Source Code Cross Referenced for EncryptedValue.java in  » Authentication-Authorization » ejbca » com » novosec » pkix » asn1 » crmf » 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 » Authentication Authorization » ejbca » com.novosec.pkix.asn1.crmf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // CMP implementation copyright (c) 2003 NOVOSEC AG (http://www.novosec.com)
002:        //
003:        // Author: Maik Stohn
004:        //
005:        // Permission is hereby granted, free of charge, to any person obtaining a copy of this 
006:        // software and associated documentation files (the "Software"), to deal in the Software 
007:        // without restriction, including without limitation the rights to use, copy, modify, merge, 
008:        // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 
009:        // to whom the Software is furnished to do so, subject to the following conditions: 
010:        //
011:        // The above copyright notice and this permission notice shall be included in all copies or 
012:        // substantial portions of the Software. 
013:        //
014:        // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
015:        // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
016:        // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
017:        // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
018:        // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
019:
020:        package com.novosec.pkix.asn1.crmf;
021:
022:        import java.util.Enumeration;
023:
024:        import org.bouncycastle.asn1.ASN1EncodableVector;
025:        import org.bouncycastle.asn1.ASN1Sequence;
026:        import org.bouncycastle.asn1.ASN1TaggedObject;
027:        import org.bouncycastle.asn1.DERBitString;
028:        import org.bouncycastle.asn1.DEREncodable;
029:        import org.bouncycastle.asn1.DERObject;
030:        import org.bouncycastle.asn1.DEROctetString;
031:        import org.bouncycastle.asn1.DERSequence;
032:        import org.bouncycastle.asn1.DERTaggedObject;
033:        import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
034:
035:        /**
036:         * ASN.1 structure DER En/DeCoder.
037:         *
038:         * <pre>
039:         *   EncryptedValue ::= SEQUENCE {
040:         *     intendedAlg   [0] AlgorithmIdentifier  OPTIONAL, -- the intended algorithm for which the value will be used
041:         *     symmAlg       [1] AlgorithmIdentifier  OPTIONAL, -- the symmetric algorithm used to encrypt the value
042:         *     encSymmKey    [2] BIT STRING           OPTIONAL, -- the (encrypted) symmetric key used to encrypt the value
043:         *     keyAlg        [3] AlgorithmIdentifier  OPTIONAL, -- algorithm used to encrypt the symmetric key
044:         *     valueHint     [4] OCTET STRING         OPTIONAL, -- a brief description or identifier of the encValue content (may be meaningful only to the sending entity, and used only if EncryptedValue might be re-examined by the sending entity in the future)
045:         *     encValue       BIT STRING }                      -- the encrypted value itself
046:         *
047:         * </pre>
048:         */
049:
050:        public class EncryptedValue implements  DEREncodable {
051:            AlgorithmIdentifier intendedAlg;
052:            AlgorithmIdentifier symmAlg;
053:            DERBitString encSymmKey;
054:            AlgorithmIdentifier keyAlg;
055:            DEROctetString valueHint;
056:            DERBitString encValue;
057:
058:            public static EncryptedValue getInstance(ASN1TaggedObject obj,
059:                    boolean explicit) {
060:                return getInstance(ASN1Sequence.getInstance(obj, explicit));
061:            }
062:
063:            public static EncryptedValue getInstance(Object obj) {
064:                if (obj instanceof  EncryptedValue) {
065:                    return (EncryptedValue) obj;
066:                } else if (obj instanceof  ASN1Sequence) {
067:                    return new EncryptedValue((ASN1Sequence) obj);
068:                }
069:
070:                throw new IllegalArgumentException("unknown object in factory");
071:            }
072:
073:            public EncryptedValue(ASN1Sequence seq) {
074:                Enumeration e = seq.getObjects();
075:                while (e.hasMoreElements()) {
076:                    Object obj = e.nextElement();
077:
078:                    if (obj instanceof  DERTaggedObject) {
079:                        DERTaggedObject tagObj = (DERTaggedObject) obj;
080:
081:                        switch (tagObj.getTagNo()) {
082:                        case 0:
083:                            this .intendedAlg = AlgorithmIdentifier
084:                                    .getInstance(tagObj.getObject());
085:                            break;
086:                        case 1:
087:                            this .symmAlg = AlgorithmIdentifier
088:                                    .getInstance(tagObj.getObject());
089:                            break;
090:                        case 2:
091:                            this .encSymmKey = DERBitString.getInstance(tagObj
092:                                    .getObject());
093:                            break;
094:                        case 3:
095:                            this .keyAlg = AlgorithmIdentifier
096:                                    .getInstance(tagObj.getObject());
097:                            break;
098:                        case 4:
099:                            this .valueHint = (DEROctetString) DEROctetString
100:                                    .getInstance(tagObj.getObject());
101:                            break;
102:                        }
103:                    } else {
104:                        encValue = DERBitString.getInstance(obj);
105:                        break;
106:                    }
107:                }
108:            }
109:
110:            public EncryptedValue(DERBitString encValue) {
111:                this .encValue = encValue;
112:            }
113:
114:            public AlgorithmIdentifier getIntendedAlg() {
115:                return intendedAlg;
116:            }
117:
118:            public void setIntendedAlg(AlgorithmIdentifier intendedAlg) {
119:                this .intendedAlg = intendedAlg;
120:            }
121:
122:            public AlgorithmIdentifier getSymmAlg() {
123:                return symmAlg;
124:            }
125:
126:            public void setSymmAlg(AlgorithmIdentifier symmAlg) {
127:                this .symmAlg = symmAlg;
128:            }
129:
130:            public DERBitString getEncSymmKey() {
131:                return encSymmKey;
132:            }
133:
134:            public void setEncSymmKey(DERBitString encSymmKey) {
135:                this .encSymmKey = encSymmKey;
136:            }
137:
138:            public AlgorithmIdentifier getKeyAlg() {
139:                return keyAlg;
140:            }
141:
142:            public void setKeyAlg(AlgorithmIdentifier keyAlg) {
143:                this .keyAlg = keyAlg;
144:            }
145:
146:            public DEROctetString getValueHint() {
147:                return valueHint;
148:            }
149:
150:            public void setValueHint(DEROctetString valueHint) {
151:                this .valueHint = valueHint;
152:            }
153:
154:            public DERBitString getEncValue() {
155:                return encValue;
156:            }
157:
158:            public DERObject getDERObject() {
159:                ASN1EncodableVector v = new ASN1EncodableVector();
160:
161:                if (intendedAlg != null)
162:                    v.add(new DERTaggedObject(false, 0, intendedAlg));
163:                if (symmAlg != null)
164:                    v.add(new DERTaggedObject(false, 1, symmAlg));
165:                if (encSymmKey != null)
166:                    v.add(new DERTaggedObject(false, 2, encSymmKey));
167:                if (keyAlg != null)
168:                    v.add(new DERTaggedObject(false, 3, keyAlg));
169:                if (valueHint != null)
170:                    v.add(new DERTaggedObject(false, 4, valueHint));
171:
172:                v.add(encValue);
173:
174:                return new DERSequence(v);
175:            }
176:
177:            public String toString() {
178:                String s = "EncryptedValue: (";
179:
180:                if (this .getIntendedAlg() != null)
181:                    s += "intendedAlg: " + this .getIntendedAlg() + ", ";
182:
183:                if (this .getSymmAlg() != null)
184:                    s += "symmAlg: " + this .getSymmAlg() + ", ";
185:
186:                if (this .getEncSymmKey() != null)
187:                    s += "encSymmKey: " + this .getEncSymmKey() + ", ";
188:
189:                if (this .getKeyAlg() != null)
190:                    s += "keyAlg: " + this .getKeyAlg() + ", ";
191:
192:                if (this .getValueHint() != null)
193:                    s += "valueHint: " + this .getValueHint() + ", ";
194:
195:                s += "encValue: " + this .getEncValue() + ")";
196:
197:                return s;
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.