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


001:        package com.sun.portal.util;
002:
003:        import java.util.Hashtable;
004:        import java.util.logging.Level;
005:        import java.util.logging.Logger;
006:
007:        import com.iplanet.log.LogException;
008:        import com.iplanet.log.LogManager;
009:        import com.iplanet.log.LogRecord;
010:        import com.iplanet.sso.SSOException;
011:        import com.iplanet.sso.SSOToken;
012:        import com.iplanet.sso.SSOTokenManager;
013:        import com.sun.portal.log.common.PortalLogger;
014:        import com.sun.portal.rproxy.configservlet.client.GatewayProfile;
015:
016:        public class NetletLogMgr {
017:
018:            private static String logName = "srapNetlet";
019:
020:            public static LogManager lm = null;
021:
022:            public static boolean loggingEnabled = false;
023:
024:            // public static SSOToken appSession = null;
025:            private static int logId = 0;
026:
027:            // Lihue # 7.4.4.1
028:            public static Hashtable logIdMap = new Hashtable();
029:
030:            // EOC :: Lihue # 7.4.4.1
031:
032:            private static String actualLogName = null;
033:
034:            private static boolean logError = false;
035:
036:            private static String platformLogName = null;
037:
038:            // static Logger logger = Logger.getLogger("com.sun.portal.sra.rproxy");
039:            private static Logger logger = PortalLogger
040:                    .getLogger(NetletLogMgr.class);
041:
042:            static {
043:                platformLogName = SystemProperties.get("netlet.logname");
044:                if (platformLogName != null) {
045:                    platformLogName = platformLogName.trim().replace('-', '_');
046:                    if (platformLogName.length() == 0) {
047:                        platformLogName = null;
048:                    }
049:                }
050:                /*
051:                 * try{ if (appSession == null) { String sessid =
052:                 * ApplicationLogin.login("srapGateway"); appSession =
053:                 * createSession(sessid); } }catch(Exception ex){
054:                 * System.err.println("Error while creating Application Session !");
055:                 * ex.printStackTrace(); }
056:                 */
057:                /*
058:                 * if (appSession != null){ System.out.println("Got session ... "); }
059:                 * else{ System.out.println("NO SESSION !!!!"); }
060:                 */
061:            }
062:
063:            public static String getUserId(String sessionID) {
064:                try {
065:                    // sessionID = URLDecoder.decode(sessionID);
066:                    // SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
067:                    // SSOToken ssoToken = ssoTokenManager.createSSOToken(sessionID);
068:                    SSOToken ssoToken = SSOUtil.getSSOToken(sessionID);
069:                    String userDN = ssoToken.getPrincipal().getName();
070:                    return userDN.substring((userDN.indexOf("=") + 1), userDN
071:                            .indexOf(","));
072:                } catch (Exception ex) {
073:                    // logger.severe("NetletLogMgr: Unable to get user ID -> " + ex);
074:                    logger.log(Level.SEVERE, "PSSR_CSPU078", ex);
075:                }
076:                return ""; // If null is returned, nothing will be logged
077:            }
078:
079:            public synchronized static int getLogId() {
080:                return ++logId;
081:            }
082:
083:            public static void createDefault() {
084:                createDefault(logName);
085:            }
086:
087:            private static SSOToken createSession(String sessid) {
088:
089:                SSOToken token = null;
090:                try {
091:                    // SSOTokenManager manager = SSOTokenManager.getInstance();
092:                    // token = manager.createSSOToken(sessid);
093:                    token = SSOUtil.getSSOTokenNoDecode(sessid);
094:                } catch (SSOException ex) {
095:                    // logger.severe("Unable to create application session!");
096:                    logger.severe("PSSR_CSPU079");
097:                    ex.printStackTrace();
098:                    token = null;
099:                } catch (Exception ex) {
100:                    // logger.severe("Unable to create application session!");
101:                    logger.severe("PSSR_CSPU080");
102:                    ex.printStackTrace();
103:                    token = null;
104:                }
105:                return token;
106:            }
107:
108:            static {
109:                loggingEnabled = GatewayProfile.getBoolean(
110:                        "NetletLoggingEnabled", false);
111:            }
112:
113:            public static void createDefault(String name) {
114:
115:                /*
116:                 * if (appSession == null) { String sessid =
117:                 * ApplicationLogin.login("srapGateway"); appSession =
118:                 * createSession(sessid); }
119:                 */
120:
121:                if (loggingEnabled) {
122:
123:                    lm = new LogManager(GWLogManager.appSession);
124:
125:                    if (name != null) {
126:                        if (name.length() > 0) {
127:                            logName = name;
128:                        }
129:                    }
130:
131:                    if (platformLogName != null) {
132:                        // Override the default log name.
133:                        logName = platformLogName;
134:                    }
135:
136:                    try {
137:                        NetletLogMgr.lm.create(logName);
138:                        actualLogName = logName;
139:                    } catch (LogException e) {
140:                        actualLogName = null;
141:                        // logger.severe("NetletLogMgr: Unable to create log");
142:                        logger.severe("PSSR_CSPU081");
143:                        // logger.severe("NetletLogMgr: " + e.toString());
144:                        Object[] params4 = { e.toString() };
145:                        logger.log(Level.SEVERE, "PSSR_CSPU082", params4);
146:                    }
147:                }
148:            }
149:
150:            public static void write(String type, String msg) {
151:
152:                if (lm == null) {
153:                    return;
154:                }
155:                if (logError) {
156:                    return;
157:                }
158:
159:                if (!loggingEnabled) {
160:                    return;
161:                }
162:
163:                try {
164:                    // LogRecord lr = new LogRecord(type, msg);
165:                    LogRecord lr = new LogRecord("ACCESS", msg);
166:                    NetletLogMgr.lm.write(lr, logName);
167:                } catch (Exception e) {
168:                    logError = true;
169:                    // logger.severe("NetletLogMgr: Unable to create log record");
170:                    logger.severe("PSSR_CSPU083");
171:                    String reason = e.toString();
172:                    // logger.severe("NetletLogMgr: " + reason);
173:                    Object[] params6 = { reason };
174:                    logger.log(Level.SEVERE, "PSSR_CSPU084", params6);
175:                    /*
176:                     * if ((reason.indexOf("invalidSession") != -1) &&
177:                     * logName.equals("srapGateway")) { String cmd =
178:                     * "/etc/init.d/ipsgateway start";
179:                     * 
180:                     * try { // Need to change back to root. GW gw = new GW();
181:                     * gw.unrun_GW();
182:                     * 
183:                     * Runtime.getRuntime().exec(cmd); } catch (Exception ex) { }
184:                     * System.exit(1); }
185:                     */
186:                    // What do we do ??
187:                    // Currently just getting another session.
188:                    synchronized (actualLogName) {
189:                        if (logError) {
190:                            if (!isAppSessionValid(GWLogManager.appSession)) {
191:                                createDefault(actualLogName);
192:                                logError = false;
193:                            }
194:                        }
195:                    }
196:                }
197:            }
198:
199:            private static boolean isAppSessionValid(SSOToken token) {
200:                boolean isvalid = false;
201:                try {
202:                    SSOTokenManager manager = SSOTokenManager.getInstance();
203:                    isvalid = manager.isValidToken(token);
204:                } catch (SSOException ssoex) {
205:                }
206:                return isvalid;
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.