harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r451631 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth: ./ internal/kerberos/v5/
Date Sat, 30 Sep 2006 17:57:46 GMT
Author: ndbeyer
Date: Sat Sep 30 10:57:45 2006
New Revision: 451631

URL: http://svn.apache.org/viewvc?view=rev&rev=451631
Log:
Code cleanup -
* Add missing annotations
* Generification
* Add if/else braces
* Format code comments
* Remove unnecessary comments

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/DefaultSubjectPolicy.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/EncryptedData.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCRequest.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosErrorMessage.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosTime.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KrbClient.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/PrincipalName.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/DefaultSubjectPolicy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/DefaultSubjectPolicy.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/DefaultSubjectPolicy.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/DefaultSubjectPolicy.java
Sat Sep 30 10:57:45 2006
@@ -15,17 +15,13 @@
  *  limitations under the License.
  */
 
-/**
-* @author Stepan M. Mishura
-* @version $Revision$
-*/
-
 package org.apache.harmony.auth;
 
 import java.io.File;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.CodeSource;
+import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.Principal;
 import java.security.cert.Certificate;
@@ -33,6 +29,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Properties;
+import java.util.Set;
 
 import javax.security.auth.AuthPermission;
 import javax.security.auth.Policy;
@@ -42,14 +39,13 @@
 import org.apache.harmony.security.fortress.DefaultPolicyParser;
 import org.apache.harmony.security.fortress.PolicyUtils;
 
-
 /**
  * Default implementation for subject-based policy 
  */
+@SuppressWarnings("deprecation")
 public class DefaultSubjectPolicy extends Policy {
 
-    private static final AuthPermission REFRESH_POLICY = new AuthPermission(
-            "refreshPolicy"); //$NON-NLS-1$
+    private static final AuthPermission REFRESH_POLICY = new AuthPermission("refreshPolicy");
//$NON-NLS-1$
 
     // System property for dynamically added policy location.
     private static final String AUTH_SECURITY_POLICY = "java.security.auth.policy"; //$NON-NLS-1$
@@ -61,27 +57,28 @@
     private boolean isInitialized;
 
     // A set of PolicyEntries constituting this Policy.
-    private HashSet set;
+    private Set<PolicyEntry> set;
 
     // A specific parser for a particular policy file format.
     // The implementation of parse thread-safe, so static instance is used 
     private static final DefaultPolicyParser parser = new DefaultPolicyParser();
 
     // empty source object for getPermissions method
-    private static final CodeSource emptySource = new CodeSource(null,
-            (Certificate[]) null);
+    private static final CodeSource emptySource = new CodeSource(null, (Certificate[]) null);
 
     public DefaultSubjectPolicy() {
+        super();
         isInitialized = false;
     }
 
+    @Override
     public PermissionCollection getPermissions(Subject subject, CodeSource cs) {
         if (!isInitialized) {
             init();
         }
 
-        Collection pc = new HashSet();
-        Iterator it = set.iterator();
+        Collection<Permission> pc = new HashSet<Permission>();
+        Iterator<PolicyEntry> it = set.iterator();
 
         if (subject != null) {
             int size = subject.getPrincipals().size();
@@ -93,17 +90,16 @@
             }
 
             while (it.hasNext()) {
-                PolicyEntry ge = (PolicyEntry) it.next();
+                PolicyEntry ge = it.next();
                 if (ge.impliesCodeSource(cs) && ge.impliesPrincipals(p)) {
                     pc.addAll(ge.getPermissions());
                 }
             }
         }
-        // TODO what about caching returned objects??? 
-
         return PolicyUtils.toPermissionCollection(pc);
     }
 
+    @Override
     public void refresh() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
