Source Code Cross Referenced for IssuerName.java in  » Web-Mail » oyster » org » enhydra » oyster » cms » 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 » Web Mail » oyster » org.enhydra.oyster.cms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Title:        Oyster Project
003:         * Description:  S/MIME email sending capabilities
004:         * @Author       Vladimir Radisic
005:         * @Version      2.1.6
006:         */
007:
008:        package org.enhydra.oyster.cms;
009:
010:        import org.enhydra.oyster.exception.SMIMEException;
011:        import org.enhydra.oyster.exception.ErrorStorage;
012:        import org.enhydra.oyster.der.DERSequencePr;
013:        import org.enhydra.oyster.der.DERObjectIdentifier;
014:        import org.enhydra.oyster.util.DERLengthSearcher;
015:        import org.enhydra.oyster.util.ByteArrayComparator;
016:        import java.security.cert.X509Certificate;
017:
018:        /**
019:         * IssuerName class is DER encoded object represented in ASN.1 notation
020:         * according to RFC2630. It is used for representing information about issuer
021:         * of particular certificates. Detail information about ASN.1 notation of
022:         * this class can be found in description of ASN.1 notation of IssuerAndSerialNumber.
023:         */
024:        public class IssuerName extends DERSequencePr {
025:
026:            /**
027:             * Container for DN (set of distinguished names)
028:             */
029:            private byte[] dNames;
030:
031:            /**
032:             * Enables/Disables function for particular adding of Relative Distinguished Name
033:             */
034:            private int enable = 0;
035:
036:            /**
037:             * Construction with information got from specific X509Certificate or from .cer
038:             * file information which is extracted into instance of X509Certificate class
039:             * @param cert0 X509Certificate
040:             * @exception SMIMEException caused by non SMIMEException which is:
041:             * CertificateEncodingException. Also, it can be thrown by super class
042:             * constructor.
043:             */
044:            public IssuerName(X509Certificate cert0) throws SMIMEException {
045:                byte[] tbs = null;
046:                try {
047:                    tbs = cert0.getTBSCertificate();
048:                } catch (Exception e) {
049:                    throw new SMIMEException(e);
050:                }
051:                dNames = findDNfromTBS(tbs);
052:            }
053:
054:            /**
055:             * Finds area with Distinguish Names from TBS Certificate part of X509
056:             * certificate, represented as byte array
057:             * @param tbs0 TBS Certificate represented as byte array
058:             * @return Distinguish name as byte array
059:             */
060:            private byte[] findDNfromTBS(byte[] tbs0) {
061:                int start = 0; // first SEQUENCE tag in TBSCertificate
062:                byte[] temp;
063:                DERLengthSearcher len = new DERLengthSearcher(start, tbs0);
064:                start = start + len.getLengthtDERLengthPart() + 1; // [0]
065:                len.newInitialization(start, tbs0);
066:                start = start + len.getLengthtDERLengthPart()
067:                        + len.getLengthtDERContentPart() + 1; // CertificateSerialNumber
068:                len.newInitialization(start, tbs0);
069:                start = start + len.getLengthtDERLengthPart()
070:                        + len.getLengthtDERContentPart() + 1; // Algorythm identifier - SEQUENCE
071:                len.newInitialization(start, tbs0);
072:                start = start + len.getLengthtDERLengthPart()
073:                        + len.getLengthtDERContentPart() + 1; // Issuer Name - SEQUENCE
074:                len.newInitialization(start, tbs0);
075:                start = start + len.getLengthtDERLengthPart() + 1;
076:                int stop = start + len.getLengthtDERContentPart() - 1;
077:                temp = new byte[stop - start + 1];
078:                for (int i = start; i <= stop; i++)
079:                    temp[i - start] = tbs0[i];
080:                return temp;
081:            }
082:
083:            /**
084:             * Adds all Relative Distinguish Names from certificate to IssuerName
085:             * @exception SMIMEException thrown from super class addContent method.
086:             */
087:            public void addAllRelativeDN() throws SMIMEException {
088:                super .addContent(dNames);
089:                enable = 1;
090:            }
091:
092:            /**
093:             * Adds particular Relative Distinguish Name from certificate to IssuerName.
094:             * This method can be called many times, but never if method
095:             * addAllRelativeDN was called first
096:             * @param id_at_type0 object identifier name of desired Particular Distinguish
097:             * Name
098:             * @return Desired Particular Distinguish Name as byte array
099:             * @exception SMIMEException if method addAllRelativeDN was already performed.
100:             * Also it can be caused by non SMIMEException which is:
101:             * UnsupportedEncodingException.
102:             */
103:            public int addParticularRelativeDN(String id_at_type0)
104:                    throws SMIMEException {
105:                if (enable == 1)
106:                    throw new SMIMEException(1021);
107:                byte[] temp = new DERObjectIdentifier(id_at_type0,
108:                        "NAME_STRING").getDEREncoded();
109:                ByteArrayComparator bcomp = new ByteArrayComparator(temp,
110:                        dNames);
111:                int positionFirst = bcomp.getMatchingIndex();
112:                if (positionFirst != -1) // Matching is founded
113:                {
114:                    positionFirst = positionFirst + temp.length;
115:                    DERLengthSearcher len = new DERLengthSearcher(
116:                            positionFirst, dNames);
117:                    positionFirst = positionFirst
118:                            + len.getLengthtDERLengthPart() + 1;
119:                    int positionLast = positionFirst
120:                            + len.getLengthtDERContentPart() - 1;
121:                    byte[] name = new byte[positionLast - positionFirst + 1];
122:                    for (int i = positionFirst; i <= positionLast; i++)
123:                        // Finding a text of particular distinguish name
124:                        name[i - positionFirst] = dNames[i];
125:                    RelativeDistinguishedName rdn = null;
126:                    try {
127:                        rdn = new RelativeDistinguishedName(id_at_type0,
128:                                "NAME_STRING", new String(name, "ISO-8859-1"));
129:                    } catch (Exception e) {
130:                        throw new SMIMEException(e);
131:                    }
132:                    super .addContent(rdn.getDEREncoded());
133:                    return 0; // success of operation
134:                } else
135:                    return -1; // failure of operation
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.