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


001:        /*
002:         * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.sra.admin.context;
007:
008:        import java.io.File;
009:        import java.io.FileInputStream;
010:        import java.io.IOException;
011:        import java.util.ArrayList;
012:        import java.util.Properties;
013:        import java.util.logging.Level;
014:        import java.util.logging.Logger;
015:
016:        import com.sun.portal.admin.common.context.PSConfigContext;
017:        import com.sun.portal.log.common.PortalLogger;
018:        import com.sun.portal.util.Platform;
019:
020:        //
021:
022:        public class SRAFileContextImpl implements  SRAFileContext {
023:            //
024:            protected SRAPropertyContext pc = null;
025:
026:            protected PSConfigContext cc = null;
027:
028:            public static final String FORWARD_SLASH = "/";
029:
030:            public static final char FORWARD_SLASH_CHAR = '/';
031:
032:            public static final String BACK_SLASH = "\\";
033:
034:            public static final char BACK_SLASH_CHAR = '\\';
035:
036:            protected static final String GW_CONFIG_FILE_PREFIX = "GWConfig";
037:
038:            protected static final String RWP_CONFIG_FILE_PREFIX = "RWPConfig";
039:
040:            protected static final String NLP_CONFIG_FILE_PREFIX = "NLPConfig";
041:
042:            protected static final String DOT_PROPERTIES = DOT + "properties";
043:
044:            protected static final String DOT_TEMPLATE = DOT + "template";
045:
046:            protected static final String PLATFORM_CONFIGURATION_FILE_PREFIX = "platform";
047:
048:            protected static final String DOT_CONF = DOT + "conf";
049:
050:            protected static final String TEMPLATE_PLATFORM_CONFIGURATION_FILE = PLATFORM_CONFIGURATION_FILE_PREFIX
051:                    + DOT_CONF + "-orig";
052:
053:            protected static final String IDENTITY_PROPERTIES_FILE_NAME = "AMConfig";
054:
055:            protected static final String TEMPLATE_IDENTITY_PROPERTIES_FILE = IDENTITY_PROPERTIES_FILE_NAME
056:                    + DOT_PROPERTIES + DOT_TEMPLATE;
057:
058:            protected static final String LOGGING_USER_AUTHENTICATION_FILE_PREFIX = DOT
059:                    + "auth" + UNDERSCORE + "password";
060:
061:            protected static final String CERT_DIRECTORY = "cert";
062:
063:            protected static final String ROOT_CA_CERT_FILE = "libnssckbi.so";
064:
065:            protected static final String ROOT_CA_CERT_FILE_WIN = "nssckbi.dll";
066:
067:            protected static final String ROOT_CA_CERT_FILE_HP = "libnssckbi.sl";
068:
069:            private static String loggerName = "debug.com.sun.portal.admin.mbeans";
070:
071:            private static Logger logger = PortalLogger
072:                    .getLogger(SRAFileContextImpl.class);
073:
074:            public SRAFileContextImpl(SRAPropertyContext pc, PSConfigContext cc) {
075:                this .pc = pc;
076:                this .cc = cc;
077:            }
078:
079:            public String getJSSNSSLibDir() {
080:                return cc.getJSSNSSLibDir();
081:            }
082:
083:            public String getJSSJARDir() {
084:                return cc.getJSSJARDir();
085:            }
086:
087:            public String getJdmkLibLocation() {
088:                return cc.getJDMKLibDir();
089:            }
090:
091:            public String getPSProductDir() {
092:                return cc.getPSBaseDir();
093:            }
094:
095:            public String getPSConfigDir() {
096:                return cc.getPSConfigDir();
097:            }
098:
099:            public String getPSVarDir() {
100:                return cc.getPSDataDir();
101:            }
102:
103:            public String getISProductDir() {
104:                return cc.getISBaseDir();
105:            }
106:
107:            public String getISConfigDir() {
108:                return cc.getISConfigDir();
109:            }
110:
111:            public String getISVarDir() {
112:                return cc.getISDataDir();
113:            }
114:
115:            //
116:            public String getConfigurationDirectory() {
117:                return cc.getPSConfigDir();
118:            }
119:
120:            public String getInstanceGWConfigurationPropertiesFile() {
121:                return getConfigurationDirectory() + fs + GW_CONFIG_FILE_PREFIX
122:                        + DASH + pc.getInstanceName() + DOT_PROPERTIES;
123:            }
124:
125:            public String getInstanceRWPConfigurationPropertiesFile() {
126:                return getConfigurationDirectory() + fs
127:                        + RWP_CONFIG_FILE_PREFIX + DASH + pc.getInstanceName()
128:                        + DOT_PROPERTIES;
129:            }
130:
131:            public String getInstanceNLPConfigurationPropertiesFile() {
132:                return getConfigurationDirectory() + fs
133:                        + NLP_CONFIG_FILE_PREFIX + DASH + pc.getInstanceName()
134:                        + DOT_PROPERTIES;
135:            }
136:
137:            public String getInstanceDirectory() {
138:                return cc.getPSConfigDir();
139:            }
140:
141:            public String getTemplatePlatformConfigurationFile() {
142:                return cc.getPSBaseDir() + fs + "template" + fs + "sra" + fs
143:                        + TEMPLATE_PLATFORM_CONFIGURATION_FILE;
144:            }
145:
146:            public String getInstancePlatformConfigurationFile() {
147:                return getInstanceDirectory() + fs
148:                        + PLATFORM_CONFIGURATION_FILE_PREFIX + DOT_CONF + DOT
149:                        + pc.getInstanceName();
150:            }
151:
152:            public String getDefaultIdentityPropertiesFile() {
153:                return cc.getISConfigDir() + fs + IDENTITY_PROPERTIES_FILE_NAME
154:                        + DOT_PROPERTIES;
155:            }
156:
157:            public String getTemplateIdentityPropertiesFile() {
158:                return cc.getISConfigDir() + fs
159:                        + TEMPLATE_IDENTITY_PROPERTIES_FILE;
160:            }
161:
162:            public String getInstanceIdentityPropertiesFile() {
163:                return cc.getISConfigDir() + fs + IDENTITY_PROPERTIES_FILE_NAME
164:                        + DASH + pc.getInstanceName() + DOT_PROPERTIES;
165:            }
166:
167:            public String getInstanceCertificatesDirectory() {
168:                return cc.getPSConfigDir() + fs + CERT_DIRECTORY + fs
169:                        + pc.getInstanceName();
170:            }
171:
172:            public String getSourceRootCACertificatesFile() {
173:                if (is_windows())
174:                    return cc.getJSSNSSLibDir() + fs + ROOT_CA_CERT_FILE_WIN;
175:                else if (is_hpux())
176:                    return cc.getJSSNSSLibDir() + fs + ROOT_CA_CERT_FILE_HP;
177:                else
178:                    return cc.getJSSNSSLibDir() + fs + ROOT_CA_CERT_FILE;
179:            }
180:
181:            public String getDestinationRootCACertificatesFile() {
182:                if (is_windows())
183:                    return getInstanceCertificatesDirectory() + fs
184:                            + ROOT_CA_CERT_FILE_WIN;
185:                else if (is_hpux())
186:                    return getInstanceCertificatesDirectory() + fs
187:                            + ROOT_CA_CERT_FILE_HP;
188:                else
189:                    return getInstanceCertificatesDirectory() + fs
190:                            + ROOT_CA_CERT_FILE;
191:            }
192:
193:            public String getCreateSelfSignedCertificateLibraryPath() {
194:                String gatewayLibPath = "";
195:                if (is_windows())
196:                    gatewayLibPath = cc.getPSBaseDir() + fs + "lib";
197:                else
198:                    gatewayLibPath = cc.getPSBaseDir() + fs + "lib" + fs
199:                            + "solaris" + fs + "sparc";
200:                return gatewayLibPath + File.pathSeparator
201:                        + cc.getJSSNSSLibDir();
202:            }
203:
204:            public String getCreateSelfSignedCertificatePath() {
205:                return getCreateSelfSignedCertificateLibraryPath();
206:            }
207:
208:            public String getJARLocation() {
209:                return cc.getPSBaseDir() + fs + "lib";
210:            }
211:
212:            public String getLocaleLocation() {
213:                return cc.getPSBaseDir() + fs + "locale";
214:            }
215:
216:            public String getJSSJARFile() {
217:                if (is_hpux()) {
218:                    return cc.getJSSJARDir() + fs + "jss4.jar";
219:                } else {
220:                    return cc.getJSSJARDir() + fs + "jss3.jar";
221:                }
222:
223:            }
224:
225:            public String getJCELocation() {
226:                return cc.getISBaseDir() + fs + "lib";
227:            }
228:
229:            public String getCreateSelfSignedCertificateClassPath() {
230:                String result = null;
231:
232:                String jarDirectory = getJARLocation();
233:                String localeDirectory = getLocaleLocation();
234:                String jssJARFile = getJSSJARFile();
235:                String jceDirectory = getJCELocation();
236:
237:                result = jarDirectory + fs + "certadmin.jar"
238:                        + File.pathSeparator + jssJARFile + File.pathSeparator
239:                        + jceDirectory + fs + "jce1_2_1.jar"
240:                        + File.pathSeparator + jceDirectory + fs
241:                        + "sunjce_provider.jar" + File.pathSeparator
242:                        + jceDirectory + fs + "local_policy.jar"
243:                        + File.pathSeparator + jceDirectory + fs
244:                        + "US_export_policy.jar" + File.pathSeparator
245:                        + localeDirectory;
246:
247:                return result;
248:            }
249:
250:            public final String getJavaHome() {
251:                return System.getProperty("java.home");
252:            }
253:
254:            private void print(ArrayList values) {
255:                for (int i = 0; i < values.size(); i++) {
256:                    // DebugContext.message(i + " = " + values.get(i));
257:                    Object[] params0 = { " = ", values.get(i) };
258:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_CTXT000", params0);
259:                }
260:            }
261:
262:            protected String[] getInstanceNames(String prefix, String suffix) {
263:                ArrayList result = new ArrayList();
264:                File configDir = new File(getConfigurationDirectory());
265:                File[] configFiles = configDir
266:                        .listFiles(new ConfigurationFileFilter(prefix, suffix));
267:
268:                if ((configFiles != null) && (configFiles.length != 0)) {
269:                    for (int i = 0; i < configFiles.length; i++) {
270:                        String name = configFiles[i].getName();
271:                        // //DebugContext.message("name1 = " + name);
272:                        Object[] params1 = { name };
273:                        logger
274:                                .log(Level.INFO, "PSSR_CSPS_ADM_CTXT001",
275:                                        params1);
276:                        name = name.substring(prefix.length(), name
277:                                .lastIndexOf(suffix));
278:                        // //DebugContext.message("name2 = " + name);
279:                        Object[] params2 = { name };
280:                        logger
281:                                .log(Level.INFO, "PSSR_CSPS_ADM_CTXT002",
282:                                        params2);
283:                        result.add(name);
284:                    }
285:
286:                    print(result);
287:                }
288:
289:                return (result.size() == 0) ? null : (String[]) result
290:                        .toArray(new String[result.size()]);
291:            }
292:
293:            public String[] getGWInstanceNames() {
294:                return getInstanceNames(GW_CONFIG_FILE_PREFIX + DASH,
295:                        DOT_PROPERTIES);
296:            }
297:
298:            public String[] getRWPInstanceNames() {
299:                return getInstanceNames(RWP_CONFIG_FILE_PREFIX + DASH,
300:                        DOT_PROPERTIES);
301:            }
302:
303:            public String[] getNLPInstanceNames() {
304:                return getInstanceNames(NLP_CONFIG_FILE_PREFIX + DASH,
305:                        DOT_PROPERTIES);
306:            }
307:
308:            protected String[] getInstanceConfigurationFiles(String prefix,
309:                    String suffix) {
310:                ArrayList result = new ArrayList();
311:                File configDir = new File(getConfigurationDirectory());
312:                File[] configFiles = configDir
313:                        .listFiles(new ConfigurationFileFilter(prefix, suffix));
314:
315:                if ((configFiles != null) && (configFiles.length != 0)) {
316:                    for (int i = 0; i < configFiles.length; i++) {
317:                        result.add(configFiles[i].getAbsolutePath());
318:                    }
319:
320:                    print(result);
321:                }
322:
323:                return (result.size() == 0) ? null : (String[]) result
324:                        .toArray(new String[result.size()]);
325:            }
326:
327:            public String[] getGWInstanceConfigurationFiles() {
328:                return getInstanceConfigurationFiles(GW_CONFIG_FILE_PREFIX
329:                        + DASH, DOT_PROPERTIES);
330:            }
331:
332:            public String[] getRWPInstanceConfigurationFiles() {
333:                return getInstanceConfigurationFiles(RWP_CONFIG_FILE_PREFIX
334:                        + DASH, DOT_PROPERTIES);
335:            }
336:
337:            public String[] getNLPInstanceConfigurationFiles() {
338:                return getInstanceConfigurationFiles(NLP_CONFIG_FILE_PREFIX
339:                        + DASH, DOT_PROPERTIES);
340:            }
341:
342:            protected Boolean existsInstance(String instanceName,
343:                    String[] instanceNames) {
344:                Boolean result = Boolean.FALSE;
345:                if (instanceNames != null) {
346:                    for (int i = 0; i < instanceNames.length; i++) {
347:                        if (instanceName.equals(instanceNames[i])) {
348:                            result = Boolean.TRUE;
349:                            break;
350:                        }
351:                    }
352:                }
353:
354:                return result;
355:            }
356:
357:            public Boolean existsGWInstance(String instanceName) {
358:                return existsInstance(instanceName, getGWInstanceNames());
359:            }
360:
361:            public Boolean existsRWPInstance(String instanceName) {
362:                return existsInstance(instanceName, getRWPInstanceNames());
363:            }
364:
365:            public Boolean existsNLPInstance(String instanceName) {
366:                return existsInstance(instanceName, getNLPInstanceNames());
367:            }
368:
369:            protected String getInstanceConfigurationFile(String prefix,
370:                    String suffix, String instanceName) {
371:                String result = null;
372:                String[] fileNames = getInstanceConfigurationFiles(prefix,
373:                        suffix);
374:
375:                if (fileNames == null) {
376:                    // DebugContext.message("No configuration file exists for instance
377:                    // <" + instanceName + ">");
378:                    Object[] params3 = { instanceName, ">" };
379:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_CTXT003", params3);
380:                } else if (fileNames.length != 1) {
381:                    // DebugContext.message("Found more than one configuration file for
382:                    // instance <" + instanceName + ">");
383:                    Object[] params4 = { instanceName, ">" };
384:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_CTXT004", params4);
385:                    result = fileNames[0];
386:                    // DebugContext.message("Returning the first one <" + result + ">");
387:                    Object[] params5 = { result, ">" };
388:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_CTXT005", params5);
389:                } else {
390:                    result = fileNames[0];
391:                }
392:
393:                return result;
394:            }
395:
396:            public String getGWInstanceConfigurationFile(String instanceName) {
397:                return getInstanceConfigurationFile(GW_CONFIG_FILE_PREFIX
398:                        + DASH + instanceName, DOT_PROPERTIES, instanceName);
399:            }
400:
401:            public String getRWPInstanceConfigurationFile(String instanceName) {
402:                return getInstanceConfigurationFile(RWP_CONFIG_FILE_PREFIX
403:                        + DASH + instanceName, DOT_PROPERTIES, instanceName);
404:            }
405:
406:            public String getNLPInstanceConfigurationFile(String instanceName) {
407:                return getInstanceConfigurationFile(NLP_CONFIG_FILE_PREFIX
408:                        + DASH + instanceName, DOT_PROPERTIES, instanceName);
409:            }
410:
411:            public AMPropertyContext getAMPropertyContext() throws IOException {
412:                String amPropertiesFile = getDefaultIdentityPropertiesFile();
413:
414:                Properties p = load(replaceBackSlash(amPropertiesFile));
415:
416:                return new AMPropertyContextImpl(p);
417:            }
418:
419:            public String getExtraLibs(String path) {
420:                if (is_linux()) {
421:                    return path + "/jre/lib/i386/native_threads";
422:                }
423:                if (is_hpux()) {
424:                    return path + "/jre/lib/PA_RISC/native_threads";
425:                } else {
426:                    return "";
427:                }
428:            }
429:
430:            public String getNative2Ascii(String path) {
431:                if (is_linux()) {
432:                    return path + "/bin/native2ascii";
433:                }
434:                if (is_hpux()) {
435:                    return path + "/bin/native2ascii";
436:                } else {
437:                    return "/usr/bin/native2ascii";
438:                }
439:            }
440:
441:            public String replaceBackSlash(String pathName) {
442:                String result = null;
443:
444:                result = pathName.replace(BACK_SLASH_CHAR, FORWARD_SLASH_CHAR);
445:
446:                return result;
447:            }
448:
449:            public Properties load(String fileName) throws IOException {
450:                File pf = new File(fileName);
451:                Properties result = new Properties();
452:
453:                FileInputStream fis = new FileInputStream(pf);
454:                result.load(fis);
455:                fis.close();
456:
457:                return result;
458:            }
459:
460:            static public boolean is_windows() {
461:                return Platform.name.equals("windows");
462:            }
463:
464:            static public boolean is_linux() {
465:                return Platform.name.startsWith("Linux");
466:            }
467:
468:            static public boolean is_hpux() {
469:                return Platform.name.startsWith("HP-UX");
470:            }
471:
472:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.