Source Code Cross Referenced for Target.java in  » Security » Bouncy-Castle » org » bouncycastle » asn1 » x509 » 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 » Security » Bouncy Castle » org.bouncycastle.asn1.x509 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.asn1.x509;
002:
003:        import org.bouncycastle.asn1.ASN1Choice;
004:        import org.bouncycastle.asn1.ASN1Encodable;
005:        import org.bouncycastle.asn1.ASN1TaggedObject;
006:        import org.bouncycastle.asn1.DERObject;
007:        import org.bouncycastle.asn1.DERTaggedObject;
008:
009:        /**
010:         * Target structure used in target information extension for attribute
011:         * certificates from RFC 3281.
012:         * 
013:         * <pre>
014:         *     Target  ::= CHOICE {
015:         *       targetName          [0] GeneralName,
016:         *       targetGroup         [1] GeneralName,
017:         *       targetCert          [2] TargetCert
018:         *     }
019:         * </pre>
020:         * 
021:         * <p>
022:         * The targetCert field is currently not supported and must not be used
023:         * according to RFC 3281.
024:         */
025:        public class Target extends ASN1Encodable implements  ASN1Choice {
026:            public static final int targetName = 0;
027:            public static final int targetGroup = 1;
028:
029:            private GeneralName targName;
030:            private GeneralName targGroup;
031:
032:            /**
033:             * Creates an instance of a Target from the given object.
034:             * <p>
035:             * <code>obj</code> can be a Target or a {@link ASN1TaggedObject}
036:             * 
037:             * @param obj The object.
038:             * @return A Target instance.
039:             * @throws IllegalArgumentException if the given object cannot be
040:             *             interpreted as Target.
041:             */
042:            public static Target getInstance(Object obj) {
043:                if (obj instanceof  Target) {
044:                    return (Target) obj;
045:                } else if (obj instanceof  ASN1TaggedObject) {
046:                    return new Target((ASN1TaggedObject) obj);
047:                }
048:
049:                throw new IllegalArgumentException(
050:                        "unknown object in factory: " + obj.getClass());
051:            }
052:
053:            /**
054:             * Constructor from ASN1TaggedObject.
055:             * 
056:             * @param tagObj The tagged object.
057:             * @throws IllegalArgumentException if the encoding is wrong.
058:             */
059:            private Target(ASN1TaggedObject tagObj) {
060:                switch (tagObj.getTagNo()) {
061:                case targetName: // GeneralName is already a choice so explicit
062:                    targName = GeneralName.getInstance(tagObj, true);
063:                    break;
064:                case targetGroup:
065:                    targGroup = GeneralName.getInstance(tagObj, true);
066:                    break;
067:                default:
068:                    throw new IllegalArgumentException("unknown tag: "
069:                            + tagObj.getTagNo());
070:                }
071:            }
072:
073:            /**
074:             * Constructor from given details.
075:             * <p>
076:             * Exactly one of the parameters must be not <code>null</code>.
077:             *
078:             * @param type the choice type to apply to the name.
079:             * @param name the general name.
080:             * @throws IllegalArgumentException if type is invalid.
081:             */
082:            public Target(int type, GeneralName name) {
083:                this (new DERTaggedObject(type, name));
084:            }
085:
086:            /**
087:             * @return Returns the targetGroup.
088:             */
089:            public GeneralName getTargetGroup() {
090:                return targGroup;
091:            }
092:
093:            /**
094:             * @return Returns the targetName.
095:             */
096:            public GeneralName getTargetName() {
097:                return targName;
098:            }
099:
100:            /**
101:             * Produce an object suitable for an ASN1OutputStream.
102:             * 
103:             * Returns:
104:             * 
105:             * <pre>
106:             *     Target  ::= CHOICE {
107:             *       targetName          [0] GeneralName,
108:             *       targetGroup         [1] GeneralName,
109:             *       targetCert          [2] TargetCert
110:             *     }
111:             * </pre>
112:             * 
113:             * @return a DERObject
114:             */
115:            public DERObject toASN1Object() {
116:                // GeneralName is a choice already so most be explicitly tagged
117:                if (targName != null) {
118:                    return new DERTaggedObject(true, 0, targName);
119:                } else {
120:                    return new DERTaggedObject(true, 1, targGroup);
121:                }
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.