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/06/09 10:11:57 UTC
svn commit: r412971 - in
/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1:
ASN1StringType.java BerInputStream.java DerInputStream.java
Author: smishura
Date: Fri Jun 9 01:11:55 2006
New Revision: 412971
URL: http://svn.apache.org/viewvc?rev=412971&view=rev
Log:
Move string indentifiers verification to decoder stream
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
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/asn1/DerInputStream.java
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=412971&r1=412970&r2=412971&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 Fri Jun 9 01:11:55 2006
@@ -101,14 +101,8 @@
}
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 ["
- + in.tagOffset + "]. Expected tag: "
- + Integer.toHexString(id) + " but encountered tag "
- + Integer.toHexString(in.tag));
- }
- in.readString();
+
+ in.readString(this);
if (in.isVerify) {
return null;
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=412971&r1=412970&r2=412971&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 Fri Jun 9 01:11:55 2006
@@ -804,14 +804,18 @@
*
* @throws IOException - if an I/O error occurs or the end of the stream is reached
*/
- public void readString() throws IOException {
+ public void readString(ASN1StringType type) throws IOException {
//FIXME check string content
- if ((tag & ASN1Constants.PC_CONSTRUCTED) == 0) {
+ if (tag == type.id) {
readContent();
- } else {
+ } else if (tag == type.constrId) {
throw new ASN1Exception("Decoding constructed ASN.1 string "
+ " type is not provided");
+ } else {
+ throw new ASN1Exception(
+ "ASN.1 string type identifier is expected at [" + tagOffset
+ + "], but encountered: " + Integer.toHexString(tag));
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/DerInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/DerInputStream.java?rev=412971&r1=412970&r2=412971&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/DerInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/DerInputStream.java Fri Jun 9 01:11:55 2006
@@ -146,13 +146,13 @@
/**
* @see org.apache.harmony.security.asn1.BerInputStream#readString()
*/
- public void readString() throws IOException {
+ public void readString(ASN1StringType type) throws IOException {
- if ((tag & ASN1Constants.PC_CONSTRUCTED) != 0) {
- throw new ASN1Exception(
- "DER: ASN.1 string type MUST have primitive encoding");
+ if (tag == type.constrId) {
+ throw new ASN1Exception("ASN.1 string: constructed identifier at ["
+ + tagOffset + "]. Not valid for DER.");
}
- super.readString();
+ super.readString(type);
}
/**