You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2016/01/16 10:49:32 UTC
[34/36] directory-kerby git commit: Consolidated facility and support
modules into kerby-common
Consolidated facility and support modules into kerby-common
Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/9e4dbd6e
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/9e4dbd6e
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/9e4dbd6e
Branch: refs/heads/kadmin-remote
Commit: 9e4dbd6e61110cc7a61cbbc4dc9135abd405dbe5
Parents: 2c8b66e
Author: Drankye <dr...@gmail.com>
Authored: Sun Jan 17 17:38:23 2016 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Sun Jan 17 17:38:23 2016 +0800
----------------------------------------------------------------------
kerby-asn1/README.md | 389 -------
kerby-asn1/pom.xml | 32 -
.../main/java/org/apache/kerby/asn1/Asn1.java | 188 ----
.../java/org/apache/kerby/asn1/Asn1Binder.java | 51 -
.../org/apache/kerby/asn1/Asn1Converter.java | 88 --
.../org/apache/kerby/asn1/Asn1Dumpable.java | 26 -
.../java/org/apache/kerby/asn1/Asn1Dumper.java | 136 ---
.../java/org/apache/kerby/asn1/Asn1Factory.java | 57 -
.../org/apache/kerby/asn1/Asn1FieldInfo.java | 107 --
.../java/org/apache/kerby/asn1/EnumType.java | 37 -
.../org/apache/kerby/asn1/ExplicitField.java | 46 -
.../org/apache/kerby/asn1/ImplicitField.java | 46 -
.../main/java/org/apache/kerby/asn1/Tag.java | 160 ---
.../java/org/apache/kerby/asn1/TagClass.java | 99 --
.../org/apache/kerby/asn1/TaggingOption.java | 119 --
.../org/apache/kerby/asn1/UniversalTag.java | 132 ---
.../apache/kerby/asn1/parse/Asn1Container.java | 81 --
.../kerby/asn1/parse/Asn1DerivedItem.java | 86 --
.../org/apache/kerby/asn1/parse/Asn1Header.java | 48 -
.../org/apache/kerby/asn1/parse/Asn1Item.java | 34 -
.../kerby/asn1/parse/Asn1ParseResult.java | 124 ---
.../org/apache/kerby/asn1/parse/Asn1Parser.java | 85 --
.../org/apache/kerby/asn1/parse/Asn1Reader.java | 126 ---
.../kerby/asn1/type/AbstractAsn1Type.java | 83 --
.../org/apache/kerby/asn1/type/Asn1Any.java | 212 ----
.../apache/kerby/asn1/type/Asn1BitString.java | 108 --
.../apache/kerby/asn1/type/Asn1BmpString.java | 70 --
.../org/apache/kerby/asn1/type/Asn1Boolean.java | 85 --
.../org/apache/kerby/asn1/type/Asn1Choice.java | 241 ----
.../apache/kerby/asn1/type/Asn1Collection.java | 79 --
.../kerby/asn1/type/Asn1CollectionOf.java | 88 --
.../kerby/asn1/type/Asn1CollectionType.java | 299 -----
.../apache/kerby/asn1/type/Asn1Constructed.java | 132 ---
.../apache/kerby/asn1/type/Asn1Encodeable.java | 292 -----
.../apache/kerby/asn1/type/Asn1Enumerated.java | 65 --
.../org/apache/kerby/asn1/type/Asn1Eoc.java | 70 --
.../org/apache/kerby/asn1/type/Asn1Flags.java | 132 ---
.../kerby/asn1/type/Asn1GeneralString.java | 32 -
.../kerby/asn1/type/Asn1GeneralizedTime.java | 136 ---
.../apache/kerby/asn1/type/Asn1IA5String.java | 32 -
.../org/apache/kerby/asn1/type/Asn1Integer.java | 51 -
.../org/apache/kerby/asn1/type/Asn1Null.java | 63 --
.../kerby/asn1/type/Asn1NumericsString.java | 45 -
.../org/apache/kerby/asn1/type/Asn1Object.java | 128 ---
.../kerby/asn1/type/Asn1ObjectIdentifier.java | 168 ---
.../apache/kerby/asn1/type/Asn1OctetString.java | 71 --
.../kerby/asn1/type/Asn1PrintableString.java | 32 -
.../apache/kerby/asn1/type/Asn1Sequence.java | 28 -
.../apache/kerby/asn1/type/Asn1SequenceOf.java | 36 -
.../kerby/asn1/type/Asn1SequenceType.java | 38 -
.../org/apache/kerby/asn1/type/Asn1Set.java | 28 -
.../org/apache/kerby/asn1/type/Asn1SetOf.java | 28 -
.../org/apache/kerby/asn1/type/Asn1SetType.java | 38 -
.../org/apache/kerby/asn1/type/Asn1Simple.java | 215 ----
.../apache/kerby/asn1/type/Asn1Specific.java | 57 -
.../org/apache/kerby/asn1/type/Asn1String.java | 292 -----
.../apache/kerby/asn1/type/Asn1T61String.java | 32 -
.../kerby/asn1/type/Asn1T61Utf8String.java | 42 -
.../org/apache/kerby/asn1/type/Asn1Tagging.java | 115 --
.../kerby/asn1/type/Asn1TaggingCollection.java | 191 ----
.../kerby/asn1/type/Asn1TaggingSequence.java | 38 -
.../apache/kerby/asn1/type/Asn1TaggingSet.java | 39 -
.../org/apache/kerby/asn1/type/Asn1Type.java | 189 ----
.../kerby/asn1/type/Asn1UniversalString.java | 32 -
.../org/apache/kerby/asn1/type/Asn1UtcTime.java | 87 --
.../apache/kerby/asn1/type/Asn1Utf8String.java | 46 -
.../kerby/asn1/type/Asn1VisibleString.java | 32 -
.../org/apache/kerby/asn1/util/Asn1Util.java | 119 --
.../org/apache/kerby/asn1/util/HexUtil.java | 113 --
.../java/org/apache/kerby/asn1/util/IOUtil.java | 109 --
.../java/org/apache/kerby/asn1/util/Utf8.java | 34 -
.../org/apache/kerby/asn1/Asn1BooleanTest.java | 70 --
.../apache/kerby/asn1/Asn1CollectionTest.java | 60 -
.../asn1/Asn1ConstructedOctetStringTest.java | 36 -
.../org/apache/kerby/asn1/Asn1DumpTest.java | 95 --
.../org/apache/kerby/asn1/Asn1FlagsTest.java | 158 ---
.../org/apache/kerby/asn1/Asn1IntegerTest.java | 72 --
.../kerby/asn1/Asn1ObjectIdentifierTest.java | 66 --
.../org/apache/kerby/asn1/Asn1UtcTimeTest.java | 72 --
.../java/org/apache/kerby/asn1/DataTest.java | 127 ---
.../org/apache/kerby/asn1/PersonnelRecord.java | 248 -----
.../apache/kerby/asn1/PersonnelRecordTest.java | 121 --
.../apache/kerby/asn1/TaggingEncodingTest.java | 205 ----
.../java/org/apache/kerby/asn1/TestUtil.java | 47 -
.../src/test/resources/compressed-data.txt | 1 -
.../test/resources/constructed-octet-string.txt | 1 -
kerby-asn1/src/test/resources/der-data.dat | Bin 291 -> 0 bytes
.../src/test/resources/empty-container.txt | 1 -
kerby-asn1/src/test/resources/signed-data.txt | 1 -
kerby-common/kerby-asn1/README.md | 389 +++++++
kerby-common/kerby-asn1/pom.xml | 32 +
.../main/java/org/apache/kerby/asn1/Asn1.java | 188 ++++
.../java/org/apache/kerby/asn1/Asn1Binder.java | 51 +
.../org/apache/kerby/asn1/Asn1Converter.java | 88 ++
.../org/apache/kerby/asn1/Asn1Dumpable.java | 26 +
.../java/org/apache/kerby/asn1/Asn1Dumper.java | 136 +++
.../java/org/apache/kerby/asn1/Asn1Factory.java | 57 +
.../org/apache/kerby/asn1/Asn1FieldInfo.java | 107 ++
.../java/org/apache/kerby/asn1/EnumType.java | 37 +
.../org/apache/kerby/asn1/ExplicitField.java | 46 +
.../org/apache/kerby/asn1/ImplicitField.java | 46 +
.../main/java/org/apache/kerby/asn1/Tag.java | 160 +++
.../java/org/apache/kerby/asn1/TagClass.java | 99 ++
.../org/apache/kerby/asn1/TaggingOption.java | 119 ++
.../org/apache/kerby/asn1/UniversalTag.java | 132 +++
.../apache/kerby/asn1/parse/Asn1Container.java | 81 ++
.../kerby/asn1/parse/Asn1DerivedItem.java | 86 ++
.../org/apache/kerby/asn1/parse/Asn1Header.java | 48 +
.../org/apache/kerby/asn1/parse/Asn1Item.java | 34 +
.../kerby/asn1/parse/Asn1ParseResult.java | 124 +++
.../org/apache/kerby/asn1/parse/Asn1Parser.java | 85 ++
.../org/apache/kerby/asn1/parse/Asn1Reader.java | 126 +++
.../kerby/asn1/type/AbstractAsn1Type.java | 83 ++
.../org/apache/kerby/asn1/type/Asn1Any.java | 212 ++++
.../apache/kerby/asn1/type/Asn1BitString.java | 108 ++
.../apache/kerby/asn1/type/Asn1BmpString.java | 70 ++
.../org/apache/kerby/asn1/type/Asn1Boolean.java | 85 ++
.../org/apache/kerby/asn1/type/Asn1Choice.java | 241 ++++
.../apache/kerby/asn1/type/Asn1Collection.java | 79 ++
.../kerby/asn1/type/Asn1CollectionOf.java | 88 ++
.../kerby/asn1/type/Asn1CollectionType.java | 299 +++++
.../apache/kerby/asn1/type/Asn1Constructed.java | 132 +++
.../apache/kerby/asn1/type/Asn1Encodeable.java | 292 +++++
.../apache/kerby/asn1/type/Asn1Enumerated.java | 65 ++
.../org/apache/kerby/asn1/type/Asn1Eoc.java | 70 ++
.../org/apache/kerby/asn1/type/Asn1Flags.java | 132 +++
.../kerby/asn1/type/Asn1GeneralString.java | 32 +
.../kerby/asn1/type/Asn1GeneralizedTime.java | 136 +++
.../apache/kerby/asn1/type/Asn1IA5String.java | 32 +
.../org/apache/kerby/asn1/type/Asn1Integer.java | 51 +
.../org/apache/kerby/asn1/type/Asn1Null.java | 63 ++
.../kerby/asn1/type/Asn1NumericsString.java | 45 +
.../org/apache/kerby/asn1/type/Asn1Object.java | 128 +++
.../kerby/asn1/type/Asn1ObjectIdentifier.java | 168 +++
.../apache/kerby/asn1/type/Asn1OctetString.java | 71 ++
.../kerby/asn1/type/Asn1PrintableString.java | 32 +
.../apache/kerby/asn1/type/Asn1Sequence.java | 28 +
.../apache/kerby/asn1/type/Asn1SequenceOf.java | 36 +
.../kerby/asn1/type/Asn1SequenceType.java | 38 +
.../org/apache/kerby/asn1/type/Asn1Set.java | 28 +
.../org/apache/kerby/asn1/type/Asn1SetOf.java | 28 +
.../org/apache/kerby/asn1/type/Asn1SetType.java | 38 +
.../org/apache/kerby/asn1/type/Asn1Simple.java | 215 ++++
.../apache/kerby/asn1/type/Asn1Specific.java | 57 +
.../org/apache/kerby/asn1/type/Asn1String.java | 292 +++++
.../apache/kerby/asn1/type/Asn1T61String.java | 32 +
.../kerby/asn1/type/Asn1T61Utf8String.java | 42 +
.../org/apache/kerby/asn1/type/Asn1Tagging.java | 115 ++
.../kerby/asn1/type/Asn1TaggingCollection.java | 191 ++++
.../kerby/asn1/type/Asn1TaggingSequence.java | 38 +
.../apache/kerby/asn1/type/Asn1TaggingSet.java | 39 +
.../org/apache/kerby/asn1/type/Asn1Type.java | 189 ++++
.../kerby/asn1/type/Asn1UniversalString.java | 32 +
.../org/apache/kerby/asn1/type/Asn1UtcTime.java | 87 ++
.../apache/kerby/asn1/type/Asn1Utf8String.java | 46 +
.../kerby/asn1/type/Asn1VisibleString.java | 32 +
.../org/apache/kerby/asn1/util/Asn1Util.java | 119 ++
.../org/apache/kerby/asn1/util/HexUtil.java | 113 ++
.../java/org/apache/kerby/asn1/util/IOUtil.java | 109 ++
.../java/org/apache/kerby/asn1/util/Utf8.java | 34 +
.../org/apache/kerby/asn1/Asn1BooleanTest.java | 70 ++
.../apache/kerby/asn1/Asn1CollectionTest.java | 60 +
.../asn1/Asn1ConstructedOctetStringTest.java | 36 +
.../org/apache/kerby/asn1/Asn1DumpTest.java | 95 ++
.../org/apache/kerby/asn1/Asn1FlagsTest.java | 158 +++
.../org/apache/kerby/asn1/Asn1IntegerTest.java | 72 ++
.../kerby/asn1/Asn1ObjectIdentifierTest.java | 66 ++
.../org/apache/kerby/asn1/Asn1UtcTimeTest.java | 72 ++
.../java/org/apache/kerby/asn1/DataTest.java | 127 +++
.../org/apache/kerby/asn1/PersonnelRecord.java | 248 +++++
.../apache/kerby/asn1/PersonnelRecordTest.java | 121 ++
.../apache/kerby/asn1/TaggingEncodingTest.java | 205 ++++
.../java/org/apache/kerby/asn1/TestUtil.java | 47 +
.../src/test/resources/compressed-data.txt | 1 +
.../test/resources/constructed-octet-string.txt | 1 +
.../kerby-asn1/src/test/resources/der-data.dat | Bin 0 -> 291 bytes
.../src/test/resources/empty-container.txt | 1 +
.../src/test/resources/signed-data.txt | 1 +
kerby-common/kerby-config/README | 20 +
kerby-common/kerby-config/pom.xml | 41 +
.../main/java/org/apache/kerby/config/Conf.java | 318 ++++++
.../java/org/apache/kerby/config/Config.java | 138 +++
.../org/apache/kerby/config/ConfigImpl.java | 428 +++++++
.../java/org/apache/kerby/config/ConfigKey.java | 25 +
.../org/apache/kerby/config/ConfigLoader.java | 50 +
.../org/apache/kerby/config/ConfigObject.java | 85 ++
.../org/apache/kerby/config/Configurable.java | 30 +
.../org/apache/kerby/config/Configured.java | 45 +
.../apache/kerby/config/IniConfigLoader.java | 75 ++
.../apache/kerby/config/JsonConfigLoader.java | 27 +
.../apache/kerby/config/MapConfigLoader.java | 79 ++
.../kerby/config/PropertiesConfigLoader.java | 42 +
.../config/PropertiesFileConfigLoader.java | 33 +
.../java/org/apache/kerby/config/Resource.java | 121 ++
.../apache/kerby/config/XmlConfigLoader.java | 153 +++
.../java/org/apache/kerby/config/ConfTest.java | 134 +++
.../org/apache/kerby/config/ConfigImplTest.java | 63 ++
.../org/apache/kerby/config/IniConfigTest.java | 88 ++
kerby-common/kerby-util/pom.xml | 41 +
.../src/main/java/org/apache/kerby/KOption.java | 29 +
.../java/org/apache/kerby/KOptionGroup.java | 33 +
.../main/java/org/apache/kerby/KOptionInfo.java | 142 +++
.../main/java/org/apache/kerby/KOptionType.java | 35 +
.../main/java/org/apache/kerby/KOptions.java | 187 ++++
.../main/java/org/apache/kerby/util/Base64.java | 1048 ++++++++++++++++++
.../apache/kerby/util/Base64InputStream.java | 174 +++
.../apache/kerby/util/Base64OutputStream.java | 198 ++++
.../apache/kerby/util/ByteArrayReadLine.java | 58 +
.../org/apache/kerby/util/EncryptoUtil.java | 46 +
.../main/java/org/apache/kerby/util/Hex.java | 77 ++
.../java/org/apache/kerby/util/HexUtil.java | 114 ++
.../java/org/apache/kerby/util/HostPort.java | 57 +
.../main/java/org/apache/kerby/util/IOUtil.java | 110 ++
.../org/apache/kerby/util/IPAddressParser.java | 181 +++
.../java/org/apache/kerby/util/NetworkUtil.java | 48 +
.../main/java/org/apache/kerby/util/OSUtil.java | 62 ++
.../org/apache/kerby/util/PublicKeyDeriver.java | 79 ++
.../java/org/apache/kerby/util/ReadLine.java | 116 ++
.../java/org/apache/kerby/util/SysUtil.java | 35 +
.../main/java/org/apache/kerby/util/Utf8.java | 34 +
.../main/java/org/apache/kerby/util/Util.java | 422 +++++++
.../java/org/apache/kerby/util/Base64Test.java | 109 ++
.../apache/kerby/util/IPAddressParserTest.java | 99 ++
kerby-common/pom.xml | 33 +
kerby-config/README | 20 -
kerby-config/pom.xml | 41 -
.../main/java/org/apache/kerby/config/Conf.java | 318 ------
.../java/org/apache/kerby/config/Config.java | 138 ---
.../org/apache/kerby/config/ConfigImpl.java | 428 -------
.../java/org/apache/kerby/config/ConfigKey.java | 25 -
.../org/apache/kerby/config/ConfigLoader.java | 50 -
.../org/apache/kerby/config/ConfigObject.java | 85 --
.../org/apache/kerby/config/Configurable.java | 30 -
.../org/apache/kerby/config/Configured.java | 45 -
.../apache/kerby/config/IniConfigLoader.java | 75 --
.../apache/kerby/config/JsonConfigLoader.java | 27 -
.../apache/kerby/config/MapConfigLoader.java | 79 --
.../kerby/config/PropertiesConfigLoader.java | 42 -
.../config/PropertiesFileConfigLoader.java | 33 -
.../java/org/apache/kerby/config/Resource.java | 121 --
.../apache/kerby/config/XmlConfigLoader.java | 153 ---
.../java/org/apache/kerby/config/ConfTest.java | 134 ---
.../org/apache/kerby/config/ConfigImplTest.java | 63 --
.../org/apache/kerby/config/IniConfigTest.java | 88 --
kerby-util/pom.xml | 29 -
.../src/main/java/org/apache/kerby/KOption.java | 29 -
.../java/org/apache/kerby/KOptionGroup.java | 33 -
.../main/java/org/apache/kerby/KOptionInfo.java | 142 ---
.../main/java/org/apache/kerby/KOptionType.java | 35 -
.../main/java/org/apache/kerby/KOptions.java | 187 ----
.../main/java/org/apache/kerby/util/Base64.java | 1048 ------------------
.../apache/kerby/util/Base64InputStream.java | 174 ---
.../apache/kerby/util/Base64OutputStream.java | 198 ----
.../apache/kerby/util/ByteArrayReadLine.java | 58 -
.../org/apache/kerby/util/EncryptoUtil.java | 46 -
.../main/java/org/apache/kerby/util/Hex.java | 77 --
.../java/org/apache/kerby/util/HexUtil.java | 114 --
.../java/org/apache/kerby/util/HostPort.java | 57 -
.../main/java/org/apache/kerby/util/IOUtil.java | 110 --
.../org/apache/kerby/util/IPAddressParser.java | 181 ---
.../java/org/apache/kerby/util/NetworkUtil.java | 48 -
.../main/java/org/apache/kerby/util/OSUtil.java | 62 --
.../org/apache/kerby/util/PublicKeyDeriver.java | 79 --
.../java/org/apache/kerby/util/ReadLine.java | 116 --
.../java/org/apache/kerby/util/SysUtil.java | 35 -
.../main/java/org/apache/kerby/util/Utf8.java | 34 -
.../main/java/org/apache/kerby/util/Util.java | 422 -------
.../java/org/apache/kerby/util/Base64Test.java | 109 --
.../apache/kerby/util/IPAddressParserTest.java | 99 --
pom.xml | 4 +-
270 files changed, 13933 insertions(+), 13890 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/README.md
----------------------------------------------------------------------
diff --git a/kerby-asn1/README.md b/kerby-asn1/README.md
deleted file mode 100644
index 05f5502..0000000
--- a/kerby-asn1/README.md
+++ /dev/null
@@ -1,389 +0,0 @@
-<!--
- 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.
--->
-kerby-asn1
-=========
-
-### A ASN1 parser with easy and simple API
-
-```
-// encoding
-Asn1Integer aValue = new Asn1Integer(8899);
-byte[] encoded = aValue.encode();
-
-// decoding
-byte[] contentToDecode = ...
-Asn1Integer decodedValue = new Asn1Integer();
-decodedValue.decode(contentToDecode);
-Integer value = decodedValue.getValue();
-```
-
-### Data-driven ASN1 encoding/decoding framework and parser
-
-With the following definition from Kerberos protocol
-```
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
- ad-type [0] Int32,
- ad-data [1] OCTET STRING
- }
- ```
-
-You can model AuthzDataEntry as follows
-```java
-public class AuthorizationDataEntry extends KrbSequenceType {
- /**
- * The possible fields
- */
- protected enum AuthorizationDataEntryField implements EnumType {
- AD_TYPE,
- AD_DATA;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getValue() {
- return ordinal();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return name();
- }
- }
-
- /** The AuthorizationDataEntry's fields */
- private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new ExplicitField(AuthorizationDataEntryField.AD_TYPE, Asn1Integer.class),
- new ExplicitField(AuthorizationDataEntryField.AD_DATA, Asn1OctetString.class)
- };
-
- /**
- * Creates an AuthorizationDataEntry instance
- */
- public AuthorizationDataEntry() {
- super(fieldInfos);
- }
-
- /**
- * @return The AuthorizationType (AD_TYPE) field
- */
- public AuthorizationType getAuthzType() {
- Integer value = getFieldAsInteger(AuthorizationDataEntryField.AD_TYPE);
- return AuthorizationType.fromValue(value);
- }
-
- /**
- * Sets the AuthorizationType (AD_TYPE) field
- * @param authzType The AuthorizationType to set
- */
- public void setAuthzType(AuthorizationType authzType) {
- setFieldAsInt(AuthorizationDataEntryField.AD_TYPE, authzType.getValue());
- }
-
- /**
- * @return The AuthorizationType (AD_DATA) field
- */
- public byte[] getAuthzData() {
- return getFieldAsOctets(AuthorizationDataEntryField.AD_DATA);
- }
-
- /**
- * Sets the AuthorizationData (AD_DATA) field
- * @param authzData The AuthorizationData to set
- */
- public void setAuthzData(byte[] authzData) {
- setFieldAsOctets(AuthorizationDataEntryField.AD_DATA, authzData);
- }
-}
-```
-
-And then define AuthorizationData simply
-```java
-public class AuthorizationData extends KrbSequenceOfType<AuthorizationDataEntry> {
-
-}
-```
-
-Then you can process with above definitions, encode and decode, without caring about the details.
-
-Think about how to implement the following more complex and pratical sample from [ITU-T Rec. X.680 ISO/IEC 8824-1](http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf):
-```
-A.1 ASN.1 description of the record structure
-The structure of the hypothetical personnel record is formally described below using ASN.1 specified in
-ITU-T Rec. X.680 | ISO/IEC 8824-1 for defining types.
-
-PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET {
- Name Name,
- title [0] VisibleString,
- number EmployeeNumber,
- dateOfHire [1] Date,
- nameOfSpouse [2] Name,
- children [3] IMPLICIT
- SEQUENCE OF ChildInformation DEFAULT {}
-}
-
-ChildInformation ::= SET {
- name Name,
- dateOfBirth [0] Date
-}
-
-Name ::= [APPLICATION 1] IMPLICIT SEQUENCE {
- givenName VisibleString,
- initial VisibleString,
- familyName VisibleString
-}
-
-EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER
-Date ::= [APPLICATION 3] IMPLICIT VisibleString -- YYYYMMDD
-```
-Similarly as above, we can have (from the unit test codes):
-```java
-public class PersonnelRecord extends Asn1TaggingSet {
- protected enum PersonnelRecordField implements EnumType {
- NAME,
- TITLE,
- NUMBER,
- DATE_OF_HIRE,
- NAME_OF_SPOUSE,
- CHILDREN;
-
- @Override
- public int getValue() {
- return ordinal();
- }
-
- @Override
- public String getName() {
- return name();
- }
- }
-
- static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
- new ExplicitField(PersonnelRecordField.NAME, -1, Name.class),
- new ExplicitField(PersonnelRecordField.TITLE, 0, Asn1VisibleString.class),
- new ExplicitField(PersonnelRecordField.NUMBER, -1, EmployeeNumber.class),
- new ExplicitField(PersonnelRecordField.DATE_OF_HIRE, 1, Date.class),
- new ExplicitField(PersonnelRecordField.NAME_OF_SPOUSE, 2, Name.class),
- new ImplicitField(PersonnelRecordField.CHILDREN, 3, Children.class)
- };
-
- public PersonnelRecord() {
- super(0, fieldInfos, true, true);
- }
-
- public void setName(Name name) {
- setFieldAs(PersonnelRecordField.NAME, name);
- }
-
- public Name getName() {
- return getFieldAs(PersonnelRecordField.NAME, Name.class);
- }
-
- public void setTitle(String title) {
- setFieldAs(PersonnelRecordField.TITLE, new Asn1VisibleString(title));
- }
-
- public String getTitle() {
- return getFieldAsString(PersonnelRecordField.TITLE);
- }
-
- public void setEmployeeNumber(EmployeeNumber employeeNumber) {
- setFieldAs(PersonnelRecordField.NUMBER, employeeNumber);
- }
-
- public EmployeeNumber getEmployeeNumber() {
- return getFieldAs(PersonnelRecordField.NUMBER, EmployeeNumber.class);
- }
-
- public void setDateOfHire(Date dateOfHire) {
- setFieldAs(PersonnelRecordField.DATE_OF_HIRE, dateOfHire);
- }
-
- public Date getDateOfHire() {
- return getFieldAs(PersonnelRecordField.DATE_OF_HIRE, Date.class);
- }
-
- public void setNameOfSpouse(Name spouse) {
- setFieldAs(PersonnelRecordField.NAME_OF_SPOUSE, spouse);
- }
-
- public Name getNameOfSpouse() {
- return getFieldAs(PersonnelRecordField.NAME_OF_SPOUSE, Name.class);
- }
-
- public void setChildren(Children children) {
- setFieldAs(PersonnelRecordField.CHILDREN, children);
- }
-
- public Children getChildren() {
- return getFieldAs(PersonnelRecordField.CHILDREN, Children.class);
- }
-
- public static class Children extends Asn1SequenceOf<ChildInformation> {
- public Children(ChildInformation ... children) {
- super();
- for (ChildInformation child : children) {
- addElement(child);
- }
- }
-
- public Children() {
- super();
- }
- }
-
- public static class ChildInformation extends Asn1SetType {
- protected enum ChildInformationField implements EnumType {
- CHILD_NAME,
- DATE_OF_BIRTH;
-
- @Override
- public int getValue() {
- return ordinal();
- }
-
- @Override
- public String getName() {
- return name();
- }
- }
-
- static Asn1FieldInfo[] tags = new Asn1FieldInfo[] {
- new ExplicitField(ChildInformationField.CHILD_NAME, -1, Name.class),
- new ExplicitField(ChildInformationField.DATE_OF_BIRTH, 0, Date.class)
- };
-
- public ChildInformation() {
- super(tags);
- }
-
- public void setName(Name name) {
- setFieldAs(ChildInformationField.CHILD_NAME, name);
- }
-
- public Name getName() {
- return getFieldAs(ChildInformationField.CHILD_NAME, Name.class);
- }
-
- public void setDateOfBirth(Date date) {
- setFieldAs(ChildInformationField.DATE_OF_BIRTH, date);
- }
-
- public Date getDateOfBirth() {
- return getFieldAs(ChildInformationField.DATE_OF_BIRTH, Date.class);
- }
- }
-
- public static class Name extends Asn1TaggingSequence {
-
- protected enum NameField implements EnumType {
- GIVENNAME,
- INITIAL,
- FAMILYNAME;
-
- @Override
- public int getValue() {
- return ordinal();
- }
-
- @Override
- public String getName() {
- return name();
- }
- }
-
- static Asn1FieldInfo[] tags = new Asn1FieldInfo[] {
- new ExplicitField(NameField.GIVENNAME, -1, Asn1VisibleString.class),
- new ExplicitField(NameField.INITIAL, -1, Asn1VisibleString.class),
- new ExplicitField(NameField.FAMILYNAME, -1, Asn1VisibleString.class)
- };
-
- public Name() {
- super(1, tags, true, true);
- }
-
- public Name(String givenName, String initial, String familyName) {
- this();
- setGivenName(givenName);
- setInitial(initial);
- setFamilyName(familyName);
- }
-
- public void setGivenName(String givenName) {
- setFieldAs(NameField.GIVENNAME, new Asn1VisibleString(givenName));
- }
-
- public String getGivenName() {
- return getFieldAsString(NameField.GIVENNAME);
- }
-
- public void setInitial(String initial) {
- setFieldAs(NameField.INITIAL, new Asn1VisibleString(initial));
- }
-
- public String getInitial() {
- return getFieldAsString(NameField.INITIAL);
- }
-
- public void setFamilyName(String familyName) {
- setFieldAs(NameField.FAMILYNAME, new Asn1VisibleString(familyName));
- }
-
- public String getFamilyName() {
- return getFieldAsString(NameField.FAMILYNAME);
- }
- }
-
- public static class EmployeeNumber extends Asn1Tagging<Asn1Integer> {
- public EmployeeNumber(Integer value) {
- super(2, new Asn1Integer(value), true, true);
- }
-
- public EmployeeNumber() {
- super(2, new Asn1Integer(), true, true);
- }
- }
-
- public static class Date extends Asn1Tagging<Asn1VisibleString> {
- public Date(String value) {
- super(3, new Asn1VisibleString(value), true, true);
- }
- public Date() {
- this(null);
- }
- }
-}
-```
-### ASN1 dumping tool
-* ASN1 dumping tool to help analyze ASN1 encoding stream or packet. It can be used to exercise the framework with all kinds of testing binary inputs.
-* The shortcut API for ASN1 encoding, decoding and dumping in Asn1.java
-
-### Notes
-* 90% tests coverage for DER encoding
-* For BER & CER encoding, to be fully supported
-* No extra dependency
-
-### License
-Apache V2 License
-
-
-
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-asn1/pom.xml b/kerby-asn1/pom.xml
deleted file mode 100644
index b89e06a..0000000
--- a/kerby-asn1/pom.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed 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. See accompanying LICENSE file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerby-all</artifactId>
- <version>1.0.0-RC2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>kerby-asn1</artifactId>
- <name>Kerby ASN1 Project</name>
- <description>Kerby ASN1 Project</description>
-
- <dependencies>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
deleted file mode 100644
index 08a9019..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.parse.Asn1ParseResult;
-import org.apache.kerby.asn1.parse.Asn1Parser;
-import org.apache.kerby.asn1.type.Asn1Type;
-import org.apache.kerby.asn1.util.HexUtil;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * The shortcut API for ASN1 encoding, decoding and dumping.
- */
-public final class Asn1 {
-
- private Asn1() {
-
- }
-
- /**
- * Encode value into buffer.
- * @param buffer
- * @param value
- * @throws IOException
- */
- public static void encode(ByteBuffer buffer, Asn1Type value) throws IOException {
- value.encode(buffer);
- }
-
- /**
- * Encode value and return the result.
- * @param value
- * @return
- * @throws IOException
- */
- public static byte[] encode(Asn1Type value) throws IOException {
- return value.encode();
- }
-
- /**
- * Blindly decode content and return the result ASN1 object.
- * @param content
- * @return
- * @throws IOException
- */
- public static Asn1Type decode(byte[] content) throws IOException {
- return decode(ByteBuffer.wrap(content));
- }
-
- /**
- * See avove.
- */
- public static Asn1Type decode(ByteBuffer content) throws IOException {
- Asn1ParseResult parseResult = Asn1Parser.parse(content);
- return Asn1Converter.convert(parseResult, false);
- }
-
- /**
- * Decode using specified value container. Better to use this when the value
- * type is known prior to the call.
- * @param content
- * @param value
- * @throws IOException
- */
- public static void decode(byte[] content, Asn1Type value) throws IOException {
- value.decode(content);
- }
-
- /**
- * See avove.
- */
- public static void decode(ByteBuffer content, Asn1Type value) throws IOException {
- value.decode(content);
- }
-
- /**
- * Parse content and return parse result. Note this is different from decode,
- * as it doesn't decode into values, only parse result info like offset,
- * header len, body len and etc. are out.
- * @param content
- * @return
- * @throws IOException
- */
- public static Asn1ParseResult parse(byte[] content) throws IOException {
- return parse(ByteBuffer.wrap(content));
- }
-
- /**
- * See avove.
- */
- public static Asn1ParseResult parse(ByteBuffer content) throws IOException {
- return Asn1Parser.parse(content);
- }
-
- /**
- * Dump out a value.
- * @param value
- */
- public static void dump(Asn1Type value) {
- Asn1Dumper dumper = new Asn1Dumper();
- dumper.dumpType(0, value);
- String output = dumper.output();
- System.out.println(output);
- }
-
- /**
- * Parse first, and then dump out the parse result.
- * @param hexStr
- * @throws IOException
- */
- public static void parseAndDump(String hexStr) throws IOException {
- byte[] data = HexUtil.hex2bytes(hexStr);
- parseAndDump(data);
- }
-
- /**
- * See avove.
- */
- public static void parseAndDump(ByteBuffer content) throws IOException {
- byte[] bytes = new byte[content.remaining()];
- content.get(bytes);
- parseAndDump(bytes);
- }
-
- /**
- * See avove.
- */
- public static void parseAndDump(byte[] content) throws IOException {
- String hexStr = HexUtil.bytesToHex(content);
- Asn1Dumper dumper = new Asn1Dumper();
- System.out.println("Dumping data:");
- dumper.dumpData(hexStr);
- dumper.parseAndDump(content);
- String output = dumper.output();
- System.out.println(output);
- }
-
- /**
- * Decode first, and then dump out the decoded value.
- * @param hexStr
- * @throws IOException
- */
- public static void decodeAndDump(String hexStr) throws IOException {
- byte[] data = HexUtil.hex2bytes(hexStr);
- decodeAndDump(data);
- }
-
- /**
- * See avove.
- */
- public static void decodeAndDump(ByteBuffer content) throws IOException {
- byte[] bytes = new byte[content.remaining()];
- content.get(bytes);
- decodeAndDump(bytes);
- }
-
- /**
- * See avove.
- */
- public static void decodeAndDump(byte[] content) throws IOException {
- String hexStr = HexUtil.bytesToHex(content);
- Asn1Dumper dumper = new Asn1Dumper();
- System.out.println("Dumping data:");
- dumper.dumpData(hexStr);
- dumper.decodeAndDump(content);
- String output = dumper.output();
- System.out.println(output);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Binder.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Binder.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Binder.java
deleted file mode 100644
index c73b63a..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Binder.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.parse.Asn1ParseResult;
-import org.apache.kerby.asn1.type.Asn1Encodeable;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.io.IOException;
-
-/**
- * Decode and bind a parsing result to an ASN1 object.
- */
-public final class Asn1Binder {
-
- private Asn1Binder() {
-
- }
-
- public static void bind(Asn1ParseResult parseResult,
- Asn1Type value) throws IOException {
- value.useDefinitiveLength(parseResult.isDefinitiveLength());
- ((Asn1Encodeable) value).decode(parseResult);
- }
-
- public static void bindWithTagging(Asn1ParseResult parseResult, Asn1Type value,
- TaggingOption taggingOption) throws IOException {
- if (!parseResult.isTagSpecific()) {
- throw new IllegalArgumentException(
- "Attempting to decode non-tagged value using tagging way");
- }
- ((Asn1Encodeable) value).taggedDecode(parseResult, taggingOption);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Converter.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Converter.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Converter.java
deleted file mode 100644
index f426764..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Converter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.parse.Asn1ParseResult;
-import org.apache.kerby.asn1.type.Asn1Specific;
-import org.apache.kerby.asn1.type.Asn1Collection;
-import org.apache.kerby.asn1.type.Asn1Constructed;
-import org.apache.kerby.asn1.type.Asn1Encodeable;
-import org.apache.kerby.asn1.type.Asn1Simple;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.io.IOException;
-
-/**
- * Converting a ASN1 parsing result into an ASN1 object.
- */
-public final class Asn1Converter {
-
- private Asn1Converter() {
-
- }
-
- public static Asn1Type convert(Asn1ParseResult parseResult,
- boolean isLazy) throws IOException {
- if (Asn1Simple.isSimple(parseResult.tag())) {
- return Asn1Converter.convertAsSimple(parseResult);
- } else if (Asn1Collection.isCollection(parseResult.tag())) {
- return Asn1Converter.convertAsCollection(parseResult, isLazy);
- } else if (!parseResult.tag().isPrimitive()) {
- Asn1Encodeable tmpValue = new Asn1Constructed(parseResult.tag());
- tmpValue.decode(parseResult);
- return tmpValue;
- } else if (parseResult.isTagSpecific()) {
- Asn1Specific app = new Asn1Specific(parseResult.tag());
- app.decode(parseResult);
- return app;
- } else {
- throw new IOException("Unexpected item: " + parseResult.simpleInfo());
- }
- }
-
- public static Asn1Type convertAsSimple(Asn1ParseResult parseResult) throws IOException {
- Asn1Encodeable value = Asn1Simple.createSimple(parseResult.tagNo());
- value.useDefinitiveLength(parseResult.isDefinitiveLength());
- Asn1Binder.bind(parseResult, value);
- return value;
- }
-
- public static Asn1Type convertAsCollection(Asn1ParseResult parseResult,
- boolean isLazy) throws IOException {
- Asn1Collection value = Asn1Collection.createCollection(parseResult.tag());
- value.useDefinitiveLength(parseResult.isDefinitiveLength());
- value.setLazy(isLazy);
- Asn1Binder.bind(parseResult, value);
- return value;
- }
-
- public static Asn1Type convertAs(Asn1ParseResult parseResult,
- Class<? extends Asn1Type> type) throws IOException {
- Asn1Type value;
- try {
- value = type.newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Invalid type: "
- + type.getCanonicalName(), e);
- }
- Asn1Binder.bind(parseResult, value);
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
deleted file mode 100644
index d4ae6d9..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.asn1;
-
-public interface Asn1Dumpable {
-
- void dumpWith(Asn1Dumper dumper, int indents);
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
deleted file mode 100644
index 3368a44..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.parse.Asn1Item;
-import org.apache.kerby.asn1.parse.Asn1ParseResult;
-import org.apache.kerby.asn1.parse.Asn1Parser;
-import org.apache.kerby.asn1.type.Asn1Specific;
-import org.apache.kerby.asn1.type.Asn1Simple;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-public final class Asn1Dumper {
- private StringBuilder builder = new StringBuilder();
-
- public String output() {
- return builder.toString();
- }
-
- public void parseAndDump(byte[] content) throws IOException {
- parseAndDump(ByteBuffer.wrap(content));
- }
-
- public void decodeAndDump(byte[] content) throws IOException {
- decodeAndDump(ByteBuffer.wrap(content));
- }
-
- public void decodeAndDump(ByteBuffer content) throws IOException {
- Asn1Type value = Asn1.decode(content);
- dumpType(0, value);
- }
-
- public void parseAndDump(ByteBuffer content) throws IOException {
- Asn1ParseResult parseResult = Asn1Parser.parse(content);
- dumpParseResult(0, parseResult);
- }
-
- public void dumpType(Asn1Type value) {
- dumpType(0, value);
- }
-
- public Asn1Dumper dumpType(int indents, Asn1Type value) {
- if (value == null) {
- indent(indents).append("Null");
- } else if (value instanceof Asn1Simple) {
- indent(indents).append(value.toString());
- } else if (value instanceof Asn1Dumpable) {
- Asn1Dumpable dumpable = (Asn1Dumpable) value;
- dumpable.dumpWith(this, indents);
- } else if (value instanceof Asn1Specific) {
- indent(indents).append(value.toString());
- } else {
- indent(indents).append("<Unknown>");
- }
-
- return this;
- }
-
- public Asn1Dumper dumpParseResult(int indents, Asn1ParseResult value) {
- if (value == null) {
- indent(indents).append("Null");
- } else if (value instanceof Asn1Item) {
- indent(indents).append(value.toString());
- } else if (value instanceof Asn1Dumpable) {
- Asn1Dumpable dumpable = (Asn1Dumpable) value;
- dumpable.dumpWith(this, indents);
- } else {
- indent(indents).append("<Unknown>");
- }
-
- return this;
- }
-
- public Asn1Dumper indent(int numSpaces) {
- for (int i = 0; i < numSpaces; i++) {
- builder.append(' ');
- }
- return this;
- }
-
- public Asn1Dumper append(Asn1Simple<?> simpleValue) {
- if (simpleValue != null) {
- builder.append(simpleValue.toString());
- } else {
- builder.append("null");
- }
- return this;
- }
-
- public Asn1Dumper append(String string) {
- builder.append(string);
- return this;
- }
-
- public Asn1Dumper appendType(Class<?> cls) {
- builder.append("<").append(cls.getSimpleName()).append("> ");
- return this;
- }
-
- public Asn1Dumper newLine() {
- builder.append("\n");
- return this;
- }
-
- public Asn1Dumper dumpData(String hexData) {
- int range = 100;
- int pos = range;
-
- while (pos < hexData.length()) {
- System.out.println(hexData.substring(pos - range, pos));
- pos = pos + range;
- }
- System.out.println(hexData.substring(pos - range, hexData.length()));
-
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
deleted file mode 100644
index 7610751..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.type.Asn1Collection;
-import org.apache.kerby.asn1.type.Asn1Simple;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-/**
- * ASN1 type factory
- */
-public class Asn1Factory {
-
- /**
- * Create an ASN1 type with specified tag number
- * @param tagNo The tag number
- * @return ASN1 type
- */
- public static Asn1Type create(int tagNo) {
- UniversalTag tagNoEnum = UniversalTag.fromValue(tagNo);
- if (tagNoEnum != UniversalTag.UNKNOWN) {
- return create(tagNoEnum);
- }
- throw new IllegalArgumentException("Unexpected tag " + tagNo);
- }
-
- /**
- * Create an ASN1 type with specified tag
- * @param tagNo The tag number
- * @return ASN1 type
- */
- public static Asn1Type create(UniversalTag tagNo) {
- if (Asn1Simple.isSimple(tagNo)) {
- return Asn1Simple.createSimple(tagNo);
- } else if (Asn1Collection.isCollection(tagNo)) {
- return Asn1Collection.createCollection(tagNo);
- }
- throw new IllegalArgumentException("Unexpected tag " + tagNo);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1FieldInfo.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1FieldInfo.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1FieldInfo.java
deleted file mode 100644
index 72182b0..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1FieldInfo.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.type.Asn1Type;
-
-/**
- * Representing a field in a ASN1 collection or choice.
- */
-public class Asn1FieldInfo {
- private EnumType index;
- private int tagNo = -1; // Indicate a non-tagged field
- private boolean isImplicit;
- private Class<? extends Asn1Type> type;
-
- /**
- * Constructor for a tagged field, the tagNo being the same of index.
- * @param index
- * @param type
- * @param isImplicit
- */
- public Asn1FieldInfo(EnumType index, Class<? extends Asn1Type> type,
- boolean isImplicit) {
- this(index, index.getValue(), type, isImplicit);
- }
-
- /**
- * Constructor for a tagged field.
- * @param index
- * @param tagNo
- * @param type
- * @param isImplicit
- */
- public Asn1FieldInfo(EnumType index, int tagNo, Class<? extends Asn1Type> type,
- boolean isImplicit) {
- this.index = index;
- this.tagNo = tagNo;
- this.type = type;
- this.isImplicit = isImplicit;
- }
-
- /**
- * Constructor for a non-tagged field.
- * @param index
- * @param type
- */
- public Asn1FieldInfo(EnumType index, Class<? extends Asn1Type> type) {
- this.index = index;
- this.type = type;
- this.tagNo = -1; // Indicate a non-tagged field
- }
-
- public boolean isTagged() {
- return tagNo != -1;
- }
-
- public TaggingOption getTaggingOption() {
- if (isImplicit) {
- return TaggingOption.newImplicitContextSpecific(tagNo);
- } else {
- return TaggingOption.newExplicitContextSpecific(tagNo);
- }
- }
-
- public int getTagNo() {
- return tagNo;
- }
-
- public EnumType getIndex() {
- return index;
- }
-
- public boolean isImplicit() {
- return isImplicit;
- }
-
- public Asn1Type createFieldValue() {
- try {
- return type.newInstance();
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Bad field type provided, no default constructor?", e);
- }
- }
-
- public Tag getFieldTag() {
- Asn1Type fieldValue = createFieldValue();
- return fieldValue.tag();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/EnumType.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/EnumType.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/EnumType.java
deleted file mode 100644
index e0166ec..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/EnumType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.asn1;
-
-/**
- * A helper interface used by Asn1Enumerated.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public interface EnumType {
- /**
- * @return the Enum element value
- */
- int getValue();
-
- /**
- * @return The enum element name
- */
- String getName();
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/ExplicitField.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/ExplicitField.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/ExplicitField.java
deleted file mode 100644
index 7142dc0..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/ExplicitField.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.type.Asn1Type;
-
-/**
- * Representing an explicitly tagged field in a ASN1 collection or choice.
- */
-public class ExplicitField extends Asn1FieldInfo {
-
- /**
- * Constructor for an explicitly tagged field.
- * @param index
- * @param type
- */
- public ExplicitField(EnumType index, int tagNo, Class<? extends Asn1Type> type) {
- super(index, tagNo, type, false);
- }
-
- /**
- * Constructor for an explicitly tagged field, the tagNo being the same of index.
- * @param index
- * @param type
- */
- public ExplicitField(EnumType index, Class<? extends Asn1Type> type) {
- super(index, index.getValue(), type, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/ImplicitField.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/ImplicitField.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/ImplicitField.java
deleted file mode 100644
index f488847..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/ImplicitField.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.asn1;
-
-import org.apache.kerby.asn1.type.Asn1Type;
-
-/**
- * Representing an implicitly tagged field in a ASN1 collection or choice.
- */
-public class ImplicitField extends Asn1FieldInfo {
-
- /**
- * Constructor for an implicitly tagged field.
- * @param index
- * @param type
- */
- public ImplicitField(EnumType index, int tagNo, Class<? extends Asn1Type> type) {
- super(index, tagNo, type, true);
- }
-
- /**
- * Constructor for an implicitly tagged field, the tagNo being the same of index.
- * @param index
- * @param type
- */
- public ImplicitField(EnumType index, Class<? extends Asn1Type> type) {
- super(index, index.getValue(), type, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
deleted file mode 100644
index d248802..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * 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.asn1;
-
-/**
- * ASN1, a tagged system.
- */
-public class Tag {
- private int tagFlags = 0;
- private int tagNo = 0;
-
- public Tag(int tag) {
- this.tagFlags = tag & 0xE0;
- this.tagNo = tag & 0x1F;
- }
-
- public Tag(UniversalTag tag) {
- this.tagFlags = TagClass.UNIVERSAL.getValue();
- this.tagNo = tag.getValue();
- }
-
- public Tag(int tagFlags, int tagNo) {
- this.tagFlags = tagFlags & 0xE0;
- this.tagNo = tagNo;
- }
-
- public Tag(TagClass tagClass, int tagNo) {
- this.tagFlags = tagClass.getValue();
- this.tagNo = tagNo;
- }
-
- public Tag(Tag other) {
- this(other.tagFlags, other.tagNo);
- }
-
- public TagClass tagClass() {
- return TagClass.fromTag(tagFlags);
- }
-
- public void usePrimitive(boolean isPrimitive) {
- if (isPrimitive) {
- tagFlags &= ~0x20;
- } else {
- tagFlags |= 0x20;
- }
- }
-
- public boolean isPrimitive() {
- return (tagFlags & 0x20) == 0;
- }
-
- public int tagFlags() {
- return tagFlags;
- }
-
- public int tagNo() {
- return tagNo;
- }
-
- public UniversalTag universalTag() {
- if (isUniversal()) {
- return UniversalTag.fromValue(tagNo());
- }
- return UniversalTag.UNKNOWN;
- }
-
- public boolean isEOC() {
- return universalTag() == UniversalTag.EOC;
- }
-
- public boolean isNull() {
- return universalTag() == UniversalTag.NULL;
- }
-
- public boolean isUniversal() {
- return tagClass().isUniversal();
- }
-
- public boolean isAppSpecific() {
- return tagClass().isAppSpecific();
- }
-
- public boolean isContextSpecific() {
- return tagClass().isContextSpecific();
- }
-
- public boolean isSpecific() {
- return tagClass().isSpecific();
- }
-
- public byte tagByte() {
- int n = tagFlags | (tagNo < 0x1F ? tagNo : 0x1F);
- return (byte) (n & 0xFF);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Tag tag = (Tag) o;
-
- if (tagFlags != tag.tagFlags) {
- return false;
- }
-
- return tagNo == tag.tagNo;
- }
-
- @Override
- public int hashCode() {
- int result = tagFlags;
- result = 31 * result + tagNo;
- return result;
- }
-
- @Override
- public String toString() {
- return String.format("0x%02X", tagByte());
- }
-
- public String typeStr() {
- if (isUniversal()) {
- return universalTag().toStr();
- } else if (isAppSpecific()) {
- return "application [" + tagNo() + "]";
- } else {
- return "context [" + tagNo() + "]";
- }
- }
-
- public static Tag newAppTag(int tagNo) {
- return new Tag(TagClass.APPLICATION, tagNo);
- }
-
- public static Tag newCtxTag(int tagNo) {
- return new Tag(TagClass.CONTEXT_SPECIFIC, tagNo);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/TagClass.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TagClass.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/TagClass.java
deleted file mode 100644
index 8d02917..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TagClass.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * 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.asn1;
-
-/**
- * Tag class defined by the spec.
- */
-public enum TagClass {
- UNKNOWN(-1),
- UNIVERSAL(0x00),
- APPLICATION(0x40),
- CONTEXT_SPECIFIC(0x80),
- PRIVATE(0xC0);
-
- private int value;
-
- /**
- * The constructor given the value.
- * @param value
- */
- private TagClass(int value) {
- this.value = value;
- }
-
- /**
- * Get the tag class value.
- * @return value
- */
- public int getValue() {
- return value;
- }
-
- /**
- * Tell it's universal or not.
- * @return true if it's universal otherwise false
- */
- public boolean isUniversal() {
- return this == UNIVERSAL;
- }
-
- public boolean isAppSpecific() {
- return this == APPLICATION;
- }
-
- public boolean isContextSpecific() {
- return this == CONTEXT_SPECIFIC;
- }
-
- public boolean isSpecific() {
- return this == APPLICATION || this == CONTEXT_SPECIFIC;
- }
-
- /**
- * Converted from an integer
- * @param value The int value of tag class
- * @return tag class
- */
- public static TagClass fromValue(int value) {
- // Optimized by Emmanuel
- switch (value) {
- case 0x00:
- return TagClass.UNIVERSAL;
- case 0x40:
- return TagClass.APPLICATION;
- case 0x80:
- return TagClass.CONTEXT_SPECIFIC;
- case 0xC0:
- return TagClass.PRIVATE;
- default:
- return TagClass.UNKNOWN;
- }
- }
-
- /**
- * Converted from a tag value, which contains tag class info.
- * @param tag The int value of tag class
- * @return tag class
- */
- public static TagClass fromTag(int tag) {
- return fromValue(tag & 0xC0);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
deleted file mode 100644
index 154e1ab..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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.asn1;
-
-/**
- * Tagging option for tagging an ASN1 type.
- */
-public final class TaggingOption {
- /** The tag number. We limit it to an int, although it's theorically unlimited */
- private int tagNo;
-
- /** A flag set to TRUE when the tag is IMPLICIT */
- private boolean isImplicit;
-
- /** A flag set to TRUE when the tag is an APPLICATION tag */
- private boolean isAppSpecific;
-
- /**
- * Create an implicit application specific tagging option with tagNo.
- * @param tagNo The tag number
- * @return tagging option
- */
- public static TaggingOption newImplicitAppSpecific(int tagNo) {
- return new TaggingOption(tagNo, true, true);
- }
-
- /**
- * Create an explicit application specific tagging option with tagNo.
- * @param tagNo The tag number
- * @return tagging option
- */
- public static TaggingOption newExplicitAppSpecific(int tagNo) {
- return new TaggingOption(tagNo, false, true);
- }
-
- /**
- * Create an implicit context specific tagging option with tagNo.
- * @param tagNo The tag number
- * @return tagging option
- */
- public static TaggingOption newImplicitContextSpecific(int tagNo) {
- return new TaggingOption(tagNo, true, false);
- }
-
- /**
- * Create an explicit context specific tagging option with tagNo.
- * @param tagNo The tag number
- * @return tagging option
- */
- public static TaggingOption newExplicitContextSpecific(int tagNo) {
- return new TaggingOption(tagNo, false, false);
- }
-
- /**
- * The private constructor.
- * @param tagNo The tag number
- * @param isImplicit Implicit or not
- * @param isAppSpecific App specific or not
- */
- private TaggingOption(int tagNo, boolean isImplicit, boolean isAppSpecific) {
- this.tagNo = tagNo;
- this.isImplicit = isImplicit;
- this.isAppSpecific = isAppSpecific;
- }
-
- /**
- * Make tag giving it's tagged constructed.
- * @param isTaggedConstructed Tagged constructed or not
- * @return tag
- */
- public Tag getTag(boolean isTaggedConstructed) {
- boolean isConstructed = isImplicit ? isTaggedConstructed : true;
- TagClass tagClass = isAppSpecific ? TagClass.APPLICATION : TagClass.CONTEXT_SPECIFIC;
- int flags = tagClass.getValue() | (isConstructed ? 0x20 : 0x00);
-
- return new Tag(flags, tagNo);
- }
-
- /**
- * Get the tag number.
- * @return tag number
- */
- public int getTagNo() {
- return tagNo;
- }
-
- /**
- * Tell it's application specific or not.
- * @return true if it's application specific otherwise false
- */
- public boolean isAppSpecific() {
- return isAppSpecific;
- }
-
- /**
- * Tell it's implicit or not.
- * @return true if it's implicit otherwise false
- */
- public boolean isImplicit() {
- return isImplicit;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/UniversalTag.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/UniversalTag.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/UniversalTag.java
deleted file mode 100644
index 3fc5026..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/UniversalTag.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * 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.asn1;
-
-/**
- * An enumeration for every ASN.1 UNIVERSAL type.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public enum UniversalTag {
- UNKNOWN (-1),
- CHOICE (-2), // Only for internal using
- ANY (-3), // Only for internal using
- EOC (0), // End of content, use by BER
- BOOLEAN (0x01),
- INTEGER (0x02),
- BIT_STRING (0x03),
- OCTET_STRING (0x04),
- NULL (0x05),
- OBJECT_IDENTIFIER (0x06),
- OBJECT_DESCRIPTOR (0x07),
- EXTERNAL (0x08),
- REAL (0x09),
- ENUMERATED (0x0a),
- EMBEDDED_PDV (0x0b),
- UTF8_STRING (0x0c),
- RELATIVE_OID (0x0d),
- RESERVED_14 (0x0e),
- RESERVED_15 (0x0f),
- SEQUENCE (0x10),
- SEQUENCE_OF (0x10),
- SET (0x11),
- SET_OF (0x11),
- NUMERIC_STRING (0x12),
- PRINTABLE_STRING (0x13),
- T61_STRING (0x14),
- VIDEOTEX_STRING (0x15),
- IA5_STRING (0x16),
- UTC_TIME (0x17),
- GENERALIZED_TIME (0x18),
- GRAPHIC_STRING (0x19),
- VISIBLE_STRING (0x1a),
- GENERAL_STRING (0x1b),
- UNIVERSAL_STRING (0x1c),
- CHARACTER_STRING (0x1d),
- BMP_STRING (0x1e),
- RESERVED_31 (0x1f);
-
- /** The tag value */
- private int value;
-
- /**
- * Create an instance of this class
- */
- private UniversalTag(int value) {
- this.value = value;
- }
-
- /**
- * @return The associated tag value
- */
- public int getValue() {
- return value;
- }
-
- /**
- * Retrieve the UniversalTag associated with a given value
- * @param value The integer value
- * @return The associated UniversalTag
- */
- public static UniversalTag fromValue(int value) {
- switch (value) {
- case -2 : return CHOICE;
- case 0x00 : return EOC;
- case 0x01 : return BOOLEAN;
- case 0x02 : return INTEGER;
- case 0x03 : return BIT_STRING;
- case 0x04 : return OCTET_STRING;
- case 0x05 : return NULL;
- case 0x06 : return OBJECT_IDENTIFIER;
- case 0x07 : return OBJECT_DESCRIPTOR;
- case 0x08 : return EXTERNAL;
- case 0x09 : return REAL;
- case 0x0A : return ENUMERATED;
- case 0x0B : return EMBEDDED_PDV;
- case 0x0C : return UTF8_STRING;
- case 0x0D : return RELATIVE_OID;
- case 0x0E : return RESERVED_14;
- case 0x0F : return RESERVED_15;
- case 0x10 : return SEQUENCE;
- case 0x11 : return SET;
- case 0x12 : return NUMERIC_STRING;
- case 0x13 : return PRINTABLE_STRING;
- case 0x14 : return T61_STRING;
- case 0x15 : return VIDEOTEX_STRING;
- case 0x16 : return IA5_STRING;
- case 0x17 : return UTC_TIME;
- case 0x18 : return GENERALIZED_TIME;
- case 0x19 : return GRAPHIC_STRING;
- case 0x1A : return VISIBLE_STRING;
- case 0x1B : return GENERAL_STRING;
- case 0x1C : return UNIVERSAL_STRING;
- case 0x1D : return CHARACTER_STRING;
- case 0x1E : return BMP_STRING;
- case 0x1F : return RESERVED_31;
- default : return UNKNOWN;
- }
- }
-
- public String toStr() {
- String typeStr = toString();
- typeStr = typeStr.replace('_', ' ');
- return typeStr.toLowerCase();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
deleted file mode 100644
index d52b63f..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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.asn1.parse;
-
-import org.apache.kerby.asn1.Asn1Dumpable;
-import org.apache.kerby.asn1.Asn1Dumper;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ASN1 constructed types, mainly structured ones, but also some primitive ones.
- */
-public class Asn1Container
- extends Asn1ParseResult implements Asn1Dumpable {
-
- private List<Asn1ParseResult> children = new ArrayList<>();
-
- public Asn1Container(Asn1Header header, int bodyStart, ByteBuffer buffer) {
- super(header, bodyStart, buffer);
- }
-
- public List<Asn1ParseResult> getChildren() {
- return children;
- }
-
- public void addItem(Asn1ParseResult value) {
- children.add(value);
- }
-
- public void clear() {
- children.clear();
- }
-
- @Override
- public void dumpWith(Asn1Dumper dumper, int indents) {
- dumper.indent(indents).append(toString());
- if (children.size() > 0) {
- dumper.newLine();
- }
-
- int i = children.size();
- for (Asn1ParseResult aObj : children) {
- dumper.dumpParseResult(indents + 4, aObj);
- i--;
- if (i > 0) {
- dumper.newLine();
- }
- }
- }
-
- @Override
- public String toString() {
- String typeStr = tag().typeStr();
- typeStr += " ["
- + "tag=" + tag()
- + ", off=" + getOffset()
- + ", len=" + getHeaderLength() + "+" + getBodyLength()
- + (isDefinitiveLength() ? "" : "(undefined)")
- + "]";
- return typeStr;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1DerivedItem.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1DerivedItem.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1DerivedItem.java
deleted file mode 100644
index 41db80e..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1DerivedItem.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.asn1.parse;
-
-import org.apache.kerby.asn1.Tag;
-
-import java.nio.ByteBuffer;
-
-/**
- * Combine multiple parts in a container into a single item, for primitive types
- * that use constructed encoding.
- */
-public class Asn1DerivedItem extends Asn1Item {
-
- private final Asn1Container container;
- private final Tag newTag;
- private int newBodyLength;
- private ByteBuffer newBodyBuffer;
-
- public Asn1DerivedItem(Tag newTag, Asn1Container container) {
- super(container.getHeader(), container.getBodyStart(),
- container.getBuffer());
-
- this.newTag = newTag;
- this.container = container;
- this.newBodyLength = -1;
- }
-
- @Override
- public Tag tag() {
- return newTag;
- }
-
- private int computeBodyLength() {
- int totalLen = 0;
- for (Asn1ParseResult parseItem : container.getChildren()) {
- totalLen += parseItem.getBodyLength();
- }
-
- return totalLen;
- }
-
- private ByteBuffer makeBodyBuffer() {
- ByteBuffer tmpBuffer = ByteBuffer.allocate(getBodyLength());
- for (Asn1ParseResult parseItem : container.getChildren()) {
- tmpBuffer.put(parseItem.getBodyBuffer());
- }
- tmpBuffer.flip();
-
- return tmpBuffer;
- }
-
- @Override
- public ByteBuffer getBodyBuffer() {
- if (newBodyBuffer == null) {
- newBodyBuffer = makeBodyBuffer();
- }
- return newBodyBuffer;
- }
-
- @Override
- public int getBodyLength() {
- if (newBodyLength == -1) {
- newBodyLength = computeBodyLength();
- }
-
- return newBodyLength;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Header.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Header.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Header.java
deleted file mode 100644
index 8d90ac1..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Header.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.asn1.parse;
-
-import org.apache.kerby.asn1.Tag;
-
-public class Asn1Header {
- private Tag tag;
- private int length;
-
- public Asn1Header(Tag tag, int length) {
- this.tag = tag;
- this.length = length;
- }
-
- public Tag getTag() {
- return tag;
- }
-
- public int getLength() {
- return length;
- }
-
- public boolean isEOC() {
- return length == 0 && tag.isEOC();
- }
-
- public boolean isDefinitiveLength() {
- return length != -1;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
deleted file mode 100644
index 066d0aa..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.asn1.parse;
-
-import java.nio.ByteBuffer;
-
-public class Asn1Item extends Asn1ParseResult {
-
- public Asn1Item(Asn1Header header, int bodyStart, ByteBuffer buffer) {
- super(header, bodyStart, buffer);
- }
-
- @Override
- public String toString() {
- return simpleInfo();
- }
-}