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


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.rproxy.admin;
006:
007:        import java.util.LinkedList;
008:        import java.util.MissingResourceException;
009:        import java.util.ResourceBundle;
010:        import java.util.StringTokenizer;
011:
012:        import com.iplanet.am.console.base.model.AMAdminLog;
013:        import com.iplanet.am.console.base.model.AMModelBase;
014:        import com.iplanet.am.util.Debug;
015:        import com.iplanet.am.util.Locale;
016:        import com.iplanet.jato.ModelManager;
017:        import com.iplanet.jato.ModelTypeMap;
018:        import com.iplanet.jato.RequestContext;
019:        import com.iplanet.sso.SSOException;
020:        import com.iplanet.sso.SSOToken;
021:        import com.iplanet.sso.SSOTokenManager;
022:
023:        /**
024:         * Model manager for rewriter admin module.
025:         */
026:        public class GatewayAdminModelManager extends ModelManager {
027:
028:            public static final String SRAP_GATEWAY_MODEL_MGR_KEY = "srapGatewayModelMgrKey";
029:
030:            private static final String TOKEN_DELIMITER = "|";
031:
032:            protected SSOToken token = null;
033:
034:            protected String rbName = "srapgwadminmsg";
035:
036:            protected ResourceBundle bundle = null;
037:
038:            protected java.util.Locale locale = null;
039:
040:            protected AMAdminLog logger = null;
041:
042:            private static Debug debug = AMModelBase.debug;
043:
044:            static {
045:                if (AMModelBase.debug == null) {
046:                    debug = AMModelBase.debug = com.iplanet.am.util.Debug
047:                            .getInstance("amConsole");
048:                }
049:            }
050:
051:            /**
052:             * Constructor
053:             * 
054:             * @param requestContext
055:             *            is the JATO request context.
056:             * @param typeMap
057:             *            is the JATO ModelTypeMap object.
058:             */
059:            public GatewayAdminModelManager(RequestContext requestContext,
060:                    ModelTypeMap typeMap) {
061:                super (requestContext, typeMap);
062:                initSSOToken(requestContext);
063:                initRB();
064:                initLogger();
065:            }
066:
067:            /**
068:             * Initializes the SSO token for use in this request. The SSO token can then
069:             * be used as a store for session info across requests.
070:             * 
071:             * @param requestContext
072:             *            is the JATO request context.
073:             */
074:            void initSSOToken(RequestContext requestContext) {
075:                try {
076:                    SSOTokenManager manager = SSOTokenManager.getInstance();
077:                    token = manager.createSSOToken(requestContext.getRequest());
078:                    manager.getInstance().validateToken(token);
079:                } catch (Exception e) {
080:                    /*
081:                     * XXX log the error.
082:                     */
083:                    token = null;
084:                }
085:            }
086:
087:            /**
088:             * Initializes the resuource bundle using the locale from the SSO token.
089:             */
090:            void initRB() {
091:                if (token != null) {
092:                    try {
093:                        String lstr = token.getProperty("Locale");
094:                        locale = Locale.getLocale(lstr);
095:                    } catch (SSOException ssoe) {
096:                        locale = java.util.Locale.getDefault();
097:                    }
098:                } else {
099:                    locale = java.util.Locale.getDefault();
100:                }
101:                try {
102:                    bundle = ResourceBundle.getBundle(rbName, locale);
103:                } catch (MissingResourceException mre) {
104:                    // XXX write debug msg
105:                }
106:            }
107:
108:            /**
109:             * Initializes the logger using the SSO token.
110:             */
111:            void initLogger() {
112:                if (token != null) {
113:                    logger = new AMAdminLog(token);
114:                }
115:            }
116:
117:            public void doLog(String msgString) {
118:                if (logger != null) {
119:                    logger.doLog(msgString);
120:                }
121:            }
122:
123:            public static boolean warningEnabled() {
124:                return debug.warningEnabled();
125:            }
126:
127:            public static boolean messageEnabled() {
128:                return debug.messageEnabled();
129:            }
130:
131:            public static void debugWarning(String message) {
132:                if (debug.warningEnabled())
133:                    debug.warning(message);
134:            }
135:
136:            public static void debugWarning(String message, Throwable t) {
137:                if (debug.warningEnabled())
138:                    debug.warning(message, t);
139:            }
140:
141:            public static void debugMessage(String message) {
142:                if (debug.messageEnabled())
143:                    debug.message(message);
144:            }
145:
146:            public static void debugMessage(String message, Throwable t) {
147:                if (debug.messageEnabled())
148:                    debug.message(message, t);
149:            }
150:
151:            public static void debugError(String message) {
152:                debug.error(message);
153:            }
154:
155:            public static void debugError(String message, Throwable t) {
156:                debug.error(message, t);
157:            }
158:
159:            /**
160:             * Returns the localized resource string for the corresponding resource key.
161:             */
162:            public String getString(String key) {
163:                String result = null;
164:                try {
165:                    if (bundle != null) {
166:                        result = bundle.getString(key);
167:                    }
168:                } catch (MissingResourceException mre) {
169:                    // XXX write debug msg
170:                }
171:                return result;
172:            }
173:
174:            /**
175:             * Can the SSO token be used for storing infomation across multiple
176:             * requests?
177:             * 
178:             * @return true if the SSO token is used to store session info; otherwise
179:             *         return false.
180:             */
181:            protected boolean useSSOToekn() {
182:                return (token == null) ? false : true;
183:            }
184:
185:            protected String getDelimitedValue(String[] values) {
186:                StringBuffer sb = new StringBuffer();
187:                for (int i = 0; i < values.length; i++) {
188:                    sb.append(values[i]);
189:                    if (i < (values.length - 1)) {
190:                        sb.append(TOKEN_DELIMITER);
191:                    }
192:                }
193:                return sb.toString();
194:            }
195:
196:            protected String[] getUnDelimitedValue(String value) {
197:                StringTokenizer st = new StringTokenizer(value, TOKEN_DELIMITER);
198:                java.util.List result = new LinkedList();
199:                while (st.hasMoreTokens()) {
200:                    String token = st.nextToken();
201:                    result.add(token);
202:                }
203:                return (String[]) result.toArray(new String[] {});
204:            }
205:
206:            /**
207:             * Stores the name/value(s) pair so that the information can be maintained
208:             * across multiple requests. Removes any prior value(s) that are stored
209:             * under the same name before storing the new value(s).
210:             * 
211:             * @param name
212:             *            the name under which the value(s) are store.
213:             * @param value
214:             *            an array of String object(s) of the actual value(s).
215:             */
216:            public void storeToSession(String name, String[] values) {
217:                String delimitedValue = null;
218:                if ((name != null) && (!name.equals("")) && (values != null)) {
219:                    delimitedValue = getDelimitedValue(values);
220:                }
221:
222:                if (useSSOToekn()) {
223:                    try {
224:                        token.setProperty(name, delimitedValue);
225:                    } catch (SSOException ssoe) {
226:                        /* XXX log this error */
227:                    }
228:                } else {
229:                    getRequestContext().getRequest().getSession().setAttribute(
230:                            name, delimitedValue);
231:                }
232:            }
233:
234:            /**
235:             * Returns the value(s) associated with the given name in the name/value(s)
236:             * store.
237:             * 
238:             * @param name
239:             *            the name under which the value(s) are store.
240:             * @return an array of String object(s) of the actual value(s). Returns an
241:             *         empty array if no value(s) are found.
242:             */
243:            public String[] getFromSession(String name) {
244:                String delimitedValue = null;
245:                if (useSSOToekn()) {
246:                    try {
247:                        delimitedValue = token.getProperty(name);
248:                    } catch (SSOException ssoe) {
249:                        /* XXX log this error */
250:                    }
251:                } else {
252:                    delimitedValue = (String) getRequestContext().getRequest()
253:                            .getSession().getAttribute(name);
254:                }
255:                return getUnDelimitedValue(delimitedValue);
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.