Source Code Cross Referenced for AMHelper.java in  » Portal » Open-Portal » com » sun » portal » wsrp » consumer » admin » mbeans » 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.portal.wsrp.consumer.admin.mbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: AMHelper.java,v 1.1 2005/08/27 05:15:39 yue Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wsrp.consumer.admin.mbeans;
014:
015:        import java.util.ArrayList;
016:        import java.util.HashMap;
017:        import java.util.Iterator;
018:        import java.util.Map;
019:        import java.util.Set;
020:
021:        import netscape.ldap.LDAPDN;
022:        import netscape.ldap.util.DN;
023:
024:        import com.iplanet.am.sdk.AMConstants;
025:        import com.iplanet.am.sdk.AMObject;
026:        import com.iplanet.am.sdk.AMOrganization;
027:        import com.iplanet.am.sdk.AMStoreConnection;
028:        import com.sun.portal.admin.server.AdminServerUtil;
029:
030:        public class AMHelper {
031:            public static AMObject getAMObject(String dn) throws Exception {
032:                AMStoreConnection sc = new AMStoreConnection(AdminServerUtil
033:                        .getSSOToken());
034:                int objectType = sc.getAMObjectType(dn);
035:                AMObject dpObj = null;
036:
037:                switch (objectType) {
038:                case AMObject.ORGANIZATION:
039:                    dpObj = sc.getOrganization(dn);
040:                    break;
041:                case AMObject.ORGANIZATIONAL_UNIT:
042:                    dpObj = sc.getOrganizationalUnit(dn);
043:                    break;
044:                case AMObject.GROUP:
045:                case AMObject.STATIC_GROUP:
046:                    dpObj = sc.getStaticGroup(dn);
047:                    break;
048:                case AMObject.DYNAMIC_GROUP:
049:                    dpObj = sc.getDynamicGroup(dn);
050:                    break;
051:                case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
052:                    dpObj = sc.getAssignableDynamicGroup(dn);
053:                    break;
054:                case AMObject.ROLE:
055:                    dpObj = sc.getRole(dn);
056:                    break;
057:                case AMObject.FILTERED_ROLE:
058:                    dpObj = sc.getFilteredRole(dn);
059:                    break;
060:                case AMObject.USER:
061:                    dpObj = sc.getUser(dn);
062:                    break;
063:                case AMObject.PEOPLE_CONTAINER:
064:                    dpObj = sc.getPeopleContainer(dn);
065:                    break;
066:                case AMObject.GROUP_CONTAINER:
067:                    dpObj = sc.getGroupContainer(dn);
068:                    break;
069:                default:
070:                }
071:
072:                return dpObj;
073:            }
074:
075:            public static String getOrganizationDN(String dn) throws Exception {
076:                return getAMObject(dn).getOrganizationDN();
077:            }
078:
079:            public static AMOrganization getOrganization(String dn)
080:                    throws Exception {
081:                AMStoreConnection sc = new AMStoreConnection(AdminServerUtil
082:                        .getSSOToken());
083:                return sc.getOrganization(getOrganizationDN(dn));
084:            }
085:
086:            public static String getNamingAttribute(int objectType) {
087:                String namingAttribute = "";
088:
089:                try {
090:                    namingAttribute = AMStoreConnection
091:                            .getNamingAttribute(objectType);
092:                } catch (Exception e) {
093:                }
094:
095:                return namingAttribute;
096:            }
097:
098:            public static String DNToName(String roleDN) {
099:                String result = roleDN;
100:
101:                if (DN.isDN(roleDN)) {
102:                    String[] components = LDAPDN.explodeDN(roleDN, true);
103:                    result = components[0];
104:
105:                    // temp workaround until localization of role names is completed
106:                    //
107:                    // when displaying the role name for one of the group admin
108:                    // strip off the cn= and the remainder of the name after the
109:                    // first occurance of "_" which is not part of actual role name.
110:                    // Help Desk Admin's are named 'help_desk_cn=' so for
111:                    // this case we must strip off the naming portion, then
112:                    // everything after the first '_'.
113:                    String HD_NAME = "help_desk_"
114:                            + getNamingAttribute(AMObject.GROUP) + "=";
115:
116:                    String suffix = "Admin";
117:
118:                    if (result.startsWith(HD_NAME)) {
119:                        result = result.substring(HD_NAME.length());
120:                        suffix = "Help Desk Admin";
121:                        int end = result.indexOf("_");
122:
123:                        if (end == -1) {
124:                            end = result.length();
125:                        }
126:
127:                        result = result.substring(0, end) + " " + suffix;
128:                    } else {
129:                        String grpNamingAttr = getNamingAttribute(AMObject.GROUP);
130:                        String pcNamingAttr = getNamingAttribute(AMObject.PEOPLE_CONTAINER);
131:
132:                        if (result.startsWith(grpNamingAttr + "=")) {
133:                            /*
134:                             * Sub groups will contain multiple occurences of '_cn'
135:                             * in the dn so we need to first check if this string
136:                             * exists in the new result string. If '_cn=' is not 
137:                             * present, then return the portion leading up to '_ou'.
138:                             */
139:                            int start = 3;
140:                            int end = result.indexOf("_" + grpNamingAttr + "=");
141:
142:                            if (end == -1) {
143:                                end = result
144:                                        .lastIndexOf("_"
145:                                                + getNamingAttribute(AMObject.GROUP_CONTAINER));
146:
147:                                if (end == -1) {
148:                                    end = result.length();
149:                                }
150:                            }
151:
152:                            result = result.substring(start, end) + " "
153:                                    + suffix;
154:                        } else if (result.startsWith(pcNamingAttr + "=")) {
155:                            int start = 3;
156:                            result = result.substring(start);
157:                            int end = result.indexOf("_");
158:
159:                            if (end == -1) {
160:                                end = result.length();
161:                            }
162:
163:                            result = result.substring(0, end) + " " + suffix;
164:                        }
165:                    }
166:                }
167:
168:                return result;
169:            }
170:
171:            public static Map getAllRoles(String dn) throws Exception {
172:                Set roles = getOrganization(dn).getRoles(AMConstants.SCOPE_ONE);
173:                Map result = new HashMap(roles.size());
174:
175:                for (Iterator i = roles.iterator(); i.hasNext();) {
176:                    String roleDN = (String) i.next();
177:                    String roleDNDisplayString = DNToName(roleDN);
178:
179:                    if (!roleDNDisplayString.startsWith("_WSRPRole_")) {
180:                        result.put(roleDN, roleDNDisplayString);
181:                    }
182:                }
183:
184:                return result;
185:            }
186:        }
w___w__w_.___ja_v_a___2___s__.__c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.