harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r409618 - in /incubator/harmony/enhanced/classlib/trunk/modules: auth/src/main/java/common/javax/security/auth/x500/ crypto/src/main/java/javax/crypto/ security/src/main/java/common/java/security/cert/ security/src/main/java/common/org/apac...
Date Fri, 26 May 2006 09:58:57 GMT
Author: smishura
Date: Fri May 26 02:58:56 2006
New Revision: 409618

URL: http://svn.apache.org/viewvc?rev=409618&view=rev
Log:
Minor optimization

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/Name.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x501/NameTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java
  (contents, props changed)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java
Fri May 26 02:58:56 2006
@@ -133,7 +133,10 @@
      * @com.intel.drl.spec_ref
      */
     public byte[] getEncoded() {
-        return dn.getEncoded();
+        byte[] src = dn.getEncoded();
+        byte[] dst = new byte[src.length];
+        System.arraycopy(src, 0, dst, 0, dst.length);
+        return dst;
     }
 
     /**
@@ -168,7 +171,7 @@
      * @com.intel.drl.spec_ref
      */
     private void writeObject(ObjectOutputStream out) throws IOException {
-        out.writeObject(dn.getInternalEncoding());
+        out.writeObject(dn.getEncoded());
     }
 
     /**
@@ -177,6 +180,6 @@
     private void readObject(ObjectInputStream in) throws IOException,
             ClassNotFoundException {
 
-        dn = new Name((byte[]) in.readObject());
+        dn = (Name) Name.ASN1.decode((byte[]) in.readObject());
     }
 }

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/x500/X500Principal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java
Fri May 26 02:58:56 2006
@@ -70,7 +70,7 @@
         System.arraycopy(encoded, 0, this.encoded, 0, encoded.length);
         Object[] values;
             
-        values = (Object[])asn1.getValues(encoded);
+        values = (Object[])asn1.decode(encoded);
 
         AlgorithmIdentifier aId = (AlgorithmIdentifier) values[0];
 

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/EncryptedPrivateKeyInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.java
Fri May 26 02:58:56 2006
@@ -56,7 +56,7 @@
         
         // DER Decoding:
         Object[] decoded = (Object[]) org.apache.harmony.security.x509.PolicyQualifierInfo.ASN1
-                .getValues(this.encoded);
+                .decode(this.encoded);
         policyQualifierId = ObjectIdentifier.toString((int[]) decoded[0]);
         policyQualifier = (byte[]) decoded[1];
     }

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PolicyQualifierInfo.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=409618&r1=409617&r2=409618&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
Fri May 26 02:58:56 2006
@@ -153,34 +153,6 @@
         verify(decoder);
     }
 
-    public final Object getValues(byte[] encoded) throws IOException {
-
-        DerInputStream decoder = new DerInputStream(encoded);
-
-        if (!checkTag(decoder.tag)) {
-            throw new ASN1Exception("Mandatory value is missing at ["
-                    + decoder.tagOffset + "]. Expected " + this
-                    + " but encountered tag " + Integer.toHexString(tag));
-        }
-        verify(decoder);
-
-        return decoder.content;
-    }
-
-    public final Object getValues(InputStream in) throws IOException {
-
-        DerInputStream decoder = new DerInputStream(in);
-
-        if (!checkTag(decoder.tag)) {
-            throw new ASN1Exception("Mandatory value is missing at ["
-                    + decoder.tagOffset + "]. Expected " + this
-                    + " but encountered tag " + Integer.toHexString(tag));
-        }
-        verify(decoder);
-
-        return decoder.content;
-    }
-
     public final byte[] encode(Object object) {
 
         DerOutputStream out = new DerOutputStream(this, object);

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1Type.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/Name.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/Name.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/Name.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/Name.java
Fri May 26 02:58:56 2006
@@ -22,7 +22,6 @@
 package org.apache.harmony.security.x501;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -32,11 +31,9 @@
 
 import javax.security.auth.x500.X500Principal;
 
-import org.apache.harmony.security.asn1.ASN1Exception;
 import org.apache.harmony.security.asn1.ASN1SequenceOf;
 import org.apache.harmony.security.asn1.ASN1SetOf;
 import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.DerInputStream;
 import org.apache.harmony.security.x509.DNParser;
 
 
@@ -61,43 +58,6 @@
     private List rdn;
 
     /**
-     * Creates new <code>Name</code> instance from its DER encoding
-     * 
-     * @param encoding - ASN.1 DER encoding
-     * @throws IOException - if encoding is wrong
-     */
-    public Name(byte[] encoding) throws IOException {
-
-        DerInputStream in = new DerInputStream(encoding);
-
-        if (in.getEndOffset() != encoding.length) {
-            throw new IllegalArgumentException("Wrong content length");
-        }
-
-        ASN1.decode(in);
-
-        this.rdn = (List) in.content;
-    }
-
-    /**
-     * Creates new <code>Name</code> instance from its DER encoding obtained
-     * from <code>InputStream</code>
-     * 
-     * @param is
-     *            <code>InputStream</code> containing DER encoding
-     * @throws IOException
-     *             if encoding is wrong
-     */
-    public Name(InputStream is) throws IOException {
-
-        try {
-            this.rdn = (List) ASN1.getValues(is);
-        } catch (ASN1Exception e) {
-            throw new IOException(e.getMessage());
-        }
-    }
-
-    /**
      * Creates new <code>Name</code> instance
      * 
      * @param name - Name as String
@@ -244,17 +204,9 @@
     /**
      * Gets encoded form of DN
      * 
-     * @return encoding of DN
+     * @return return encoding, no copying is performed
      */
     public byte[] getEncoded() {
-        getInternalEncoding();
-        byte[] enc = new byte[encoded.length];
-        System.arraycopy(encoded, 0, enc, 0, encoded.length);
-        return enc;
-    }
-
-    // @return encoding, no copying is performed
-    public byte[] getInternalEncoding() {
         if (encoded == null) {
             encoded = ASN1.encode(this);
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x501/NameTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x501/NameTest.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x501/NameTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x501/NameTest.java
Fri May 26 02:58:56 2006
@@ -70,7 +70,7 @@
 
     public void testGetName1779() throws Exception {
 
-        Name principal = new Name(mess);
+        Name principal = (Name) Name.ASN1.decode(mess);
 
         String s = principal.getName("RFC1779");
 
@@ -82,7 +82,7 @@
     public void testStreamGetName1779() throws Exception {
         ByteArrayInputStream is = new ByteArrayInputStream(mess);
 
-        Name principal = new Name(is);
+        Name principal = (Name) Name.ASN1.decode(is);
 
         String s = principal.getName("RFC1779");
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java?rev=409618&r1=409617&r2=409618&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java
Fri May 26 02:58:56 2006
@@ -93,7 +93,7 @@
                     // Perform DER decoding:
                     Object[] decoded =
                         (Object[])org.apache.harmony.security.x509.
-                        PolicyQualifierInfo.ASN1.getValues(
+                        PolicyQualifierInfo.ASN1.decode(
                                 getDerEncoding(myIntValue));
                     // check OID value
                     assertEquals(this.getName()+"(OID)",
@@ -126,7 +126,7 @@
                     // Perform DER decoding:
                     Object[] decoded =
                         (Object[])org.apache.harmony.security.x509.
-                        PolicyQualifierInfo.ASN1.getValues(
+                        PolicyQualifierInfo.ASN1.decode(
                                 getDerInputStream(myIntValue));
                     // check OID value
                     assertEquals(this.getName()+"(OID)",

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/x509/PolicyQualifierInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message