You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/05/29 11:46:35 UTC
svn commit: r410067 - in
/incubator/harmony/enhanced/classlib/trunk/modules/security/src:
main/java/common/org/apache/harmony/security/asn1/
main/java/common/org/apache/harmony/security/x501/
test/java/common/org/apache/harmony/security/asn1/der/
Author: smishura
Date: Mon May 29 02:46:34 2006
New Revision: 410067
URL: http://svn.apache.org/viewvc?rev=410067&view=rev
Log:
Moving all tag related checks to input stream - removing ASN1Type.verify() method
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/BerInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java (contents, props changed)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java (contents, props changed)
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java Mon May 29 02:46:34 2006
@@ -75,6 +75,17 @@
return true; //all tags are OK
}
+ public Object decode(BerInputStream in) throws IOException {
+
+ // only read content, doesn't check it
+ in.readContent();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
+ }
+
public Object getDecodedObject(BerInputStream in) throws IOException {
byte[] bytesEncoded = new byte[in.offset - in.tagOffset];
System.arraycopy(in.buffer, in.tagOffset, bytesEncoded, 0,
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Any.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java Mon May 29 02:46:34 2006
@@ -65,15 +65,14 @@
//
//
- public final void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- //FIXME message: what about constr tag?
- throw new ASN1Exception("ASN.1 Bitstring is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + " but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
+
in.readBitString();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1BitString.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java Mon May 29 02:46:34 2006
@@ -65,14 +65,13 @@
//
//
- public final void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 Boolean is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + " but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readBoolean();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Boolean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java Mon May 29 02:46:34 2006
@@ -252,24 +252,6 @@
return false;
}
- public void verify(BerInputStream in) throws IOException {
-
- for (int index = 0; index < type.length; index++) {
- if (type[index].checkTag(in.tag)) {
-
- type[index].verify(in);
-
- // set index for getDecodedObject method
- in.choiceIndex = index;
-
- return;
- }
- }
- throw new ASN1Exception("Failed to decode ASN.1 choice type. "
- + " No alternatives were found for " + getClass().getName());
- }
-
-
public Object decode(BerInputStream in) throws IOException {
for (int index = 0; index < type.length; index++) {
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Choice.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java Mon May 29 02:46:34 2006
@@ -65,14 +65,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 Enumerated is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
+ public Object decode(BerInputStream in) throws IOException {
+ in.readEnumerated();
+
+ if (in.isVerify) {
+ return null;
}
- in.readInteger();
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Enumerated.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java Mon May 29 02:46:34 2006
@@ -69,19 +69,6 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception(
- "ASN.1 explicitly tagged type is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag)
- + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
- in.next();
- type.verify(in);
- }
-
public Object decode(BerInputStream in) throws IOException {
if (tag != in.tag) {
throw new ASN1Exception(
@@ -95,6 +82,9 @@
in.content = type.decode(in);
+ if (in.isVerify) {
+ return null;
+ }
return getDecodedObject(in);
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Explicit.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java Mon May 29 02:46:34 2006
@@ -70,15 +70,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- //FIXME message: what about constr tag?
- throw new ASN1Exception("ASN.1 GeneralizedTime is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readGeneralizedTime();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java Mon May 29 02:46:34 2006
@@ -86,24 +86,6 @@
return super.checkTag(tag);
}
- public void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- throw new ASN1Exception(
- "ASN.1 implicitly tagged type is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag)
- + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
-
- if (strTag > 0 && (in.tag & ASN1Constants.PC_CONSTRUCTED) != 0) {
- in.tag = strTag;
- } else {
- in.tag = type.tag;
- }
- type.verify(in);
- }
-
public Object decode(BerInputStream in) throws IOException {
if (!checkTag(in.tag)) {
throw new ASN1Exception(
@@ -122,6 +104,9 @@
in.content = type.decode(in);
+ if (in.isVerify) {
+ return null;
+ }
return getDecodedObject(in);
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Implicit.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java Mon May 29 02:46:34 2006
@@ -66,14 +66,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 Integer is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readInteger();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Integer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java Mon May 29 02:46:34 2006
@@ -65,15 +65,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- //FIXME message: what about constr tag?
- throw new ASN1Exception("ASN.1 Octetstring is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readOctetString();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OctetString.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java Mon May 29 02:46:34 2006
@@ -65,14 +65,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 ObjectIdentifier is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readOID();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Oid.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java Mon May 29 02:46:34 2006
@@ -44,7 +44,7 @@
this.pool = pool;
}
- public void verify(BerInputStream in) throws IOException {
+ public Object decode(BerInputStream in) throws IOException {
int[] oid = (int[]) in.get(key);
if (oid == null) {
@@ -52,19 +52,12 @@
}
AttributeType attr = (AttributeType) pool.get(oid);
- if (in.isVerify) {
- if (attr == null) {
- in.readContent(); //FIXME what about unknown oids???
- } else {
- attr.type.verify(in);
- }
+ if (attr == null || (!attr.type.checkTag(in.tag))) {
+ in.content = (byte[]) super.getDecodedObject(in);
} else {
- if (attr == null || (!attr.type.checkTag(in.tag))) {
- in.content = (byte[]) super.getDecodedObject(in);
- } else {
- in.content = attr.type.decode(in);
- }
+ in.content = attr.type.decode(in);
}
+ return in.content;
}
public Object getDecodedObject(BerInputStream in) throws IOException {
@@ -73,10 +66,15 @@
public static class Id extends ASN1Oid {
- public void verify(BerInputStream in) throws IOException {
- super.verify(in);
+ public Object decode(BerInputStream in) throws IOException {
+ Object oid = super.decode(in);
- in.put(this, super.getDecodedObject(in));
+ if (oid == null) {
+ in.put(this, super.getDecodedObject(in));
+ } else {
+ in.put(this, oid);
+ }
+ return oid;
}
public Object getDecodedObject(BerInputStream in) throws IOException {
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1OpenType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java Mon May 29 02:46:34 2006
@@ -44,14 +44,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 Sequence is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readSequence(this);
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Sequence.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java Mon May 29 02:46:34 2006
@@ -45,14 +45,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 SequenceOf is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readSequenceOf(this);
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SequenceOf.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java Mon May 29 02:46:34 2006
@@ -46,13 +46,13 @@
// Decode
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 Set is expected at [" + in.tagOffset
- + "]. Expected tag: " + Integer.toHexString(tag)
- + ", but encountered tag " + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readSet(this);
+
+ if(in.isVerify){
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Set.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java Mon May 29 02:46:34 2006
@@ -44,14 +44,13 @@
// Decode
//
- public void verify(BerInputStream in) throws IOException {
- if (tag != in.tag) {
- throw new ASN1Exception("ASN.1 SetOf is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readSetOf(this);
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1SetOf.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java Mon May 29 02:46:34 2006
@@ -95,7 +95,7 @@
public final boolean checkTag(int tag) {
return super.checkTag(tag) || tag == constructedTag;
}
- public void verify(BerInputStream in) throws IOException {
+ public Object decode(BerInputStream in) throws IOException {
if (!checkTag(in.tag)) {
//FIXME message: what about constr tag?
throw new ASN1Exception("ASN.1 String is expected at ["
@@ -104,6 +104,11 @@
+ Integer.toHexString(in.tag));
}
in.readString();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
/**
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java Mon May 29 02:46:34 2006
@@ -149,13 +149,13 @@
public final void verify(byte[] encoded) throws IOException {
DerInputStream decoder = new DerInputStream(encoded);
decoder.setVerify();
- verify(decoder);
+ decode(decoder);
}
public final void verify(InputStream in) throws IOException {
DerInputStream decoder = new DerInputStream(in);
decoder.setVerify();
- verify(decoder);
+ decode(decoder);
}
public final byte[] encode(Object object) {
@@ -176,25 +176,7 @@
* @param in - BER input stream
* @throws IOException - if an I/O error occurs or the end of the stream is reached
*/
- public Object decode(BerInputStream in) throws IOException {
- verify(in);
- return getDecodedObject(in);
- }
-
- /**
- * Verified ASN.1 type.
- *
- * @param in - BER input stream
- * @throws IOException - if an I/O error occurs or the end of the stream is reached
- */
- public void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- throw new ASN1Exception("Mandatory value is missing at ["
- + in.tagOffset + "]. Expected " + this
- + " but encountered tag " + Integer.toHexString(tag));
- }
- in.readContent();
- }
+ public abstract Object decode(BerInputStream in) throws IOException;
/**
* Tests whether provided tag is equal to ASN.1 type tag.
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java Mon May 29 02:46:34 2006
@@ -89,15 +89,13 @@
//
//
- public void verify(BerInputStream in) throws IOException {
- if (!checkTag(in.tag)) {
- //FIXME message: what about constr tag?
- throw new ASN1Exception("ASN.1 GeneralizedTime is expected at ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(tag) + ", but encountered tag "
- + Integer.toHexString(in.tag));
- }
+ public Object decode(BerInputStream in) throws IOException {
in.readUTCTime();
+
+ if (in.isVerify) {
+ return null;
+ }
+ return getDecodedObject(in);
}
//
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/BerInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/BerInputStream.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/BerInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/BerInputStream.java Mon May 29 02:46:34 2006
@@ -250,7 +250,7 @@
*/
public void readBitString() throws IOException {
- if ((tag & ASN1Constants.PC_CONSTRUCTED) == 0) {
+ if (tag == ASN1Constants.TAG_BITSTRING) {
if (length == 0) {
throw new ASN1Exception(
@@ -273,9 +273,56 @@
+ "]. For empty string unused bits MUST be 0");
}
- } else {
+ } else if (tag == (ASN1Constants.TAG_BITSTRING | ASN1Constants.PC_CONSTRUCTED)) {
throw new ASN1Exception("Decoding constructed ASN.1 bitstring "
+ " type is not provided");
+ } else {
+ throw new ASN1Exception(
+ "ASN.1 bitstring identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
+ }
+ }
+
+ /**
+ * Decodes ASN.1 Enumerated type
+ *
+ * @throws IOException - if error occured
+ */
+ public void readEnumerated() throws IOException {
+
+ if (tag != ASN1Constants.TAG_ENUM) {
+ throw new ASN1Exception(
+ "ASN.1 enumerated identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
+ }
+
+ //
+ // all checks are the same as for ASN.1 integer type
+ //
+
+ // check encoded length
+ if (length == 0) {
+ throw new ASN1Exception(
+ "ASN.1 enumerated: wrong length for identifier at ["
+ + tagOffset + ']');
+ }
+
+ readContent();
+
+ // check encoded content
+ if (length > 1) {
+
+ int bits = buffer[contentOffset] & 0xFF;
+ if (buffer[contentOffset + 1] < 0) {
+ bits += 0x100;
+ }
+
+ if (bits == 0 || bits == 0x1FF) {
+ throw new ASN1Exception(
+ "ASN.1 enumerated: wrong content at ["
+ + contentOffset
+ + "]. An integer MUST be encoded in minimum number of octets");
+ }
}
}
@@ -286,6 +333,12 @@
*/
public void readBoolean() throws IOException {
+ if (tag != ASN1Constants.TAG_BOOLEAN) {
+ throw new ASN1Exception("ASN.1 boolean identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
+
// check encoded length
if (length != 1) {
throw new ASN1Exception("Wrong length for ASN.1 boolean at ["
@@ -312,64 +365,72 @@
*/
public void readGeneralizedTime() throws IOException {
- if ((tag & ASN1Constants.PC_CONSTRUCTED) != 0) {
- throw new ASN1Exception(
- "Decoding constructed ASN.1 GeneralizedTime"
- + " type is not provided");
- }
-
- //FIXME: any other optimizations?
- readContent();
- //FIXME store string somewhere to allow a custom time type perform additional checks
+ if (tag == ASN1Constants.TAG_GENERALIZEDTIME) {
- // check syntax: the last char MUST be Z
- if (buffer[offset - 1] != 'Z') {
- // FIXME support only format that is acceptable for DER
- throw new ASN1Exception(
- "ASN.1 GeneralizedTime: encoded format is not implemented");
- }
+ // FIXME: any other optimizations?
+ readContent();
+ // FIXME store string somewhere to allow a custom time type perform
+ // additional checks
- // check syntax: MUST be YYYYMMDDHHMMSS[(./,)DDD]'Z'
- if (length != 15 && (length < 17 || length > 19)) // invalid length
- {
- throw new ASN1Exception(
- "ASN.1 GeneralizedTime wrongly encoded at ["
- + contentOffset + ']');
- }
+ // check syntax: the last char MUST be Z
+ if (buffer[offset - 1] != 'Z') {
+ // FIXME support only format that is acceptable for DER
+ throw new ASN1Exception(
+ "ASN.1 GeneralizedTime: encoded format is not implemented");
+ }
- // check content: milliseconds
- if (length > 16) {
- byte char14 = buffer[contentOffset + 14];
- if (char14 != '.' && char14 != ',') {
+ // check syntax: MUST be YYYYMMDDHHMMSS[(./,)DDD]'Z'
+ if (length != 15 && (length < 17 || length > 19)) // invalid
+ // length
+ {
throw new ASN1Exception(
"ASN.1 GeneralizedTime wrongly encoded at ["
+ contentOffset + ']');
}
- }
- if (times == null) {
- times = new int[7];
- }
- times[0] = strToInt(contentOffset, 4); //year
- times[1] = strToInt(contentOffset + 4, 2); //month
- times[2] = strToInt(contentOffset + 6, 2); //day
- times[3] = strToInt(contentOffset + 8, 2); //hour
- times[4] = strToInt(contentOffset + 10, 2); //minute
- times[5] = strToInt(contentOffset + 12, 2); //second
+ // check content: milliseconds
+ if (length > 16) {
+ byte char14 = buffer[contentOffset + 14];
+ if (char14 != '.' && char14 != ',') {
+ throw new ASN1Exception(
+ "ASN.1 GeneralizedTime wrongly encoded at ["
+ + contentOffset + ']');
+ }
+ }
+ if (times == null) {
+ times = new int[7];
+ }
+ times[0] = strToInt(contentOffset, 4); // year
+ times[1] = strToInt(contentOffset + 4, 2); // month
+ times[2] = strToInt(contentOffset + 6, 2); // day
+ times[3] = strToInt(contentOffset + 8, 2); // hour
+ times[4] = strToInt(contentOffset + 10, 2); // minute
+ times[5] = strToInt(contentOffset + 12, 2); // second
+
+ if (length > 16) {
+ // FIXME optimize me
+ times[6] = strToInt(contentOffset + 15, length - 16);
+
+ if (length == 17) {
+ times[6] = times[6] * 100;
+ } else if (length == 18) {
+ times[6] = times[6] * 10;
+ }
+ }
- if (length > 16) {
- //FIXME optimize me
- times[6] = strToInt(contentOffset + 15, length - 16);
+ // FIXME check all values for valid numbers!!!
+ } else if (tag == (ASN1Constants.TAG_GENERALIZEDTIME | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception(
+ "Decoding constructed ASN.1 GeneralizedTime"
+ + " type is not provided");
- if (length == 17) {
- times[6] = times[6] * 100;
- } else if (length == 18) {
- times[6] = times[6] * 10;
- }
+ } else {
+ throw new ASN1Exception(
+ "ASN.1 GeneralizedTime identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
}
-
- //FIXME check all values for valid numbers!!!
}
/**
@@ -379,57 +440,62 @@
*/
public void readUTCTime() throws IOException {
- if ((tag & ASN1Constants.PC_CONSTRUCTED) != 0) {
- // It is a string type and it can be encoded as primitive or constructed.
- throw new ASN1Exception("Decoding constructed ASN.1 UTCTime"
- + " type is not provided");
- }
+ if (tag == ASN1Constants.TAG_UTCTIME) {
- switch (length) {
- case ASN1UTCTime.UTC_HM:
- case ASN1UTCTime.UTC_HMS:
- break;
- case ASN1UTCTime.UTC_LOCAL_HM:
- case ASN1UTCTime.UTC_LOCAL_HMS:
- // FIXME only coordinated universal time formats are supported
- throw new ASN1Exception(
- "ASN.1 UTCTime: local time format is not supported.");
- default:
- throw new ASN1Exception(
- "ASN.1 UTCTime: wrong length, identifier at ["
- + tagOffset + ']');
- }
+ switch (length) {
+ case ASN1UTCTime.UTC_HM:
+ case ASN1UTCTime.UTC_HMS:
+ break;
+ case ASN1UTCTime.UTC_LOCAL_HM:
+ case ASN1UTCTime.UTC_LOCAL_HMS:
+ // FIXME only coordinated universal time formats are supported
+ throw new ASN1Exception(
+ "ASN.1 UTCTime: local time format is not supported.");
+ default:
+ throw new ASN1Exception(
+ "ASN.1 UTCTime: wrong length, identifier at ["
+ + tagOffset + ']');
+ }
- //FIXME: any other optimizations?
- readContent();
+ // FIXME: any other optimizations?
+ readContent();
- // FIXME store string somewhare to allow a custom time type perform additional checks
+ // FIXME store string somewhare to allow a custom time type perform
+ // additional checks
- // check syntax: the last char MUST be Z
- if (buffer[offset - 1] != 'Z') {
- throw new ASN1Exception("ASN.1 UTCTime wrongly encoded at ["
- + contentOffset + ']');
- }
+ // check syntax: the last char MUST be Z
+ if (buffer[offset - 1] != 'Z') {
+ throw new ASN1Exception("ASN.1 UTCTime wrongly encoded at ["
+ + contentOffset + ']');
+ }
- if (times == null) {
- times = new int[7];
- }
+ if (times == null) {
+ times = new int[7];
+ }
- times[0] = strToInt(contentOffset, 2) + 1900; //year
- if (Calendar.getInstance().get(Calendar.YEAR) - times[0] > 80) {
- times[0] += 100;
- }
+ times[0] = strToInt(contentOffset, 2) + 1900; // year
+ if (Calendar.getInstance().get(Calendar.YEAR) - times[0] > 80) {
+ times[0] += 100;
+ }
- times[1] = strToInt(contentOffset + 2, 2); //month
- times[2] = strToInt(contentOffset + 4, 2); //day
- times[3] = strToInt(contentOffset + 6, 2); //hour
- times[4] = strToInt(contentOffset + 8, 2); //minute
-
- if (length == ASN1UTCTime.UTC_HMS) {
- times[5] = strToInt(contentOffset + 10, 2); //second
- }
+ times[1] = strToInt(contentOffset + 2, 2); // month
+ times[2] = strToInt(contentOffset + 4, 2); // day
+ times[3] = strToInt(contentOffset + 6, 2); // hour
+ times[4] = strToInt(contentOffset + 8, 2); // minute
- //FIXME check all time values for valid numbers!!!
+ if (length == ASN1UTCTime.UTC_HMS) {
+ times[5] = strToInt(contentOffset + 10, 2); // second
+ }
+
+ // FIXME check all time values for valid numbers!!!
+ } else if (tag == (ASN1Constants.TAG_UTCTIME | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception("Decoding constructed ASN.1 UTCTime"
+ + " type is not provided");
+ } else {
+ throw new ASN1Exception("ASN.1 UTCTime identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
}
//TODO comment me
@@ -456,6 +522,12 @@
*/
public void readInteger() throws IOException {
+ if (tag != ASN1Constants.TAG_INTEGER) {
+ throw new ASN1Exception("ASN.1 integer identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
+
// check encoded length
if (length < 1) {
throw new ASN1Exception("Wrong length for ASN.1 integer at ["
@@ -487,13 +559,16 @@
*/
public void readOctetString() throws IOException {
- if ((tag & ASN1Constants.PC_CONSTRUCTED) == 0) {
+ if (tag == ASN1Constants.TAG_OCTETSTRING) {
readContent();
- } else {
+ } else if (tag == (ASN1Constants.TAG_OCTETSTRING | ASN1Constants.PC_CONSTRUCTED)) {
throw new ASN1Exception("Decoding constructed ASN.1 octet string "
+ " type is not provided");
+ } else {
+ throw new ASN1Exception(
+ "ASN.1 octetstring identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
}
-
}
//FIXME comment me
@@ -506,6 +581,12 @@
*/
public void readOID() throws IOException {
+ if (tag != ASN1Constants.TAG_OID) {
+ throw new ASN1Exception("ASN.1 OID identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
+
// check encoded length
if (length < 1) {
throw new ASN1Exception(
@@ -548,6 +629,12 @@
*/
public void readSequence(ASN1Sequence sequence) throws IOException {
+ if (tag != (ASN1Constants.TAG_SEQUENCE | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception(
+ "ASN.1 sequence identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
+ }
+
int begOffset = offset;
int endOffset = begOffset + length;
@@ -570,7 +657,7 @@
i++;
}
- type[i].verify(this);
+ type[i].decode(this);
}
// check the rest of components
@@ -634,6 +721,13 @@
* @throws IOException - if error occured
*/
public void readSequenceOf(ASN1SequenceOf sequenceOf) throws IOException {
+
+ if (tag != (ASN1Constants.TAG_SEQENCEOF | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception(
+ "ASN.1 sequenceOf identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
+ }
+
decodeValueCollection(sequenceOf);
}
@@ -644,6 +738,13 @@
* @throws IOException - if error occured
*/
public void readSet(ASN1Set set) throws IOException {
+
+ if (tag != (ASN1Constants.TAG_SET | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception("ASN.1 set identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
+
throw new ASN1Exception("Decoding ASN.1 Set type is not provided");
}
@@ -654,6 +755,13 @@
* @throws IOException - if error occured
*/
public void readSetOf(ASN1SetOf setOf) throws IOException {
+
+ if (tag != (ASN1Constants.TAG_SETOF | ASN1Constants.PC_CONSTRUCTED)) {
+ throw new ASN1Exception("ASN.1 setOf identifier is expected at ["
+ + tagOffset + "], but encountered: "
+ + Integer.toHexString(tag));
+ }
+
decodeValueCollection(setOf);
}
@@ -668,7 +776,7 @@
if (isVerify) {
while (endOffset > offset) {
next();
- type.verify(this);
+ type.decode(this);
}
} else {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java Mon May 29 02:46:34 2006
@@ -388,28 +388,6 @@
return true;
}
- public void verify(BerInputStream in) throws IOException {
-
- switch (in.tag) {
- case ASN1Constants.TAG_TELETEXSTRING:
- ASN1StringType.TELETEXSTRING.verify(in);
- break;
- case ASN1Constants.TAG_PRINTABLESTRING:
- ASN1StringType.PRINTABLESTRING.verify(in);
- break;
- case ASN1Constants.TAG_UNIVERSALSTRING:
- ASN1StringType.UNIVERSALSTRING.verify(in);
- break;
- case ASN1Constants.TAG_UTF8STRING:
- ASN1StringType.UTF8STRING.verify(in);
- break;
- case ASN1Constants.TAG_BMPSTRING:
- ASN1StringType.BMPSTRING.verify(in);
- break;
- }
- in.readContent();
- }
-
public Object decode(BerInputStream in) throws IOException {
// FIXME what about constr???
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java Mon May 29 02:46:34 2006
@@ -119,7 +119,7 @@
for (int i = 0; i < testcases.length; i++) {
DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
in.setVerify();
- seqVerify.verify(in);
+ seqVerify.decode(in);
}
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceOfTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java?rev=410067&r1=410066&r2=410067&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java Mon May 29 02:46:34 2006
@@ -189,7 +189,7 @@
for (int i = 0; i < testcases.length; i++) {
DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
in.setVerify();
- seqVerify.verify(in);
+ seqVerify.decode(in);
}
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/SequenceTest.java
------------------------------------------------------------------------------
svn:eol-style = native