Source Code Cross Referenced for PSClientAwareAuthlessContext.java in  » Portal » Open-Portal » com » sun » ssoadapter » config » 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 » Portal » Open Portal » com.sun.ssoadapter.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: PSClientAwareAuthlessContext.java,v 1.7 2005/10/13 16:35:49 dpolla Exp $
003:         * Copyright 2002 Sun Microsystems, Inc. Allrights reserved. Use of
004:         * this product is subjectto license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users Subject to Standard License
006:         * Terms and Conditions.
007:         *
008:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE are trademarks or
009:         * registered trademarks of Sun Microsystems,Inc. in the United States
010:         * and other countries.
011:         */package com.sun.ssoadapter.config;
012:
013:        import java.util.Map;
014:        import java.util.HashMap;
015:        import java.util.Iterator;
016:        import java.util.Set;
017:        import java.util.HashSet;
018:        import java.util.Locale;
019:        import java.util.StringTokenizer;
020:        import java.security.AccessController;
021:
022:        import java.io.File;
023:        import java.io.IOException;
024:        import java.io.FileNotFoundException;
025:        import java.util.MissingResourceException;
026:        import java.util.logging.Level;
027:        import java.util.logging.Logger;
028:
029:        import com.iplanet.am.util.AdminUtils;
030:        import com.iplanet.sso.SSOException;
031:        import com.iplanet.sso.SSOToken;
032:        import com.sun.identity.security.AdminTokenAction;
033:        import com.sun.ssoadapter.SSOAdapterLogger;
034:        import com.sun.ssoadapter.SSOAdapterSession;
035:
036:        public class PSClientAwareAuthlessContext implements 
037:                ClientAwareUserContext, DSAMEConstants {
038:            private String this ClassName = null;
039:
040:            private DSAMEConnection dsameConn = null;
041:            private DSAMEUtils dsameUtils = null;
042:
043:            private String sessClientType = null;
044:            private String charset = null;
045:
046:            private ClientAwareAppContext caAppContext = null;
047:
048:            private static Logger logger = SSOAdapterLogger
049:                    .getLogger("com.sun.portal.ssoadapter.config");
050:
051:            //
052:            // authless authentication session uid
053:            //
054:            private static final String authlessSUID = "ssoadapter.authless.suid";
055:
056:            /*
057:             * Initialize ClientAwareUserContext for an authless authenticated user.
058:             * Since the Session is invalid, need to establish a connection based on 
059:             * the authless anonymous uid.
060:             *
061:             * @param session         SSOAdapterSession Object
062:             * @param appContent  The ClientAwareAppContext
063:             */
064:            /**
065:             * 
066:             * @param session 
067:             * @param appContext 
068:             * @throws java.lang.IllegalStateException 
069:             * @throws com.sun.ssoadapter.config.SAALException 
070:             */
071:            public synchronized void init(SSOAdapterSession session,
072:                    ClientAwareAppContext appContext)
073:                    throws IllegalStateException, SAALException {
074:
075:                //
076:                // order matters here!
077:                //
078:                this ClassName = getClass().getName(); // for debug
079:
080:                // store ClientAware AppContext - needed for debugMessage()
081:                caAppContext = appContext;
082:
083:                if (logger.isLoggable(Level.FINEST)) {
084:                    logger.log(Level.FINEST, "PSSA_CSSC0010");
085:                }
086:
087:                // check to see if authless authentication session uid has 
088:                // been set in request
089:                // 
090:                String userDN = session.getAuthlessUID();
091:
092:                if (userDN == null) {
093:                    if (logger.isLoggable(Level.SEVERE)) {
094:                        logger.log(Level.SEVERE, "PSSA_CSSC0011");
095:                    }
096:                    throw new IllegalStateException("Session Invalid:");
097:                }
098:
099:                sessClientType = caAppContext.getClientType(session);
100:
101:                //
102:                // Get the AdminConnection to DSAME
103:                // Get the instance of DSAMEUtils, should have been created by
104:                // DSAMEServiceAppContext
105:                //
106:                SSOToken ssot = (SSOToken) AccessController
107:                        .doPrivileged(AdminTokenAction.getInstance());
108:                dsameConn = new DSAMEConnection(ssot, userDN);
109:                dsameUtils = DSAMEUtils.getInstance(dsameConn);
110:
111:                if (dsameUtils == null) {
112:                    throw new SAALException(this ClassName
113:                            + ": DSAMEUtils not Initialized");
114:                }
115:
116:                if (logger.isLoggable(Level.FINEST)) {
117:                    logger.log(Level.FINEST, "PSSA_CSSC0012");
118:                }
119:
120:            }
121:
122:            //
123:            // service methods - to get classnames
124:            //
125:
126:            /**
127:             * Defaults:
128:             *   clientType - session
129:             * @param service 
130:             * @param attrName 
131:             * @throws java.lang.IllegalStateException 
132:             * @throws java.io.IOException 
133:             * @return 
134:             */
135:            public String getStringAttribute(Map service, String attrName)
136:                    throws IllegalStateException, IOException {
137:                return getStringAttribute(service, getClientType(), attrName);
138:            }
139:
140:            /**
141:             * 
142:             * @param service 
143:             * @param client 
144:             * @param attrName 
145:             * @throws java.lang.IllegalStateException 
146:             * @throws java.io.IOException 
147:             * @return 
148:             */
149:            public String getStringAttribute(Map service, String client,
150:                    String attrName) throws IllegalStateException, IOException {
151:                String val = null;
152:                Set vals = getAttribute(service, client, attrName);
153:
154:                if (vals != null && vals.size() > 0) {
155:                    Iterator iter = vals.iterator();
156:                    val = (String) iter.next();
157:                }
158:
159:                if (logger.isLoggable(Level.FINEST)) {
160:                    String[] param = { attrName, val };
161:                    logger.log(Level.FINEST, "PSSA_CSSC0013", param);
162:                }
163:
164:                return (val);
165:            }
166:
167:            /**
168:             * Defaults:
169:             *   clientType - session
170:             * @param service 
171:             * @param attrName 
172:             * @throws java.lang.IllegalStateException 
173:             * @throws java.io.IOException 
174:             * @return 
175:             */
176:            public Set getAttribute(Map service, String attrName)
177:                    throws IllegalStateException, IOException {
178:                return getAttribute(service, getClientType(), attrName);
179:
180:            }
181:
182:            /**
183:             * 
184:             * @param service 
185:             * @param client 
186:             * @param attrName 
187:             * @throws java.lang.IllegalStateException 
188:             * @throws java.io.IOException 
189:             * @return 
190:             */
191:            public Set getAttribute(Map service, String client, String attrName)
192:                    throws IllegalStateException, IOException {
193:                String serviceName = dsameUtils.getServiceName(service);
194:                return getAttribute(serviceName, client, attrName, true, null,
195:                        0, 0);
196:            }
197:
198:            /**
199:             * All getAttribute() calls map into this one.
200:             * 
201:             * @return Set of all client-aware attributes
202:             * @param serviceName 
203:             * @param client 
204:             * @param attrName The name of the attribute
205:             * @param removeClientInfo When the getAttribute() calls DSAMEUtils.
206:             *   getClientValues(), it removes the client-info from the vals. This
207:             *   flag prevents it from doing so. (Used in the call from setAttribute())
208:             * @param awareMap To store the results from the parsing of attributes.
209:             *   Used by setAttribute() to reused the parsed objects.
210:             * @param scope The scope of the attribute to look for (used by setAttr())
211:             * @param type The attribute type (list/string..) (used by setAttr()).
212:             * @throws java.lang.IllegalStateException 
213:             * @throws java.io.IOException 
214:             */
215:            private Set getAttribute(String serviceName, String client,
216:                    String attrName, boolean removeClientInfo, Map awareMap,
217:                    int scope, int type) throws IllegalStateException,
218:                    IOException {
219:                Set vals = null;
220:                Set retVals = null;
221:
222:                if (logger.isLoggable(Level.FINEST)) {
223:                    String[] param = { attrName, serviceName, client };
224:                    logger.log(Level.FINEST, "PSSA_CSSC0014", param);
225:                }
226:
227:                //
228:                // Lookup attrName in our attribute name Hashmap and get the
229:                // the attribute type - Global/Org/User-Dynamic
230:                //
231:
232:                scope = (scope != 0) ? scope : dsameUtils.getAttributeScope(
233:                        serviceName, attrName);
234:
235:                switch (scope) {
236:                case GLOBAL: //
237:                    vals = dsameConn.getGlobalAttribute(serviceName, attrName);
238:                    break;
239:
240:                case ORGANIZATION: //
241:                    vals = dsameConn.getOrganizationAttribute(serviceName,
242:                            attrName);
243:                    break;
244:
245:                case INSTANCE: //
246:                    break;
247:
248:                case POLICY: //
249:                case DYNAMIC:
250:                case USER:
251:                default: // assume user scope
252:                    //
253:                    // Policy/Dynamic/User/Unknown - USER scope
254:                    //
255:                    vals = dsameConn.getAttribute(attrName);
256:                    break;
257:                }
258:
259:                //
260:                // Get the Type
261:                //
262:
263:                type = (type != 0) ? type : dsameUtils.getAttributeType(
264:                        serviceName, attrName);
265:                switch (type) {
266:                case SINGLE:
267:                    //
268:                    // return the List. The getStringAttribute() will pick up
269:                    // only the first value !
270:                    //
271:                    retVals = vals;
272:                    break;
273:
274:                case LIST:
275:                    //
276:                    //
277:                    //
278:                    retVals = dsameUtils.getClientValues(vals, client,
279:                            awareMap, removeClientInfo);
280:                    break;
281:
282:                default:
283:                    retVals = vals;
284:                    break;
285:                }
286:
287:                return retVals;
288:            }
289:
290:            public void store() {
291:            }
292:
293:            //
294:            // Unsupported Operations
295:            //
296:
297:            /**
298:             * 
299:             * @param service 
300:             * @param attrName 
301:             * @param val 
302:             * @throws java.lang.IllegalStateException 
303:             * @throws java.util.MissingResourceException 
304:             * @throws java.io.IOException 
305:             */
306:            public void setStringAttribute(Map service, String attrName,
307:                    String val) throws IllegalStateException,
308:                    MissingResourceException, IOException {
309:                throw new IllegalStateException(
310:                        "Session Operation Not Supported");
311:            }
312:
313:            /**
314:             * 
315:             * @param service 
316:             * @param attrName 
317:             * @param val 
318:             * @param forceCA 
319:             * @throws java.lang.IllegalStateException 
320:             * @throws java.util.MissingResourceException 
321:             * @throws java.io.IOException 
322:             */
323:            public void setStringAttribute(Map service, String attrName,
324:                    String val, boolean forceCA) throws IllegalStateException,
325:                    MissingResourceException, IOException {
326:                throw new IllegalStateException(
327:                        "Session Operation Not Supported");
328:            }
329:
330:            /**
331:             * 
332:             * @param service 
333:             * @param client 
334:             * @param attrName 
335:             * @param val 
336:             * @throws java.lang.IllegalStateException 
337:             * @throws java.util.MissingResourceException 
338:             * @throws java.io.IOException 
339:             */
340:            public void setStringAttribute(Map service, String client,
341:                    String attrName, String val) throws IllegalStateException,
342:                    MissingResourceException, IOException {
343:                throw new IllegalStateException(
344:                        "Session Operation Not Supported");
345:            }
346:
347:            /**
348:             * 
349:             * @param service 
350:             * @param client 
351:             * @param attrName 
352:             * @param val 
353:             * @param forceClientAwareness 
354:             * @throws java.lang.IllegalStateException 
355:             * @throws java.util.MissingResourceException 
356:             * @throws java.io.IOException 
357:             */
358:            private void setStringAttribute(Map service, String client,
359:                    String attrName, String val, boolean forceClientAwareness)
360:                    throws IllegalStateException, MissingResourceException,
361:                    IOException {
362:                throw new IllegalStateException(
363:                        "Session Operation Not Supported");
364:            }
365:
366:            /**
367:             * 
368:             * @param service 
369:             * @param attrName 
370:             * @param vals 
371:             * @throws java.lang.IllegalStateException 
372:             * @throws java.util.MissingResourceException 
373:             * @throws java.io.IOException 
374:             */
375:            public void setAttribute(Map service, String attrName, Set vals)
376:                    throws IllegalStateException, MissingResourceException,
377:                    IOException {
378:                throw new IllegalStateException(
379:                        "Session Operation Not Supported");
380:            }
381:
382:            /**
383:             * 
384:             * @param service 
385:             * @param attrName 
386:             * @param vals 
387:             * @param forceClientAwareness 
388:             * @throws java.lang.IllegalStateException 
389:             * @throws java.util.MissingResourceException 
390:             * @throws java.io.IOException 
391:             */
392:            public void setAttribute(Map service, String attrName, Set vals,
393:                    boolean forceClientAwareness) throws IllegalStateException,
394:                    MissingResourceException, IOException {
395:                throw new IllegalStateException(
396:                        "Session Operation Not Supported");
397:            }
398:
399:            /**
400:             * 
401:             * @param service 
402:             * @param client 
403:             * @param attrName 
404:             * @param vals 
405:             * @throws java.lang.IllegalStateException 
406:             * @throws java.util.MissingResourceException 
407:             * @throws java.io.IOException 
408:             */
409:            public void setAttribute(Map service, String client,
410:                    String attrName, Set vals) throws IllegalStateException,
411:                    MissingResourceException, IOException {
412:                throw new IllegalStateException(
413:                        "Session Operation Not Supported");
414:            }
415:
416:            /**
417:             * 
418:             * @param service 
419:             * @param client 
420:             * @param attrName 
421:             * @param vals 
422:             * @param forceCA 
423:             * @throws java.lang.IllegalStateException 
424:             * @throws java.util.MissingResourceException 
425:             * @throws java.io.IOException 
426:             */
427:            private void setAttribute(Map service, String client,
428:                    String attrName, Set vals, boolean forceCA)
429:                    throws IllegalStateException, MissingResourceException,
430:                    IOException {
431:                throw new IllegalStateException(
432:                        "Session Operation Not Supported");
433:            }
434:
435:            /**
436:             * 
437:             * @param service 
438:             * @param attrName 
439:             * @throws java.lang.IllegalStateException 
440:             * @throws java.util.MissingResourceException 
441:             * @throws java.io.IOException 
442:             */
443:            public void removeAttribute(Map service, String attrName)
444:                    throws IllegalStateException, MissingResourceException,
445:                    IOException {
446:                throw new IllegalStateException(
447:                        "Session Operation Not Supported");
448:            }
449:
450:            //
451:            // client
452:            //  
453:
454:            /**
455:             * 
456:             * @return 
457:             */
458:            public String getClientType() {
459:                return sessClientType;
460:            }
461:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.