harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r451778 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth: ./ module/
Date Sun, 01 Oct 2006 18:25:33 GMT
Author: ndbeyer
Date: Sun Oct  1 11:25:32 2006
New Revision: 451778

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

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericGroupPrincipal.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericUserPrincipal.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixPrincipal.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixLoginModule.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixSystem.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericGroupPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericGroupPrincipal.java?view=diff&rev=451778&r1=451777&r2=451778
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericGroupPrincipal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericGroupPrincipal.java
Sun Oct  1 11:25:32 2006
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-/**
- * @author Alexander V. Astapchuk
- * @version $Revision$
- */
 package org.apache.harmony.auth;
 
 import java.io.Serializable;
@@ -31,18 +27,12 @@
  */
 public class UnixNumericGroupPrincipal implements Serializable, Principal {
 
-    /**
-     * @serial
-     */
     private static final long serialVersionUID = -535408497353506159L;
 
     // Group id
     private long gid;
     // Group name
     private String gname;
-    // Shows whether the group is primary for a user or not
-    private boolean primary;
-
     /**
      * Creates the object using a String representation of gid.
      * @param gid string representation of gid
@@ -54,7 +44,6 @@
             throw new NullPointerException(Messages.getString("auth.07")); //$NON-NLS-1$
         }
         this.gid = Long.parseLong(gid);
-        this.primary = primary;
     }
 
     /**
@@ -64,7 +53,6 @@
      */
     public UnixNumericGroupPrincipal(long gid, boolean primary) {
         this.gid = gid;
-        this.primary = primary;
     }
 
     /**
@@ -76,7 +64,6 @@
     public UnixNumericGroupPrincipal(long gid, String gname, boolean primary) {
         this.gid = gid;
         this.gname = gname;
-        this.primary = primary;
     }
     
     /**
@@ -103,13 +90,12 @@
     /**
      * Returns String representation of this object.
      */
+    @Override
     public String toString() {
         if( gname == null ) {
             return "UnixNumericGroupPrincipal, gid=" + gid; //$NON-NLS-1$
         }
-        else {
-            return "UnixNumericGroupPrincipal, gid=" + gid+"; name="+gname; //$NON-NLS-1$
//$NON-NLS-2$
-        }
+        return "UnixNumericGroupPrincipal, gid=" + gid+"; name="+gname; //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -117,6 +103,7 @@
      * The objects are considered equals if they both are of type 
      * UnixNumericGroupPrincipal and have the same gid.
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof UnixNumericGroupPrincipal) {
             return ((UnixNumericGroupPrincipal) o).gid == gid;
@@ -127,6 +114,7 @@
     /**
      * Returns hash code of this object.
      */
+    @Override
     public int hashCode() {
         return (int) gid;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericUserPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericUserPrincipal.java?view=diff&rev=451778&r1=451777&r2=451778
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericUserPrincipal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixNumericUserPrincipal.java
Sun Oct  1 11:25:32 2006
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-/**
- * @author Alexander V. Astapchuk
- * @version $Revision$
- */
 package org.apache.harmony.auth;
 
 import java.io.Serializable;
@@ -31,9 +27,6 @@
  */
 public class UnixNumericUserPrincipal implements Serializable, Principal {
 
-    /**
-     * @serial
-     */
     private static final long serialVersionUID = -8301723108164907822L;
 
     // User id
@@ -76,6 +69,7 @@
     /**
      * Returns String representation of this object.
      */
+    @Override
     public String toString() {
         return "UnixNumericUserPrincipal, uid=" + uid; //$NON-NLS-1$
     }
@@ -85,6 +79,7 @@
      * The objects are considered equals if they both are of type 
      * UnixNumericUserPrincipal and have the same uid.
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof UnixNumericUserPrincipal) {
             return ((UnixNumericUserPrincipal) o).uid == uid;
@@ -95,6 +90,7 @@
     /**
      * Returns hash code of this object.
      */
+    @Override
     public int hashCode() {
         return (int) uid;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixPrincipal.java?view=diff&rev=451778&r1=451777&r2=451778
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixPrincipal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/UnixPrincipal.java
Sun Oct  1 11:25:32 2006
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-/**
- * @author Alexander V. Astapchuk
- * @version $Revision$
- */
 package org.apache.harmony.auth;
 
 import java.io.Serializable;
@@ -61,6 +57,7 @@
     /**
      * Returns string representation of this object
      */
+    @Override
     public String toString() {
         return "UnixPrincipal, name=" + name; //$NON-NLS-1$
     }
@@ -70,6 +67,7 @@
      * Two pricipal objects are considered equal if they are both of type 
      * UnixPrincipal and their names are equal.
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof UnixPrincipal) {
             return name.equals(((UnixPrincipal) o).name);
@@ -80,6 +78,7 @@
     /**
      * Return hash code of this object.
      */
+    @Override
     public int hashCode() {
         return name.hashCode();
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixLoginModule.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixLoginModule.java?view=diff&rev=451778&r1=451777&r2=451778
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixLoginModule.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixLoginModule.java
Sun Oct  1 11:25:32 2006
@@ -15,12 +15,9 @@
  *  limitations under the License.
  */
 
-/**
- * @author Alexander V. Astapchuk
- * @version $Revision$
- */
 package org.apache.harmony.auth.module;
 
+import java.security.Principal;
 import java.util.Map;
 import java.util.Set;
 
@@ -44,8 +41,6 @@
 
     private Subject subject;
 
-    private Map options;
-
     private UnixPrincipal user;
 
     private UnixNumericUserPrincipal uid;
@@ -58,7 +53,7 @@
      * @throws NullPointerException if either subject or options is null  
      */
     public void initialize(Subject subject, CallbackHandler callbackHandler,
-            Map sharedState, Map options) {
+            Map<String, ?> sharedState, Map<String, ?> options) {
         if (subject == null) {
             throw new NullPointerException(Messages.getString("auth.03")); //$NON-NLS-1$
         }
@@ -66,9 +61,6 @@
             throw new NullPointerException(Messages.getString("auth.04")); //$NON-NLS-1$
         }
         this.subject = subject;
-        // callbackHandler - unused
-        // sharedState - unused
-        this.options = options;
     }
 
     /** 
@@ -101,7 +93,7 @@
         if (subject.isReadOnly()) {
             throw new LoginException(Messages.getString("auth.05")); //$NON-NLS-1$
         }
-        Set ps = subject.getPrincipals();
+        Set<Principal> ps = subject.getPrincipals();
 
         if (!ps.contains(user)) {
             ps.add(user);
@@ -112,9 +104,9 @@
         if (!ps.contains(gid)) {
             ps.add(gid);
         }
-        for (int i = 0; i < gids.length; i++) {
-            if (!ps.contains(gids[i])) {
-                ps.add(gids[i]);
+        for (UnixNumericGroupPrincipal element : gids) {
+            if (!ps.contains(element)) {
+                ps.add(element);
             }
         }
         return true;
@@ -133,13 +125,13 @@
      * then clears clears an info store in its own fields.
      */
     public boolean logout() throws LoginException {
-        Set ps = subject.getPrincipals();
+        Set<Principal> ps = subject.getPrincipals();
         ps.remove(user);
         ps.remove(uid);
         ps.remove(gid);
         if (gids != null) {
-            for (int i = 0; i < gids.length; i++) {
-                ps.remove(gids[i]);
+            for (UnixNumericGroupPrincipal element : gids) {
+                ps.remove(element);
             }
         }
         clear();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixSystem.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixSystem.java?view=diff&rev=451778&r1=451777&r2=451778
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixSystem.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/linux/org/apache/harmony/auth/module/UnixSystem.java
Sun Oct  1 11:25:32 2006
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-/**
- * @author Alexander V. Astapchuk
- * @version $Revision$
- */
 package org.apache.harmony.auth.module;
 
 /** 
@@ -131,8 +127,9 @@
     /**
      * Returns string representation of this object
      */
+    @Override
     public String toString() {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append("UnixSystem: \n"); //$NON-NLS-1$
         buf.append("uid:gid=").append(uid).append(":").append(gid); //$NON-NLS-1$ //$NON-NLS-2$
         buf.append("="); //$NON-NLS-1$



Mime
View raw message