Source Code Cross Referenced for Protocol.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » io » j2me » btgoep » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.midp.io.j2me.btgoep 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:        package com.sun.midp.io.j2me.btgoep;
027:
028:        import java.io.IOException;
029:        import javax.microedition.io.Connection;
030:        import javax.microedition.io.StreamConnectionNotifier;
031:        import javax.microedition.io.StreamConnection;
032:        import com.sun.kvem.jsr082.obex.ClientSessionImpl;
033:        import com.sun.kvem.jsr082.obex.SessionNotifierImpl;
034:        import com.sun.midp.security.SecurityToken;
035:        import com.sun.midp.io.BluetoothUrl;
036:        import com.sun.midp.io.BluetoothProtocol;
037:        import com.sun.midp.security.Permissions;
038:        import com.sun.midp.security.ImplicitlyTrustedClass;
039:        import com.sun.midp.jsr082.SecurityInitializer;
040:
041:        /**
042:         * Provides a wrapper for "btgoep" protocol implementation
043:         * to answer the GCF style.
044:         */
045:        public class Protocol extends BluetoothProtocol {
046:
047:            /**
048:             * Inner class to request security token from SecurityInitializer.
049:             * SecurityInitializer should be able to check this inner class name.
050:             */
051:            static private class SecurityTrusted implements 
052:                    ImplicitlyTrustedClass {
053:            };
054:
055:            /**
056:             * The internal security token is privileged and allows to skip
057:             * permissions check for btspp in case ones are allowed for btgoep.
058:             */
059:            private static SecurityToken internalSecurityToken = SecurityInitializer
060:                    .requestToken(new SecurityTrusted());
061:
062:            /** Originally requested url saved to reused in btspp transport. */
063:            String name = null;
064:
065:            /**
066:             * Constructs an instance.
067:             */
068:            public Protocol() {
069:                super (BluetoothUrl.OBEX);
070:            }
071:
072:            /**
073:             * Cheks permissions and opens requested connection.
074:             * Returns either ClientSession or SessionNotifier for OBEX connections,
075:             * depending whether client or server URL was specified. Actually all 
076:             * essential logic is implemented in the superclass, this one only saves
077:             * resource name to reuse it for opening btspp transport.
078:             *
079:             * @param token security token of the calling class
080:             * @param name the URL for the connection without protocol.
081:             * @param mode obex supports READ_WRITE mode only.
082:             * @param timeouts ignored (because it is allowed by spec).
083:             * @return ClientSession for client url or SessionNotifier for server url.
084:             * @exception IOException if opening connection fails.
085:             */
086:            public Connection openPrim(Object token, String name, int mode,
087:                    boolean timeouts) throws IOException {
088:                this .name = name;
089:                return super .openPrim(token, name, mode, timeouts);
090:            }
091:
092:            /** 
093:             * Ensures URL parameters have valid value. Makes nothing actually
094:             * for all the required checks will be done durin ntspp transport 
095:             * creation.
096:             * @param url URL to check
097:             */
098:            protected void checkUrl(BluetoothUrl url) {
099:            }
100:
101:            /**
102:             * Creates ClientSession connection over the rfcomm transport layer 
103:             * @param token security token of the calling class
104:             * @param mode       I/O access mode
105:             * @return ClientSession connection instance
106:             * @exception IOException if openning connection fails.
107:             */
108:            protected Connection clientConnection(SecurityToken token, int mode)
109:                    throws IOException {
110:                checkForPermission(token, Permissions.OBEX_CLIENT);
111:
112:                StreamConnection sock = (StreamConnection) new com.sun.midp.io.j2me.btspp.Protocol()
113:                        .openPrim(getBtsppToken(token), name, mode, false);
114:                return new ClientSessionImpl(new BTGOEPConnection(sock));
115:            }
116:
117:            /**
118:             * Creates server connection over the rfcomm transport layer 
119:             * @param token security token of the calling class
120:             * @param mode       I/O access mode
121:             * @return server connection instance
122:             * @exception IOException if openning connection fails.
123:             */
124:            protected Connection serverConnection(SecurityToken token, int mode)
125:                    throws IOException {
126:                checkForPermission(token, Permissions.OBEX_SERVER);
127:
128:                StreamConnectionNotifier sock = (StreamConnectionNotifier) new com.sun.midp.io.j2me.btspp.Protocol()
129:                        .openPrim(getBtsppToken(token), name, mode, false);
130:                return new SessionNotifierImpl(new BTGOEPNotifier(sock));
131:            }
132:
133:            /** 
134:             * Retrieves privileged token if there is no defined one.
135:             * @param token security token on hands or <code>null</code> 
136:             *        if there is no one 
137:             * @return privileged security token that allow acces to btspp if
138:             *     given token is <code>null</code>, the token given otherwise.
139:             */
140:            private static SecurityToken getBtsppToken(SecurityToken token) {
141:                return (token == null) ? internalSecurityToken : token;
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.