Source Code Cross Referenced for PGPKeyRingImpl.java in  » ESB » mule » org » mule » module » pgp » 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 » ESB » mule » org.mule.module.pgp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PGPKeyRingImpl.java 10808 2008-02-14 20:36:57Z acooke $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.module.pgp;
012:
013:        import org.mule.api.lifecycle.Initialisable;
014:        import org.mule.api.lifecycle.InitialisationException;
015:        import org.mule.api.lifecycle.LifecycleTransitionResult;
016:        import org.mule.config.i18n.CoreMessages;
017:        import org.mule.util.IOUtils;
018:
019:        import java.io.InputStream;
020:        import java.security.Principal;
021:        import java.util.Enumeration;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:
025:        import cryptix.pki.ExtendedKeyStore;
026:        import cryptix.pki.KeyBundle;
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:
030:        public class PGPKeyRingImpl implements  PGPKeyRing, Initialisable {
031:            protected static final Log logger = LogFactory
032:                    .getLog(PGPKeyRingImpl.class);
033:
034:            private String publicKeyRingFileName;
035:
036:            private HashMap principalsKeyBundleMap;
037:
038:            private String secretKeyRingFileName;
039:
040:            private String secretAliasId;
041:
042:            private KeyBundle secretKeyBundle;
043:
044:            private String secretPassphrase;
045:
046:            public PGPKeyRingImpl() {
047:                super ();
048:            }
049:
050:            public String getSecretKeyRingFileName() {
051:                return secretKeyRingFileName;
052:            }
053:
054:            public void setSecretKeyRingFileName(String value) {
055:                this .secretKeyRingFileName = value;
056:            }
057:
058:            public String getSecretAliasId() {
059:                return secretAliasId;
060:            }
061:
062:            public void setSecretAliasId(String value) {
063:                this .secretAliasId = value;
064:            }
065:
066:            public String getSecretPassphrase() {
067:                return secretPassphrase;
068:            }
069:
070:            public void setSecretPassphrase(String value) {
071:                this .secretPassphrase = value;
072:            }
073:
074:            private void readPrivateKeyBundle() throws Exception {
075:                InputStream in = IOUtils.getResourceAsStream(
076:                        secretKeyRingFileName, getClass());
077:
078:                ExtendedKeyStore ring = (ExtendedKeyStore) ExtendedKeyStore
079:                        .getInstance("OpenPGP/KeyRing");
080:                ring.load(in, null);
081:
082:                in.close();
083:
084:                secretKeyBundle = ring.getKeyBundle(secretAliasId);
085:            }
086:
087:            public KeyBundle getSecretKeyBundle() {
088:                return secretKeyBundle;
089:            }
090:
091:            /** @return  */
092:            public String getPublicKeyRingFileName() {
093:                return publicKeyRingFileName;
094:            }
095:
096:            /** @param value  */
097:            public void setPublicKeyRingFileName(String value) {
098:                this .publicKeyRingFileName = value;
099:            }
100:
101:            public KeyBundle getKeyBundle(String principalId) {
102:                return (KeyBundle) principalsKeyBundleMap.get(principalId);
103:            }
104:
105:            public LifecycleTransitionResult initialise()
106:                    throws InitialisationException {
107:                try {
108:                    java.security.Security
109:                            .addProvider(new cryptix.jce.provider.CryptixCrypto());
110:                    java.security.Security
111:                            .addProvider(new cryptix.openpgp.provider.CryptixOpenPGP());
112:
113:                    principalsKeyBundleMap = new HashMap();
114:
115:                    readPublicKeyRing();
116:                    readPrivateKeyBundle();
117:                } catch (Exception e) {
118:                    logger.error(
119:                            "errore in inizializzazione:" + e.getMessage(), e);
120:                    throw new InitialisationException(CoreMessages
121:                            .failedToCreate("PGPKeyRingImpl"), e, this );
122:                }
123:                return LifecycleTransitionResult.OK;
124:            }
125:
126:            private void readPublicKeyRing() throws Exception {
127:                logger.debug(System.getProperties().get("user.dir"));
128:                InputStream in = IOUtils.getResourceAsStream(
129:                        publicKeyRingFileName, getClass());
130:
131:                ExtendedKeyStore ring = (ExtendedKeyStore) ExtendedKeyStore
132:                        .getInstance("OpenPGP/KeyRing");
133:                ring.load(in, null);
134:                in.close();
135:
136:                for (Enumeration e = ring.aliases(); e.hasMoreElements();) {
137:                    String aliasId = (String) e.nextElement();
138:
139:                    KeyBundle bundle = ring.getKeyBundle(aliasId);
140:
141:                    if (bundle != null) {
142:                        for (Iterator users = bundle.getPrincipals(); users
143:                                .hasNext();) {
144:                            Principal princ = (Principal) users.next();
145:
146:                            principalsKeyBundleMap.put(princ.getName(), bundle);
147:                        }
148:                    }
149:                }
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.