@@ -114,23 +110,19 @@
 
     private synchronized void init() {
 
-        set = new HashSet();
+        set = new HashSet<PolicyEntry>();
 
-        Properties system = new Properties((Properties) AccessController
+        Properties system = new Properties(AccessController
                 .doPrivileged(new PolicyUtils.SystemKit()));
         system.setProperty("/", File.separator); //$NON-NLS-1$
-        URL[] policyLocations = PolicyUtils.getPolicyURLs(system,
-                AUTH_SECURITY_POLICY, POLICY_URL_PREFIX);
+        URL[] policyLocations = PolicyUtils.getPolicyURLs(system, AUTH_SECURITY_POLICY,
+                POLICY_URL_PREFIX);
 
-        for (int i = 0; i < policyLocations.length; i++) {
+        for (URL url : policyLocations) {
             try {
-                //TODO debug log
-                //System.err.println("Parsing policy file: " + policyLocations[i]);
-                set.addAll(parser.parse(policyLocations[i], system));
+                set.addAll(parser.parse(url, system));
             } catch (Exception e) {
-                // TODO log warning
-                //System.err.println("Ignoring policy file: " 
-                //                 + policyLocations[i] + ". Reason:\n"+ e);
+                e.printStackTrace();
             }
         }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/EncryptedData.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/EncryptedData.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/EncryptedData.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/EncryptedData.java
Sat Sep 30 10:57:45 2006
@@ -31,8 +31,6 @@
 import org.apache.harmony.security.asn1.BerInputStream;
 
 /**
- * TODO comment me
- * 
  * @see http://www.ietf.org/rfc/rfc4120.txt
  */
 public class EncryptedData {
@@ -82,49 +80,50 @@
 
         IvParameterSpec initCipherState;
         switch (etype) {
-        case DES_CBC_CRC:
-            offset = 12;// confounder(8)+CRC-32 checksum(4)
-            // copy of original key
-            initCipherState = new IvParameterSpec(key.getEncoded());
-            break;
-        case DES_CBC_MD4:
-        case DES_CBC_MD5:
-            offset = 24;// confounder(8)+ MD4/5 checksum(16)
-            // all-zero
-            initCipherState = new IvParameterSpec(new byte[] { 0, 0, 0, 0, 0,
-                    0, 0, 0, });
-            break;
-        default:
-            throw new RuntimeException();//FIXME not implemented yet
+            case DES_CBC_CRC:
+                offset = 12;// confounder(8)+CRC-32 checksum(4)
+                // copy of original key
+                initCipherState = new IvParameterSpec(key.getEncoded());
+                break;
+            case DES_CBC_MD4:
+            case DES_CBC_MD5:
+                offset = 24;// confounder(8)+ MD4/5 checksum(16)
+                // all-zero
+                initCipherState = new IvParameterSpec(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0,
});
+                break;
+            default:
+                throw new RuntimeException();//FIXME not implemented yet
         }
 
         try {
             Cipher dcipher = Cipher.getInstance("DES/CBC/NoPadding");
-            
+
             dcipher.init(Cipher.DECRYPT_MODE, key, initCipherState);
-            
+
             byte[] tmp = dcipher.doFinal(cipher);
-            
+
             // TODO: verify checksum
 
             // cat out: confounder and checksum bytes
             // TODO: how to do the same for padding bytes?
-            byte[] result = new byte[tmp.length-offset];
+            byte[] result = new byte[tmp.length - offset];
             System.arraycopy(tmp, offset, result, 0, result.length);
-            
+
             return result;
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
 
-    //
-    // EncryptedData   ::= SEQUENCE {
-    //    etype   [0] Int32 -- EncryptionType --,
-    //    kvno    [1] UInt32 OPTIONAL,
-    //    cipher  [2] OCTET STRING -- ciphertext
-    // }
-    //
+    /**
+     * <pre>
+     * EncryptedData   ::= SEQUENCE {
+     *      etype   [0] Int32 -- EncryptionType --,
+     *      kvno    [1] UInt32 OPTIONAL,
+     *      cipher  [2] OCTET STRING -- ciphertext
+     *      }
+     * </pre>
+     */
     static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
     // TODO should we define Int32 type?
             new ASN1Explicit(0, ASN1Integer.getInstance()), // etype
@@ -136,14 +135,14 @@
             setOptional(1); // kvno
         }
 
+        @Override
         protected Object getDecodedObject(BerInputStream in) throws IOException {
-
             Object[] values = (Object[]) in.content;
-
-            return new EncryptedData(ASN1Integer.toIntValue(values[0]),
-                    ASN1Integer.toIntValue(values[1]), (byte[]) values[2]);
+            return new EncryptedData(ASN1Integer.toIntValue(values[0]), ASN1Integer
+                    .toIntValue(values[1]), (byte[]) values[2]);
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
             throw new RuntimeException(); //FIXME message
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
Sat Sep 30 10:57:45 2006
@@ -30,8 +30,6 @@
 import org.apache.harmony.security.asn1.BerInputStream;
 
 /**
- * TODO comment me
- * 
  * @see http://www.ietf.org/rfc/rfc4120.txt
  */
 public class KDCReply {
@@ -57,8 +55,8 @@
 
     private final EncryptedData encPart;
 
-    private KDCReply(int msgType, String crealm, PrincipalName cname,
-            Ticket ticket, EncryptedData encPart) {
+    private KDCReply(int msgType, String crealm, PrincipalName cname, Ticket ticket,
+            EncryptedData encPart) {
         this.msgType = msgType;
         this.cname = cname;
         this.crealm = crealm;
@@ -86,20 +84,22 @@
         return encPart;
     }
 
-    //
-    // KDC-REP         ::= SEQUENCE {
-    //    pvno            [0] INTEGER (5),
-    //    msg-type        [1] INTEGER (11 -- AS -- | 13 -- TGS --),
-    //    padata          [2] SEQUENCE OF PA-DATA OPTIONAL
-    //                            -- NOTE: not empty --,
-    //    crealm          [3] Realm,
-    //    cname           [4] PrincipalName,
-    //    ticket          [5] Ticket,
-    //    enc-part        [6] EncryptedData
-    //                            -- EncASRepPart or EncTGSRepPart,
-    //                            -- as appropriate
-    // }
-    //
+    /**
+     * <pre>
+     *  KDC-REP         ::= SEQUENCE {
+     *       pvno            [0] INTEGER (5),
+     *       msg-type        [1] INTEGER (11 -- AS -- | 13 -- TGS --),
+     *       padata          [2] SEQUENCE OF PA-DATA OPTIONAL
+     *       -- NOTE: not empty --,
+     *       crealm          [3] Realm,
+     *       cname           [4] PrincipalName,
+     *       ticket          [5] Ticket,
+     *       enc-part        [6] EncryptedData
+     *       -- EncASRepPart or EncTGSRepPart,
+     *       -- as appropriate
+     *       }
+     * </pre>
+     */
     static final ASN1Sequence KDC_REP_ASN1 = new ASN1Sequence(new ASN1Type[] {
             new ASN1Explicit(0, ASN1Integer.getInstance()), // pvno
             new ASN1Explicit(1, ASN1Integer.getInstance()), // msg-type
@@ -107,24 +107,25 @@
             // TODO should we define Realm type?
             new ASN1Explicit(3, ASN1StringType.GENERALSTRING), // crealm
             new ASN1Explicit(4, PrincipalName.ASN1), // cname
-            new ASN1Explicit(5, Ticket.TICKET_ASN1), // ticket 
-            new ASN1Explicit(6, EncryptedData.ASN1), // enc-part 
+            new ASN1Explicit(5, Ticket.TICKET_ASN1), // ticket
+            new ASN1Explicit(6, EncryptedData.ASN1), // enc-part
     }) {
         {
             setOptional(2); // padata
         }
 
+        @Override
         protected Object getDecodedObject(BerInputStream in) throws IOException {
 
             Object[] values = (Object[]) in.content;
 
-            return new KDCReply(ASN1Integer.toIntValue(values[1]),
-                    (String) values[3], (PrincipalName) values[4],
-                    (Ticket) values[5], (EncryptedData) values[6]);
+            return new KDCReply(ASN1Integer.toIntValue(values[1]), (String) values[3],
+                    (PrincipalName) values[4], (Ticket) values[5], (EncryptedData) values[6]);
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
-            throw new RuntimeException(); //FIXME message
+            throw new RuntimeException(); // FIXME message
         }
     };
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCRequest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCRequest.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCRequest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCRequest.java
Sat Sep 30 10:57:45 2006
@@ -35,8 +35,6 @@
 import org.apache.harmony.security.asn1.ASN1Type;
 
 /**
- * TODO comment me
- * 
  * @see http://www.ietf.org/rfc/rfc3961.txt
  * @see http://www.ietf.org/rfc/rfc4120.txt
  */
@@ -61,22 +59,20 @@
 
     private final PrincipalName sname;
 
-    KDCRequest(int msgType, PrincipalName cname, String realm,
-            PrincipalName sname) {
-
+    KDCRequest(int msgType, PrincipalName cname, String realm, PrincipalName sname) {
+        super();
         this.msgType = msgType;
         this.cname = cname;
         this.realm = realm;
         this.sname = sname;
     }
 
-    public DatagramSocket send(InetAddress address, int port)
-            throws IOException {
+    public DatagramSocket send(InetAddress address, int port) throws IOException {
 
         if (msgType != AS_REQ) {
             throw new RuntimeException("Not implemented");
         }
-        
+
         byte[] enc = AS_REQ_ASN1.encode(this);
 
         DatagramPacket req = new DatagramPacket(enc, enc.length, address, port);
@@ -87,45 +83,47 @@
         return socket;
     }
 
-    // KDC-REQ-BODY    ::= SEQUENCE {
-    //     kdc-options             [0] KDCOptions,
-    //     cname                   [1] PrincipalName OPTIONAL
-    //                                 -- Used only in AS-REQ --,
-    //     realm                   [2] Realm
-    //                                 -- Server's realm
-    //                                 -- Also client's in AS-REQ --,
-    //     sname                   [3] PrincipalName OPTIONAL,
-    //     from                    [4] KerberosTime OPTIONAL,
-    //     till                    [5] KerberosTime,
-    //     rtime                   [6] KerberosTime OPTIONAL,
-    //     nonce                   [7] UInt32,
-    //     etype                   [8] SEQUENCE OF Int32 -- EncryptionType
-    //                                 -- in preference order --,
-    //     addresses               [9] HostAddresses OPTIONAL,
-    //     enc-authorization-data  [10] EncryptedData OPTIONAL
-    //                                 -- AuthorizationData --,
-    //     additional-tickets      [11] SEQUENCE OF Ticket OPTIONAL
-    //                                    -- NOTE: not empty
-    // }
-
-    private static final ASN1Sequence KDC_REQ_BODY = new ASN1Sequence(
-            new ASN1Type[] {
-                    new ASN1Explicit(0, ASN1Any.getInstance()), //TODO: ignored
-                    new ASN1Explicit(1, PrincipalName.ASN1),
-                    // TODO should we define Realm type?
-                    new ASN1Explicit(2, ASN1StringType.GENERALSTRING),
-                    new ASN1Explicit(3, PrincipalName.ASN1),
-                    new ASN1Explicit(4, ASN1Any.getInstance()), //TODO: ignored
-                    new ASN1Explicit(5, KerberosTime.getASN1()),
-                    new ASN1Explicit(6, ASN1Any.getInstance()), //TODO: ignored
-                    new ASN1Explicit(7, ASN1Integer.getInstance()),
-                    new ASN1Explicit(8, new ASN1SequenceOf(ASN1Integer
-                            .getInstance())),
-                    new ASN1Explicit(9, ASN1Any.getInstance()), //TODO: ignored
-                    new ASN1Explicit(10, ASN1Any.getInstance()), //TODO: ignored
-                    new ASN1Explicit(11, ASN1Any.getInstance()), //TODO: ignored
+    /**
+     * 
+     * <pre>
+     * KDC-REQ-BODY    ::= SEQUENCE {
+     *      kdc-options             [0] KDCOptions,
+     *      cname                   [1] PrincipalName OPTIONAL
+     *      -- Used only in AS-REQ --,
+     *      realm                   [2] Realm
+     *      -- Server's realm
+     *      -- Also client's in AS-REQ --,
+     *      sname                   [3] PrincipalName OPTIONAL,
+     *      from                    [4] KerberosTime OPTIONAL,
+     *      till                    [5] KerberosTime,
+     *      rtime                   [6] KerberosTime OPTIONAL,
+     *      nonce                   [7] UInt32,
+     *      etype                   [8] SEQUENCE OF Int32 -- EncryptionType
+     *      -- in preference order --,
+     *      addresses               [9] HostAddresses OPTIONAL,
+     *      enc-authorization-data  [10] EncryptedData OPTIONAL
+     *      -- AuthorizationData --,
+     *      additional-tickets      [11] SEQUENCE OF Ticket OPTIONAL
+     *      -- NOTE: not empty
+     *      }
+     * </pre>
+     */
+    private static final ASN1Sequence KDC_REQ_BODY = new ASN1Sequence(new ASN1Type[] {
+            new ASN1Explicit(0, ASN1Any.getInstance()), // TODO: ignored
+            new ASN1Explicit(1, PrincipalName.ASN1),
+            // TODO should we define Realm type?
+            new ASN1Explicit(2, ASN1StringType.GENERALSTRING),
+            new ASN1Explicit(3, PrincipalName.ASN1),
+            new ASN1Explicit(4, ASN1Any.getInstance()), //TODO: ignored
+            new ASN1Explicit(5, KerberosTime.getASN1()),
+            new ASN1Explicit(6, ASN1Any.getInstance()), //TODO: ignored
+            new ASN1Explicit(7, ASN1Integer.getInstance()),
+            new ASN1Explicit(8, new ASN1SequenceOf(ASN1Integer.getInstance())),
+            new ASN1Explicit(9, ASN1Any.getInstance()), //TODO: ignored
+            new ASN1Explicit(10, ASN1Any.getInstance()), //TODO: ignored
+            new ASN1Explicit(11, ASN1Any.getInstance()), //TODO: ignored
 
-            }) {
+    }) {
         {
             setOptional(1); // cname
             setOptional(3); // sname
@@ -136,14 +134,15 @@
             setOptional(11); // additional-tickets
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
             KDCRequest request = (KDCRequest) object;
 
             // FIXME: hardcoded - no KDCoptions are set
             // note: number of bits should be >= 32
             // (see RFC 4120, 5.2.8. KerberosFlags)
-            values[0] = new byte[] { (byte) 0x03, (byte) 0x05, (byte) 0x00,
-                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, };
+            values[0] = new byte[] { (byte) 0x03, (byte) 0x05, (byte) 0x00, (byte) 0x00,
+                    (byte) 0x00, (byte) 0x00, (byte) 0x00, };
 
             values[1] = request.cname;
             values[2] = request.realm;
@@ -160,7 +159,7 @@
             values[7] = BigInteger.valueOf(0).toByteArray();
 
             // etype FIXME
-            ArrayList list = new ArrayList();
+            ArrayList<byte[]> list = new ArrayList<byte[]>();
 
             // see RFC 3961 (Section 8)
             list.add(BigInteger.valueOf(1).toByteArray());// des-cbc-crc
@@ -174,16 +173,18 @@
         }
     };
 
-    //
-    // KDC-REQ         ::= SEQUENCE {
-    //     -- NOTE: first tag is [1], not [0]
-    //     pvno            [1] INTEGER (5) ,
-    //     msg-type        [2] INTEGER (10 -- AS -- | 12 -- TGS --),
-    //     padata          [3] SEQUENCE OF PA-DATA OPTIONAL
-    //                         -- NOTE: not empty --,
-    //     req-body        [4] KDC-REQ-BODY
-    // }
-    //
+    /**
+     * <pre>
+     * KDC-REQ         ::= SEQUENCE {
+     *      -- NOTE: first tag is [1], not [0]
+     *      pvno            [1] INTEGER (5) ,
+     *      msg-type        [2] INTEGER (10 -- AS -- | 12 -- TGS --),
+     *      padata          [3] SEQUENCE OF PA-DATA OPTIONAL
+     *      -- NOTE: not empty --,
+     *      req-body        [4] KDC-REQ-BODY
+     *      }
+     * </pre>
+     */
     static final ASN1Sequence KDC_REQ_ASN1 = new ASN1Sequence(new ASN1Type[] {
     // pvno [1] INTEGER (5)
             new ASN1Explicit(1, ASN1Integer.getInstance()),
@@ -197,6 +198,7 @@
             setOptional(2); // padata
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
             KDCRequest request = (KDCRequest) object;
 
@@ -207,6 +209,6 @@
         }
     };
 
-    static final ASN1Explicit AS_REQ_ASN1 = new ASN1Explicit(
-            ASN1Constants.CLASS_APPLICATION, AS_REQ, KDC_REQ_ASN1);
+    static final ASN1Explicit AS_REQ_ASN1 = new ASN1Explicit(ASN1Constants.CLASS_APPLICATION,
+            AS_REQ, KDC_REQ_ASN1);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosErrorMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosErrorMessage.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosErrorMessage.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosErrorMessage.java
Sat Sep 30 10:57:45 2006
@@ -57,12 +57,11 @@
     private PrincipalName sname;
 
     private String etext;
-    
+
     public KerberosErrorMessage() {
     }
 
-    public static KerberosErrorMessage decode(DerInputStream in)
-            throws IOException {
+    public static KerberosErrorMessage decode(DerInputStream in) throws IOException {
 
         return (KerberosErrorMessage) ASN1.decode(in);
     }
@@ -107,28 +106,28 @@
         return etext;
     }
 
-    private static final ASN1Sequence KRB_ERROR = new ASN1Sequence(
-            new ASN1Type[] { new ASN1Explicit(0, ASN1Any.getInstance()), // TODO:ignored
-                    new ASN1Explicit(1, ASN1Any.getInstance()), // TODO: ignored
-                    new ASN1Explicit(2, KerberosTime.getASN1()),// ctime
-                    // TODO should we define Microseconds type?
-                    new ASN1Explicit(3, ASN1Integer.getInstance()), // cusec
-                    new ASN1Explicit(4, KerberosTime.getASN1()),// stime
-                    // TODO should we define Microseconds type?
-                    new ASN1Explicit(5, ASN1Integer.getInstance()), // susec
-                    // TODO should we define Int32 type?
-                    new ASN1Explicit(6, ASN1Integer.getInstance()),// error-code
-                    // TODO should we define Realm type?
-                    new ASN1Explicit(7, ASN1StringType.GENERALSTRING),// crealm
-                    new ASN1Explicit(8, PrincipalName.ASN1),// cname
-                    // TODO should we define Realm type?
-                    new ASN1Explicit(9, ASN1StringType.GENERALSTRING),// realm
-                    new ASN1Explicit(10, PrincipalName.ASN1),// sname
-                    // TODO should we define KerberosString type?
-                    new ASN1Explicit(11, ASN1StringType.GENERALSTRING),// e-text
-                    // TODO: ignored
-                    new ASN1Explicit(12, ASN1OctetString.getInstance()),// e-data
-            }) {
+    private static final ASN1Sequence KRB_ERROR = new ASN1Sequence(new ASN1Type[] {
+            new ASN1Explicit(0, ASN1Any.getInstance()), // TODO:ignored
+            new ASN1Explicit(1, ASN1Any.getInstance()), // TODO: ignored
+            new ASN1Explicit(2, KerberosTime.getASN1()),// ctime
+            // TODO should we define Microseconds type?
+            new ASN1Explicit(3, ASN1Integer.getInstance()), // cusec
+            new ASN1Explicit(4, KerberosTime.getASN1()),// stime
+            // TODO should we define Microseconds type?
+            new ASN1Explicit(5, ASN1Integer.getInstance()), // susec
+            // TODO should we define Int32 type?
+            new ASN1Explicit(6, ASN1Integer.getInstance()),// error-code
+            // TODO should we define Realm type?
+            new ASN1Explicit(7, ASN1StringType.GENERALSTRING),// crealm
+            new ASN1Explicit(8, PrincipalName.ASN1),// cname
+            // TODO should we define Realm type?
+            new ASN1Explicit(9, ASN1StringType.GENERALSTRING),// realm
+            new ASN1Explicit(10, PrincipalName.ASN1),// sname
+            // TODO should we define KerberosString type?
+            new ASN1Explicit(11, ASN1StringType.GENERALSTRING),// e-text
+            // TODO: ignored
+            new ASN1Explicit(12, ASN1OctetString.getInstance()),// e-data
+    }) {
         {
             setOptional(2);// ctime
             setOptional(3);// cusec
@@ -138,6 +137,7 @@
             setOptional(12);// e-data
         }
 
+        @Override
         protected Object getDecodedObject(BerInputStream in) throws IOException {
 
             Object[] values = (Object[]) in.content;
@@ -160,12 +160,12 @@
             return message;
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
-            throw new RuntimeException(
-                    "KerberosErrorMessage encoder is not implemented");
+            throw new RuntimeException("KerberosErrorMessage encoder is not implemented");
         }
     };
 
-    public static final ASN1Explicit ASN1 = new ASN1Explicit(
-            ASN1Constants.CLASS_APPLICATION, 30, KRB_ERROR);
+    public static final ASN1Explicit ASN1 = new ASN1Explicit(ASN1Constants.CLASS_APPLICATION,
+            30, KRB_ERROR);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosTime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosTime.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosTime.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KerberosTime.java
Sat Sep 30 10:57:45 2006
@@ -28,11 +28,11 @@
 public class KerberosTime {
 
     private KerberosTime() {
+        super();
     }
 
     // TODO: should we create encoder that handles fractional seconds?
-    private static final ASN1GeneralizedTime ASN1 = ASN1GeneralizedTime
-            .getInstance();
+    private static final ASN1GeneralizedTime ASN1 = ASN1GeneralizedTime.getInstance();
 
     /**
      * KerberosTime is defined as GeneralizedTime with no fractional seconds

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KrbClient.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KrbClient.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KrbClient.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KrbClient.java
Sat Sep 30 10:57:45 2006
@@ -27,8 +27,6 @@
 import org.apache.harmony.security.asn1.DerInputStream;
 
 /**
- * TODO comment me
- * 
  * @see http://www.ietf.org/rfc/rfc4120.txt
  */
 public class KrbClient {
@@ -42,21 +40,16 @@
     /**
      * Get credentials from Authentication Service.
      * 
-     * @param address -
-     *            service host
-     * @param port -
-     *            service port
-     * @param cname -
-     *            client's principal identifier
-     * @param realm -
-     *            client's realm
+     * @param address - service host
+     * @param port - service port
+     * @param cname - client's principal identifier
+     * @param realm - client's realm
      * @return - ticket
      */
-    public static Ticket doAS(InetAddress address, int port,
-            PrincipalName cname, String realm, PrincipalName sname) {
+    public static Ticket doAS(InetAddress address, int port, PrincipalName cname, String
realm,
+            PrincipalName sname) {
 
-        KDCRequest request = new KDCRequest(KDCRequest.AS_REQ, cname, realm,
-                sname);
+        KDCRequest request = new KDCRequest(KDCRequest.AS_REQ, cname, realm, sname);
 
         try {
             DatagramSocket socket = request.send(address, port);
@@ -81,14 +74,13 @@
             } else if (in.tag == KerberosErrorMessage.ASN1.constrId) {
                 KerberosErrorMessage errMsg = KerberosErrorMessage.decode(in);
                 // auth.52=Error code: {0}
-                throw new RuntimeException(Messages.getString(
-                        "auth.52", errMsg.getErrorCode())); //$NON-NLS-1$
+                throw new RuntimeException(Messages.getString("auth.52", errMsg.getErrorCode()));
//$NON-NLS-1$
             } else {
                 new RuntimeException(); //FIXME
             }
 
         } catch (IOException e) {
-            new RuntimeException(); //FIXME 
+            new RuntimeException(e); //FIXME 
         }
 
         return null;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/PrincipalName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/PrincipalName.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/PrincipalName.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/PrincipalName.java
Sat Sep 30 10:57:45 2006
@@ -72,6 +72,7 @@
         return name;
     }
 
+    @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
@@ -86,10 +87,12 @@
         return type == that.type && Arrays.equals(that.name, name);
     }
 
+    @Override
     public int hashCode() {
         return type + Arrays.hashCode(name);
     }
 
+    @Override
     public String toString() {
         StringBuilder buf = new StringBuilder("Name: "); //$NON-NLS-1$
 
@@ -110,9 +113,9 @@
      */
     public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
             new ASN1Explicit(0, ASN1Integer.getInstance()),
-            new ASN1Explicit(1,
-                    new ASN1SequenceOf(ASN1StringType.GENERALSTRING)), }) {
+            new ASN1Explicit(1, new ASN1SequenceOf(ASN1StringType.GENERALSTRING)), }) {
 
+        @Override
         protected Object getDecodedObject(BerInputStream in) throws IOException {
 
             Object[] values = (Object[]) in.content;
@@ -120,13 +123,12 @@
             int type = ASN1Integer.toIntValue(values[0]);
 
             // TODO: list to array conversion should be done by framework
-            List list = (List) values[1];
-            String[] name = new String[list.size()];
-            list.toArray(name);
-
+            List<?> list = (List<?>) values[1];
+            String[] name = list.toArray(new String[list.size()]);
             return new PrincipalName(type, name);
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
 
             PrincipalName name = (PrincipalName) object;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java?view=diff&rev=451631&r1=451630&r2=451631
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
Sat Sep 30 10:57:45 2006
@@ -29,8 +29,6 @@
 import org.apache.harmony.security.asn1.BerInputStream;
 
 /**
- * TODO comment me
- * 
  * @see http://www.ietf.org/rfc/rfc4120.txt
  */
 public class Ticket {
@@ -52,14 +50,14 @@
         return sname;
     }
 
-    //
-    // Ticket          ::= [APPLICATION 1] SEQUENCE {
-    //     tkt-vno         [0] INTEGER (5),
-    //     realm           [1] Realm,
-    //     sname           [2] PrincipalName,
-    //     enc-part        [3] EncryptedData -- EncTicketPart
-    // }
-    //
+    /**
+     <pre>Ticket          ::= [APPLICATION 1] SEQUENCE {
+     tkt-vno         [0] INTEGER (5),
+     realm           [1] Realm,
+     sname           [2] PrincipalName,
+     enc-part        [3] EncryptedData -- EncTicketPart
+     }</pre>
+     */
     static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
             new ASN1Explicit(0, ASN1Integer.getInstance()), // tkt-vno
             // TODO should we define Realm type?
@@ -69,6 +67,7 @@
             new ASN1Explicit(3, ASN1Any.getInstance()), // ticket 
     }) {
 
+        @Override
         protected Object getDecodedObject(BerInputStream in) throws IOException {
 
             Object[] values = (Object[]) in.content;
@@ -76,6 +75,7 @@
             return new Ticket((String) values[1], (PrincipalName) values[2]);
         }
 
+        @Override
         protected void getValues(Object object, Object[] values) {
             throw new RuntimeException(); //FIXME message
         }



Mime
View raw message