Source Code Cross Referenced for GSSManagerImpl.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » auth » jgss » 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 » Apache Harmony Java SE » org package » org.apache.harmony.auth.jgss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package org.apache.harmony.auth.jgss;
019:
020:        import java.security.Provider;
021:        import java.util.ArrayList;
022:        import java.util.Hashtable;
023:        import java.util.Set;
024:        import java.util.Map.Entry;
025:
026:        import org.apache.harmony.auth.jgss.kerberos.KerberosSpiImpl;
027:        import org.apache.harmony.auth.jgss.kerberos.KerberosProvider;
028:        import org.ietf.jgss.GSSContext;
029:        import org.ietf.jgss.GSSCredential;
030:        import org.ietf.jgss.GSSException;
031:        import org.ietf.jgss.GSSManager;
032:        import org.ietf.jgss.GSSName;
033:        import org.ietf.jgss.Oid;
034:
035:        public class GSSManagerImpl extends GSSManager {
036:
037:            private static Oid DEFAULT_MECH;
038:
039:            private static Provider DEFAULT_PROVIDER = new KerberosProvider(
040:                    "kerberos provider", 0, "");
041:
042:            private static GSSMechSpi DEFAULT_API = new KerberosSpiImpl();
043:
044:            static {
045:                try {
046:                    DEFAULT_MECH = new Oid("1.2.840.113554.1.2.2");
047:                } catch (GSSException e) {
048:
049:                }
050:            }
051:
052:            public GSSManagerImpl() throws GSSException {
053:                addProviderAtFront(DEFAULT_PROVIDER, null);
054:            }
055:
056:            private Hashtable<Oid, GSSMechSpi> spis = new Hashtable<Oid, GSSMechSpi>();
057:
058:            private static final String JGSSAPI = "GssApiMechanism.";
059:
060:            private void enumApisFromProvider(Provider p, Oid mech,
061:                    boolean override) {
062:                for (Entry entry : p.entrySet()) {
063:                    String key = (String) entry.getKey();
064:
065:                    String value = (String) entry.getValue();
066:
067:                    if (!key.startsWith(JGSSAPI)) {
068:                        continue;
069:                    }
070:
071:                    String currentMechName = key.substring(JGSSAPI.length())
072:                            .trim();
073:                    Oid currentMech;
074:                    try {
075:                        currentMech = new Oid(currentMechName);
076:                    } catch (GSSException e) {
077:                        continue;
078:                    }
079:
080:                    if (mech != null && !mech.equals(currentMech)) {
081:                        continue;
082:                    }
083:
084:                    if (!override && spis.get(currentMech) != null) {
085:                        continue;
086:                    }
087:
088:                    GSSMechSpi gssApi;
089:                    try {
090:                        gssApi = (GSSMechSpi) Class.forName(value)
091:                                .newInstance();
092:                    } catch (Exception e) {
093:                        continue;
094:                    }
095:                    spis.put(currentMech, gssApi);
096:                }
097:            }
098:
099:            @Override
100:            public void addProviderAtEnd(Provider p, Oid mech)
101:                    throws GSSException {
102:                enumApisFromProvider(p, mech, false);
103:            }
104:
105:            @Override
106:            public void addProviderAtFront(Provider p, Oid mech)
107:                    throws GSSException {
108:                enumApisFromProvider(p, mech, true);
109:            }
110:
111:            @Override
112:            public GSSContext createContext(GSSName peer, Oid mech,
113:                    GSSCredential myCred, int lifetime) throws GSSException {
114:
115:                return null;
116:            }
117:
118:            @Override
119:            public GSSContext createContext(GSSCredential myCred)
120:                    throws GSSException {
121:                // TODO Auto-generated method stub
122:                return null;
123:            }
124:
125:            @Override
126:            public GSSContext createContext(byte[] interProcessToken)
127:                    throws GSSException {
128:                // TODO Auto-generated method stub
129:                return null;
130:            }
131:
132:            @Override
133:            public GSSCredential createCredential(int usage)
134:                    throws GSSException {
135:                // TODO Auto-generated method stub
136:                return null;
137:            }
138:
139:            @Override
140:            public GSSCredential createCredential(GSSName name, int lifetime,
141:                    Oid mech, int usage) throws GSSException {
142:                // TODO Auto-generated method stub
143:                return null;
144:            }
145:
146:            @Override
147:            public GSSCredential createCredential(GSSName name, int lifetime,
148:                    Oid[] mechs, int usage) throws GSSException {
149:                // TODO Auto-generated method stub
150:                return null;
151:            }
152:
153:            @Override
154:            public GSSName createName(String nameStr, Oid nameType)
155:                    throws GSSException {
156:                if (nameType != null && nameType.equals(GSSName.NT_EXPORT_NAME)) {
157:                    return GSSNameImpl.importFromString(GSSUtils
158:                            .getBytes(nameStr), this );
159:                }
160:                return DEFAULT_API.createName(nameStr, nameType);
161:            }
162:
163:            @Override
164:            public GSSName createName(byte[] name, Oid nameType)
165:                    throws GSSException {
166:                if (nameType != null && nameType.equals(GSSName.NT_EXPORT_NAME)) {
167:                    return GSSNameImpl.importFromString(name, this );
168:                }
169:                return DEFAULT_API
170:                        .createName(GSSUtils.toString(name), nameType);
171:            }
172:
173:            @Override
174:            public GSSName createName(String nameStr, Oid nameType, Oid mech)
175:                    throws GSSException {
176:                return createName(nameStr, nameType).canonicalize(mech);
177:            }
178:
179:            @Override
180:            public GSSName createName(byte[] name, Oid nameType, Oid mech)
181:                    throws GSSException {
182:                return createName(GSSUtils.toString(name), nameType, mech);
183:            }
184:
185:            @Override
186:            public Oid[] getMechs() {
187:                Set<Oid> oids = spis.keySet();
188:                Oid[] mechs = new Oid[oids.size()];
189:                int i = 0;
190:                for (Oid oid : oids) {
191:                    mechs[i++] = oid;
192:                }
193:                return mechs;
194:            }
195:
196:            @Override
197:            public Oid[] getMechsForName(Oid nameType) {
198:                ArrayList<Oid> mechs = new ArrayList<Oid>();
199:                Oid[] oids = getMechs();
200:                for (Oid oid : oids) {
201:                    GSSMechSpi api = spis.get(oid);
202:                    Oid[] mechNames = api.getNameMechs();
203:                    boolean support = false;
204:                    for (Oid mechName : mechNames) {
205:                        if (mechName.equals(nameType)) {
206:                            support = true;
207:                            break;
208:                        }
209:                    }
210:                    if (support) {
211:                        mechs.add(oid);
212:                    }
213:                }
214:                return mechs.toArray(new Oid[mechs.size()]);
215:            }
216:
217:            @Override
218:            public Oid[] getNamesForMech(Oid mech) throws GSSException {
219:                GSSMechSpi api = getSpi(mech);
220:                return api.getNameMechs();
221:            }
222:
223:            GSSMechSpi getSpi(Oid mech) {
224:                return spis.get(mech);
225:            }
226:
227:            Oid getDefaultMech() {
228:                return DEFAULT_MECH;
229:            }
230:
231:            GSSCredentialElement createCredentialElement(GSSName name,
232:                    int initLifetime, int acceptLifetime, Oid mech, int usage) {
233:                // TODO Auto-generated method stub
234:                return null;
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.