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


001:        /*
002:         * JSSContextImpl.java
003:         *
004:         */
005:
006:        /**
007:         *
008:         * @author  ss133690
009:         * @version 0.1
010:         */package com.sun.portal.cli.cert;
011:
012:        import org.mozilla.jss.crypto.*;
013:        import com.sun.portal.log.common.PortalLogger;
014:        import org.mozilla.jss.*;
015:        import java.security.*;
016:
017:        public class JSSContextImpl implements  JSSContext {
018:            protected String certdir;
019:            protected String fqdn;
020:            protected String locale = "en_US";
021:            protected String inst;
022:            protected CryptoManager cm;
023:            //protected KeyStore ks;
024:            protected boolean passfileExist = true;
025:            protected boolean dbfileExist = true;
026:            protected SignatureAlgorithm sigAlg = SignatureAlgorithm.RSASignatureWithMD5Digest;
027:            protected boolean isPassEncrypted = true;
028:            protected PasswordContext passwdcntx;
029:
030:            public JSSContextImpl() {
031:            }
032:
033:            public JSSContextImpl(String certdir, String fqdn, String locale) {
034:                this (certdir, locale);
035:                this .fqdn = fqdn;
036:            }
037:
038:            public JSSContextImpl(String certdir, String locale) {
039:                this .certdir = certdir;
040:                this .locale = locale;
041:            }
042:
043:            public void setCertdir(String certdir) {
044:                this .certdir = certdir;
045:            }
046:
047:            public void setHost(String fqdn) {
048:                this .fqdn = fqdn;
049:            }
050:
051:            public void setLocale(String locale) {
052:                this .locale = locale;
053:            }
054:
055:            public String getCertdir() {
056:                return certdir;
057:            }
058:
059:            public String getHost() {
060:                return fqdn;
061:            }
062:
063:            public String getLocale() {
064:                return locale;
065:            }
066:
067:            public CryptoManager getCryptoManager() {
068:                return cm;
069:            }
070:
071:            /*public KeyStore getKeyStore(){
072:                return ks;
073:            }*/
074:            public SignatureAlgorithm getSigAlg() {
075:                return sigAlg;
076:            }
077:
078:            public boolean isPassFileExist() {
079:                return CertAdminUtil.fileExist(certdir
080:                        + CertAdminConstants.SEPERATOR
081:                        + CertAdminConstants.JSSPASSFILE);
082:            }
083:
084:            public boolean isDBFileExist() {
085:                return CertAdminUtil.fileExist(certdir
086:                        + CertAdminConstants.SEPERATOR
087:                        + CertAdminConstants.KEYDB);
088:            }
089:
090:            public boolean isPasswordEcrypted() {
091:                if (isPassFileExist()) {
092:                    String jsspass = CertAdminUtil.readLine(certdir
093:                            + CertAdminConstants.SEPERATOR
094:                            + CertAdminConstants.JSSPASSFILE);
095:                    isPassEncrypted = JSSUtil.isPasswordEncrypted(jsspass);
096:                }
097:                return isPassEncrypted;
098:            }
099:
100:            public void setPasswordMode(boolean encrypt) {
101:                isPassEncrypted = encrypt;
102:            }
103:
104:            public void setPasswordContext(PasswordContext passwdcntx) {
105:                this .passwdcntx = passwdcntx;
106:            }
107:
108:            public PasswordContext getPasswordContext() {
109:                return passwdcntx;
110:            }
111:
112:            /**
113:             * Initializes the certificate database.
114:             * This method should be called first after the object creation.
115:             */
116:            public boolean init() {
117:
118:                CertAdminLocale.createDefault(locale);
119:                try {
120:                    //Initialize the CryptoManager
121:                    CryptoManager.InitializationValues vals = new CryptoManager.InitializationValues(
122:                            certdir);
123:                    CryptoManager.initialize(vals);
124:                    cm = CryptoManager.getInstance();
125:                    //Initialize the KeyStore (This will be used to perform some operations which CrytoManager cannot do)
126:                    Security.insertProviderAt(new sun.security.provider.Sun(),
127:                            1);
128:                    //KeyStore ks = KeyStore.getInstance("Mozilla-JSS");
129:                    //ks.load(null,null);
130:                    //setPasswordMode(true);
131:
132:                    JSSUtil.setDefaultDecoder(certdir);
133:                    org.mozilla.jss.util.PasswordCallback password = new CertAdminPasswordCallback(
134:                            passwdcntx.generatePassphrase(this ));
135:                    cm.setPasswordCallback(password);
136:
137:                } catch (KeyDatabaseException kdbe) {
138:                    //println("GWNSSInit: Couldn't open the key database." + kdbe);
139:                    CertAdminUtil.println(CertAdminLocale.getPFString("m3",
140:                            CertAdminConstants.m3)
141:                            + CertAdminConstants.newline + kdbe);
142:                    return false;
143:                } catch (CertDatabaseException cdbe) {
144:                    //println("GWNSSInit: Couldn't open the certificate database." + cdbe);
145:                    CertAdminUtil.println(CertAdminLocale.getPFString("m4",
146:                            CertAdminConstants.m4)
147:                            + CertAdminConstants.newline + cdbe);
148:                    return false;
149:                } catch (org.mozilla.jss.crypto.AlreadyInitializedException aie) {
150:                    //println("GWNSSInit: CryptoManager already initialized." + aie);
151:                    CertAdminUtil.println(CertAdminLocale.getPFString("m5",
152:                            CertAdminConstants.m5)
153:                            + CertAdminConstants.newline + aie);
154:                } catch (SRADecoderException sde) {
155:                    //println("Error!, Could not initialize the JSS password engine");
156:                    CertAdminUtil.println(CertAdminLocale.getPFString("m54",
157:                            CertAdminConstants.m54)
158:                            + CertAdminConstants.newline + sde);
159:                } catch (Exception e) {
160:                    //println("GWNSSInit: Exception occurred: "+e.getMessage());
161:                    CertAdminUtil.println(CertAdminLocale.getPFString("m6",
162:                            CertAdminConstants.m6));
163:                    e.printStackTrace();
164:                    return false;
165:                }
166:                return true;
167:            }
168:
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.