You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pl...@apache.org on 2015/11/27 09:18:21 UTC

[11/17] directory-kerby git commit: DIRKRB-473. Initially added X509 ASN1 types

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectDirectoryAttributes.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectDirectoryAttributes.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectDirectoryAttributes.java
new file mode 100644
index 0000000..9ad8ff8
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectDirectoryAttributes.java
@@ -0,0 +1,39 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+/**
+ * Ref. RFC 3039
+ * <pre>
+ *     SubjectDirectoryAttributes ::= Attributes
+ *     Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
+ *     Attribute ::= SEQUENCE {
+ *       type AttributeType 
+ *       values SET OF AttributeValue 
+ *     }
+ *     
+ *     AttributeType ::= OBJECT IDENTIFIER
+ *     AttributeValue ::= ANY DEFINED BY AttributeType
+ * </pre>
+ *
+ */
+public class SubjectDirectoryAttributes extends Attributes {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectKeyIdentifier.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectKeyIdentifier.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectKeyIdentifier.java
new file mode 100644
index 0000000..e70882d
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectKeyIdentifier.java
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1OctetString;
+
+/**
+ *
+ * <pre>
+ *   SubjectKeyIdentifier::= OCTET STRING
+ * </pre>
+ */
+public class SubjectKeyIdentifier extends Asn1OctetString {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectPublicKeyInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectPublicKeyInfo.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectPublicKeyInfo.java
new file mode 100644
index 0000000..d904e63
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/SubjectPublicKeyInfo.java
@@ -0,0 +1,60 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1BitString;
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+
+/**
+ * SubjectPublicKeyInfo  ::=  SEQUENCE  {
+ *    algorithm            AlgorithmIdentifier,
+ *    subjectPublicKey     BIT STRING
+ * }
+ */
+public class SubjectPublicKeyInfo extends Asn1SequenceType {
+    private static final int ALGORITHM = 0;
+    private static final int SUBJECT_PUBLIC_KEY = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new Asn1FieldInfo(ALGORITHM, AlgorithmIdentifier.class),
+            new Asn1FieldInfo(SUBJECT_PUBLIC_KEY, Asn1BitString.class)
+    };
+
+    public SubjectPublicKeyInfo() {
+        super(fieldInfos);
+    }
+
+    public AlgorithmIdentifier getAlgorithm() {
+        return getFieldAs(ALGORITHM, AlgorithmIdentifier.class);
+    }
+
+    public void setAlgorithm(AlgorithmIdentifier algorithm) {
+        setFieldAs(ALGORITHM, algorithm);
+    }
+
+    public byte[] getSubjectPubKey() {
+        return getFieldAsOctets(SUBJECT_PUBLIC_KEY);
+    }
+
+    public void setSubjectPubKey(byte[] subjectPubKey) {
+        setFieldAs(SUBJECT_PUBLIC_KEY, new Asn1BitString(subjectPubKey));
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertList.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertList.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertList.java
new file mode 100644
index 0000000..64f1b90
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertList.java
@@ -0,0 +1,128 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+import org.apache.kerby.asn1.type.ExplicitField;
+import org.apache.kerby.x500.type.Name;
+
+/**
+ * Ref. RFC-2459
+ * <pre>
+ * TBSCertList  ::=  SEQUENCE  {
+ *      version                 Version OPTIONAL,
+ *                                   -- if present, shall be v2
+ *      signature               AlgorithmIdentifier,
+ *      issuer                  Name,
+ *      thisUpdate              Time,
+ *      nextUpdate              Time OPTIONAL,
+ *      revokedCertificates     SEQUENCE OF SEQUENCE  {
+ *           userCertificate         CertificateSerialNumber,
+ *           revocationDate          Time,
+ *           crlEntryExtensions      Extensions OPTIONAL
+ *                                         -- if present, shall be v2
+ *                                }  OPTIONAL,
+ *      crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
+ *                                         -- if present, shall be v2
+ *                                }
+ * </pre>
+ */
+public class TBSCertList extends Asn1SequenceType {
+
+    private static final int VERSION = 0;
+    private static final int SIGNATURE = 1;
+    private static final int ISSUER = 2;
+    private static final int THIS_UPDATA = 3;
+    private static final int NEXT_UPDATE = 4;
+    private static final int REVOKED_CERTIFICATES = 5;
+    private static final int CRL_EXTENSIONS = 6;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+        new Asn1FieldInfo(VERSION, Asn1Integer.class),
+        new Asn1FieldInfo(SIGNATURE, AlgorithmIdentifier.class),
+        new Asn1FieldInfo(ISSUER, Name.class),
+        new Asn1FieldInfo(THIS_UPDATA, Time.class),
+        new Asn1FieldInfo(NEXT_UPDATE, Time.class),
+        new Asn1FieldInfo(REVOKED_CERTIFICATES, RevokedCertificates.class),
+        new ExplicitField(CRL_EXTENSIONS, 0, Extensions.class)
+    };
+
+    public TBSCertList() {
+        super(fieldInfos);
+    }
+
+    public Asn1Integer getVersion() {
+        return getFieldAs(VERSION, Asn1Integer.class);
+    }
+
+    public void setVersion(Asn1Integer version) {
+        setFieldAs(VERSION, version);
+    }
+
+    public AlgorithmIdentifier getSignature() {
+        return getFieldAs(SIGNATURE, AlgorithmIdentifier.class);
+    }
+
+    public void setSignature(AlgorithmIdentifier signature) {
+        setFieldAs(SIGNATURE, signature);
+    }
+
+    public Name getIssuer() {
+        return getFieldAs(ISSUER, Name.class);
+    }
+
+    public void setIssuer(Name issuer) {
+        setFieldAs(ISSUER, issuer);
+    }
+
+    public Time getThisUpdate() {
+        return getFieldAs(THIS_UPDATA, Time.class);
+    }
+
+    public void setThisUpdata(Time thisUpdata) {
+        setFieldAs(THIS_UPDATA, thisUpdata);
+    }
+
+    public Time getNextUpdate() {
+        return getFieldAs(NEXT_UPDATE, Time.class);
+    }
+
+    public void setNextUpdate(Time nextUpdate) {
+        setFieldAs(NEXT_UPDATE, nextUpdate);
+    }
+
+    public RevokedCertificates getRevokedCertificates() {
+        return getFieldAs(REVOKED_CERTIFICATES, RevokedCertificates.class);
+    }
+
+    public void setRevokedCertificates(RevokedCertificates revokedCertificates) {
+        setFieldAs(REVOKED_CERTIFICATES, revokedCertificates);
+    }
+
+    public Extensions getCrlExtensions() {
+        return getFieldAs(CRL_EXTENSIONS, Extensions.class);
+    }
+
+    public void setCrlExtensions(Extensions crlExtensions) {
+        setFieldAs(CRL_EXTENSIONS, crlExtensions);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertificate.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertificate.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertificate.java
new file mode 100644
index 0000000..23042c0
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TBSCertificate.java
@@ -0,0 +1,155 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1BitString;
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+import org.apache.kerby.asn1.type.ExplicitField;
+import org.apache.kerby.asn1.type.ImplicitField;
+import org.apache.kerby.x500.type.Name;
+
+/**
+ * <pre>
+ * TBSCertificate ::= SEQUENCE {
+ *      version          [ 0 ]  Version DEFAULT v1(0),
+ *      serialNumber            CertificateSerialNumber,
+ *      signature               AlgorithmIdentifier,
+ *      issuer                  Name,
+ *      validity                Validity,
+ *      subject                 Name,
+ *      subjectPublicKeyInfo    SubjectPublicKeyInfo,
+ *      issuerUniqueID    [ 1 ] IMPLICIT UniqueIdentifier OPTIONAL,
+ *      subjectUniqueID   [ 2 ] IMPLICIT UniqueIdentifier OPTIONAL,
+ *      extensions        [ 3 ] Extensions OPTIONAL
+ *  }
+ * </pre>
+ */
+public class TBSCertificate extends Asn1SequenceType {
+
+    private static final int VERSION = 0;
+    private static final int SERIAL_NUMBER = 1;
+    private static final int SIGNATURE = 2;
+    private static final int ISSUER = 3;
+    private static final int VALIDITY = 4;
+    private static final int SUBJECT = 5;
+    private static final int SUBJECT_PUBLIC_KEY_INFO = 6;
+    private static final int ISSUER_UNIQUE_ID = 7;
+    private static final int SUBJECT_UNIQUE_ID = 8;
+    private static final int EXTENSIONS = 9;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(VERSION, 0, Asn1Integer.class),
+            new Asn1FieldInfo(SERIAL_NUMBER, CertificateSerialNumber.class),
+            new Asn1FieldInfo(SIGNATURE, AlgorithmIdentifier.class),
+            new Asn1FieldInfo(ISSUER, Name.class),
+            new Asn1FieldInfo(VALIDITY, AttCertValidityPeriod.class),
+            new Asn1FieldInfo(SUBJECT, Name.class),
+            new Asn1FieldInfo(SUBJECT_PUBLIC_KEY_INFO, SubjectPublicKeyInfo.class),
+            new ImplicitField(ISSUER_UNIQUE_ID, 1, Asn1BitString.class),
+            new ImplicitField(SUBJECT_UNIQUE_ID, 2, Asn1BitString.class),
+            new ExplicitField(EXTENSIONS, 3, Extensions.class)
+    };
+
+    public TBSCertificate() {
+        super(fieldInfos);
+    }
+
+    public int getVersion() {
+        return getFieldAsInteger(VERSION);
+    }
+
+    public void setVersion(int version) {
+        setFieldAsInt(VERSION, version);
+    }
+
+    public CertificateSerialNumber getSerialNumber() {
+        return getFieldAs(SERIAL_NUMBER, CertificateSerialNumber.class);
+    }
+
+    public void setSerialNumber(CertificateSerialNumber certificateSerialNumber) {
+        setFieldAs(SERIAL_NUMBER, certificateSerialNumber);
+    }
+
+    public AlgorithmIdentifier getSignature() {
+        return getFieldAs(SIGNATURE, AlgorithmIdentifier.class);
+    }
+
+    public void setSignature(AlgorithmIdentifier signature) {
+        setFieldAs(SIGNATURE, signature);
+    }
+
+    public Name getIssuer() {
+        return getFieldAs(ISSUER, Name.class);
+    }
+
+    public void setIssuer(Name attCertIssuer) {
+        setFieldAs(ISSUER, attCertIssuer);
+    }
+
+    public AttCertValidityPeriod getValidity() {
+        return getFieldAs(VALIDITY, AttCertValidityPeriod.class);
+    }
+
+    public void setValidity(AttCertValidityPeriod validity) {
+        setFieldAs(VALIDITY, validity);
+    }
+
+    public Name getSubject() {
+        return getFieldAs(SUBJECT, Name.class);
+    }
+
+    public void setSubject(Name subject) {
+        setFieldAs(SUBJECT, subject);
+    }
+
+    public SubjectPublicKeyInfo getSubjectPublicKeyInfo() {
+        return getFieldAs(SUBJECT_PUBLIC_KEY_INFO, SubjectPublicKeyInfo.class);
+    }
+
+    public void setSubjectPublicKeyInfo(SubjectPublicKeyInfo subjectPublicKeyInfo) {
+        setFieldAs(SUBJECT_PUBLIC_KEY_INFO, subjectPublicKeyInfo);
+    }
+
+    public byte[] getIssuerUniqueID() {
+        return getFieldAs(ISSUER_UNIQUE_ID, Asn1BitString.class).getValue();
+    }
+
+    public void setIssuerUniqueId(byte[] issuerUniqueId) {
+        setFieldAs(ISSUER_UNIQUE_ID, new Asn1BitString(issuerUniqueId));
+    }
+
+    public byte[] getSubjectUniqueId() {
+        return getFieldAs(ISSUER_UNIQUE_ID, Asn1BitString.class).getValue();
+    }
+
+    public void setSubjectUniqueId(byte[] issuerUniqueId) {
+        setFieldAs(ISSUER_UNIQUE_ID, new Asn1BitString(issuerUniqueId));
+    }
+
+    public Extensions getExtensions() {
+        return getFieldAs(EXTENSIONS, Extensions.class);
+    }
+
+    public void setExtensions(Extensions extensions) {
+        setFieldAs(EXTENSIONS, extensions);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Target.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Target.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Target.java
new file mode 100644
index 0000000..8ef6c5e
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Target.java
@@ -0,0 +1,74 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1Choice;
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.ExplicitField;
+
+/**
+ * Ref. RFC 3281
+ * <pre>
+ *     Target  ::= CHOICE {
+ *       targetName          [0] GeneralName,
+ *       targetGroup         [1] GeneralName,
+ *       targetCert          [2] TargetCert
+ *     }
+ * </pre>
+ */
+public class Target extends Asn1Choice {
+    private static final int TARGET_NAME = 0;
+    private static final int TARGET_GROUP = 1;
+    private static final int TARGET_CERT = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+        new ExplicitField(TARGET_NAME, GeneralName.class),
+        new ExplicitField(TARGET_GROUP, GeneralName.class),
+        new ExplicitField(TARGET_CERT, TargetCert.class),
+    };
+
+    public Target() {
+        super(fieldInfos);
+    }
+
+    public GeneralName getTargetName() {
+        return getFieldAs(TARGET_NAME, GeneralName.class);
+    }
+
+    public void setTargetName(GeneralName targetName) {
+        setFieldAs(TARGET_NAME, targetName);
+    }
+
+    public GeneralName getTargetGroup() {
+        return getFieldAs(TARGET_GROUP, GeneralName.class);
+    }
+
+    public void setTargetGroup(GeneralName targetGroup) {
+        setFieldAs(TARGET_GROUP, targetGroup);
+    }
+
+    public TargetCert targetCert() {
+        return getFieldAs(TARGET_CERT, TargetCert.class);
+    }
+
+    public void setTargetCert(TargetCert targetCert) {
+        setFieldAs(TARGET_CERT, targetCert);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetCert.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetCert.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetCert.java
new file mode 100644
index 0000000..b79fe3f
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetCert.java
@@ -0,0 +1,70 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+
+/**
+ * TargetCert  ::= SEQUENCE {
+ *   targetCertificate    IssuerSerial,
+ *   targetName           GeneralName OPTIONAL,
+ *   certDigestInfo       ObjectDigestInfo OPTIONAL
+ * }
+ */
+public class TargetCert extends Asn1SequenceType{
+    private static final int TARGET_CERTIFICATE = 0;
+    private static final int TARGET_NAME = 1;
+    private static final int CERT_DIGEST_INFO = 2;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new Asn1FieldInfo(TARGET_CERTIFICATE, IssuerSerial.class),
+            new Asn1FieldInfo(TARGET_NAME, GeneralName.class),
+            new Asn1FieldInfo(CERT_DIGEST_INFO, ObjectDigestInfo.class)
+    };
+
+    public TargetCert() {
+        super(fieldInfos);
+    }
+
+    public IssuerSerial getTargetCertificate() {
+        return getFieldAs(TARGET_CERTIFICATE, IssuerSerial.class);
+    }
+
+    public void setTargetCertificate(IssuerSerial targetCertificate) {
+        setFieldAs(TARGET_CERTIFICATE, targetCertificate);
+    }
+
+    public GeneralName getTargetName() {
+        return getFieldAs(TARGET_NAME, GeneralName.class);
+    }
+
+    public void setTargetName(GeneralName targetName) {
+        setFieldAs(TARGET_NAME, targetName);
+    }
+
+    public ObjectDigestInfo getCertDigestInfo() {
+        return getFieldAs(CERT_DIGEST_INFO, ObjectDigestInfo.class);
+    }
+
+    public void setCerttDigestInfo(ObjectDigestInfo certDigestInfo) {
+        setFieldAs(CERT_DIGEST_INFO, certDigestInfo);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetInformation.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetInformation.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetInformation.java
new file mode 100644
index 0000000..8c17c3b
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/TargetInformation.java
@@ -0,0 +1,34 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1SequenceOf;
+
+/**
+ * Ref. RFC 3281
+ * 
+ * <pre>
+ *  TargetInformation ::= SEQUENCE OF Targets
+ * </pre>
+ * 
+ */
+public class TargetInformation extends Asn1SequenceOf<Target> {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Targets.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Targets.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Targets.java
new file mode 100644
index 0000000..77b6adc
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Targets.java
@@ -0,0 +1,45 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1SequenceOf;
+
+/**
+ * Ref. RFC 3281
+ * 
+ * <pre>
+ *            Targets ::= SEQUENCE OF Target
+ *           
+ *            Target  ::= CHOICE {
+ *              targetName          [0] GeneralName,
+ *              targetGroup         [1] GeneralName,
+ *              targetCert          [2] TargetCert
+ *            }
+ *           
+ *            TargetCert  ::= SEQUENCE {
+ *              targetCertificate    IssuerSerial,
+ *              targetName           GeneralName OPTIONAL,
+ *              certDigestInfo       ObjectDigestInfo OPTIONAL
+ *            }
+ * </pre>
+ */
+public class Targets extends Asn1SequenceOf<Target> {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Time.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Time.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Time.java
new file mode 100644
index 0000000..fb3280d
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/Time.java
@@ -0,0 +1,66 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1Choice;
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1GeneralizedTime;
+import org.apache.kerby.asn1.type.Asn1UtcTime;
+
+import java.util.Date;
+
+/**
+ *
+ * <pre>
+ * Time ::= CHOICE {
+ *             utcTime        UTCTime,
+ *             generalTime    GeneralizedTime
+ *          }
+ * </pre>
+ */
+public class Time extends Asn1Choice {
+    private static final int UTC_TIME = 0;
+    private static final int GENERAL_TIME = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+        new Asn1FieldInfo(UTC_TIME, Asn1UtcTime.class),
+        new Asn1FieldInfo(GENERAL_TIME, Asn1GeneralizedTime.class)
+    };
+
+    public Time() {
+        super(fieldInfos);
+    }
+
+    public Date getUtcTime() {
+        return getFieldAs(UTC_TIME, Asn1UtcTime.class).getValue();
+    }
+
+    public void setUtcTime(Asn1UtcTime utcTime) {
+        setFieldAs(UTC_TIME, utcTime);
+    }
+
+    public Date generalizedTime() {
+        return getFieldAs(GENERAL_TIME, Asn1GeneralizedTime.class).getValue();
+    }
+
+    public void setGeneralTime(Asn1GeneralizedTime generalTime) {
+        setFieldAs(GENERAL_TIME, generalTime);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/UserNotice.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/UserNotice.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/UserNotice.java
new file mode 100644
index 0000000..d648218
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/UserNotice.java
@@ -0,0 +1,63 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+
+/**
+ *
+ * <pre>
+ * UserNotice ::= SEQUENCE {
+ *      noticeRef        NoticeReference OPTIONAL,
+ *      explicitText     DisplayText OPTIONAL}
+ *
+ * </pre>
+ *
+ */
+public class UserNotice extends Asn1SequenceType {
+    private static final int NOTICE_REF = 0;
+    private static final int EXPLICIT_TEXT = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+        new Asn1FieldInfo(NOTICE_REF, NoticeReference.class),
+        new Asn1FieldInfo(EXPLICIT_TEXT, DisplayText.class)
+    };
+
+    public UserNotice() {
+        super(fieldInfos);
+    }
+
+    public NoticeReference getNoticeRef() {
+        return getFieldAs(NOTICE_REF, NoticeReference.class);
+    }
+
+    public void setNoticeRef(NoticeReference noticeRef) {
+        setFieldAs(NOTICE_REF, noticeRef);
+    }
+    
+    public DisplayText getExplicitText() {
+        return getFieldAs(EXPLICIT_TEXT, DisplayText.class);
+    }
+
+    public void setExplicitText(DisplayText explicitText) {
+        setFieldAs(EXPLICIT_TEXT, explicitText);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/kerby-pkix/src/main/java/org/apache/kerby/x509/type/V2Form.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/V2Form.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/V2Form.java
new file mode 100644
index 0000000..26ecec3
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/V2Form.java
@@ -0,0 +1,77 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.x509.type;
+
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+import org.apache.kerby.asn1.type.ExplicitField;
+
+/**
+ * Produce an object suitable for an ASN1OutputStream.
+ * <pre>
+ *  V2Form ::= SEQUENCE {
+ *       issuerName            GeneralNames  OPTIONAL,
+ *       baseCertificateID     [0] IssuerSerial  OPTIONAL,
+ *       objectDigestInfo      [1] ObjectDigestInfo  OPTIONAL
+ *         -- issuerName MUST be present in this profile
+ *         -- baseCertificateID and objectDigestInfo MUST NOT
+ *         -- be present in this profile
+ *  }
+ * </pre>
+ */
+public class V2Form extends Asn1SequenceType {
+    private static final int ISSUER_NAME = 0;
+    private static final int BASE_CERTIFICATE_ID = 1;
+    private static final int OBJECT_DIGEST_INFO = 2;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+        new Asn1FieldInfo(ISSUER_NAME, GeneralNames.class),
+        new ExplicitField(BASE_CERTIFICATE_ID, 0, IssuerSerial.class),
+        new ExplicitField(OBJECT_DIGEST_INFO, 1, ObjectDigestInfo.class)
+    };
+
+    public V2Form() {
+        super(fieldInfos);
+    }
+
+    public GeneralNames getIssuerName() {
+        return getFieldAs(ISSUER_NAME, GeneralNames.class);
+    }
+
+    public void setIssuerName(GeneralNames issuerName) {
+        setFieldAs(ISSUER_NAME, issuerName);
+    }
+
+    public IssuerSerial getBaseCertificateID() {
+        return getFieldAs(BASE_CERTIFICATE_ID, IssuerSerial.class);
+    }
+
+    public void setBaseCertificateId(IssuerSerial baseCertificateId) {
+        setFieldAs(BASE_CERTIFICATE_ID, baseCertificateId);
+    }
+
+    public ObjectDigestInfo getObjectDigestInfo() {
+        return getFieldAs(OBJECT_DIGEST_INFO, ObjectDigestInfo.class);
+    }
+
+    public void setObjectDigestInfo(ObjectDigestInfo objectDigestInfo) {
+        setFieldAs(OBJECT_DIGEST_INFO, objectDigestInfo);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/93bcd6fe/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 96ea773..90be760 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,7 @@
     <module>kerby-config</module>
     <module>kerby-util</module>
     <module>kerby-asn1</module>
+    <module>kerby-pkix</module>
     <module>kerby-kerb</module>
     <module>kerby-kdc</module>
     <module>kerby-tool</module>