Docstoc

3 GroupImpl synopsis

Document Sample
3 GroupImpl synopsis Powered By Docstoc
					GroupImpl -- synopsis by Florian Mueller (http://fosspatents.blogspot.com -- Twitter:FOSSpatents)

     Source code generated by decompilation of GroupImpl.class                          Source code shipped by Google
       (jdk1.5.0.22; spaces and blank lines inserted manually)         (Android "Froyo" release; spaces and blank lines inserted manually)

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel                   /*
Kouznetsov.                                                           * Licensed to the Apache Software Foundation (ASF)
// Jad home page: http://www.kpdus.com/jad.html                      under one or more
// Decompiler options: packimports(3)                                 * contributor license agreements. See the NOTICE file
// Source File Name:   GroupImpl.java                                distributed with
                                                                      * this work for additional information regarding
                                                                     copyright ownership.
                                                                      * The ASF licenses this file to You under the Apache
                                                                     License, Version 2.0
                                                                      * (the "License"); you may not use this file except in
                                                                     compliance with
                                                                      * the License. You may obtain a copy of the License at
                                                                      *
                                                                      *     http://www.apache.org/licenses/LICENSE-2.0
                                                                      *
                                                                      * Unless required by applicable law or agreed to in
                                                                     writing, software
                                                                      * distributed under the License is distributed on an
                                                                     "AS IS" BASIS,
                                                                      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
                                                                     express or implied.
                                                                      * See the License for the specific language governing
                                                                     permissions and
                                                                      * limitations under the License.
                                                                      */

package sun.security.acl;                                            package org.apache.harmony.security.tests.support.acl;

import   java.security.Principal;                                    import   java.security.Principal;
import   java.security.acl.Group;                                    import   java.security.acl.Group;
import   java.util.Enumeration;                                      import   java.util.Enumeration;
import   java.util.Vector;                                           import   java.util.Vector;



                                                       GroupImpl synopsis -- page 1 of 5
                                                                                        /**
                                                                                         * Additional class for verification Group interface
                                                                                         */
public class GroupImpl                                                                  public class GroupImpl implements Group {
    implements Group
{
                                                                                             private Vector groupMembers;
                                                                                             private String group;1

      public GroupImpl(String s)                                                             public GroupImpl(String s) {
      {
          groupMembers = new Vector(50, 100);                                                    groupMembers = new Vector(50, 100);
          group = s;                                                                             group = s;
      }                                                                                      }

      public boolean addMember(Principal principal)                                          public boolean addMember(Principal principal) {
      {
          if(groupMembers.contains(principal))                                                   if(groupMembers.contains(principal))
              return false;                                                                          return false;
          if(group.equals(principal.toString()))                                                 if(group.equals(principal.toString())) {
          {
              throw new IllegalArgumentException();                                                  throw new IllegalArgumentException();
          } else                                                                                 } else {
          {
              groupMembers.addElement(principal);                                                    groupMembers.addElement(principal);
              return true;                                                                           return true;
          }                                                                                      }
      }                                                                                      }

      public boolean removeMember(Principal principal)                                       public boolean removeMember(Principal principal) {
      {
          return groupMembers.removeElement(principal);                                          return groupMembers.removeElement(principal);
      }                                                                                      }

      public Enumeration members()                                                           public Enumeration members() {
      {
          return groupMembers.elements();                                                        return groupMembers.elements();
      }                                                                                      }

1 In the left column, the same two declarations appear at the end of the class definition.

                                                                       GroupImpl synopsis -- page 2 of 5
public boolean equals(Object obj)                           public boolean equals(Object obj) {
{
    if(this == obj)                                              if(this == obj)
        return true;                                                 return true;
    if(!(obj instanceof Group))                                  if(!(obj instanceof Group)) {
    {
        return false;                                                return false;
    } else                                                       } else {
    {
        Group group1 = (Group)obj;                                    Group group1 = (Group)obj;
        return group.equals(group1.toString());                       return group.equals(group1.toString());
    }                                                            }
}                                                           }

public boolean equals(Group group1)                         public boolean equals(Group group1) {
{
    return equals(group1);                                       return equals(group1);
}                                                           }

public String toString()                                    public String toString() {
{
    return group;                                                return group;
}                                                           }

public int hashCode()                                       public int hashCode() {
{
    return group.hashCode();                                     return group.hashCode();
}                                                           }

public boolean isMember(Principal principal)                public boolean isMember(Principal principal) {
{
    if(groupMembers.contains(principal))                         if(groupMembers.contains(principal)) {
    {
        return true;                                                 return true;
    } else                                                       } else {
    {
        Vector vector = new Vector(10);                               Vector vector = new Vector(10);
        return isMemberRecurse(principal, vector);                    return isMemberRecurse(principal, vector);


                                          GroupImpl synopsis -- page 3 of 5
    }                                                             }
}                                                            }

public String getName()                                      public String getName() {
{
    return group;                                                 return group;
}                                                            }

boolean isMemberRecurse(Principal principal,                 boolean isMemberRecurse(Principal principal,
Vector vector)                                               Vector vector) {
{
    for(Enumeration enumeration = members();                      for(Enumeration enumeration = members();
    enumeration.hasMoreElements();)                               enumeration.hasMoreElements();) {
    {
        boolean flag = false;                                          boolean flag = false;
        Principal principal1 =                                         Principal principal1 =
        (Principal)enumeration.nextElement();                          (Principal)enumeration.nextElement();
        if(principal1.equals(principal))                               if(principal1.equals(principal))
            return true;                                                   return true;
        if(principal1 instanceof GroupImpl)                            if(principal1 instanceof GroupImpl) {
        {
            GroupImpl groupimpl =                                              GroupImpl groupimpl =
            (GroupImpl)principal1;                                             (GroupImpl)principal1;
            vector.addElement(this);                                           vector.addElement(this);
            if(!vector.contains(groupimpl))                                    if(!vector.contains(groupimpl))
                 flag =                                                            flag =
                 groupimpl.isMemberRecurse(principal,                              groupimpl.isMemberRecurse(principal,
                 vector);                                                          vector);
        } else
        if(principal1 instanceof Group)                                } else if(principal1 instanceof Group) {
        {
            Group group1 = (Group)principal1;                                  Group group1 = (Group)principal1;
            if(!vector.contains(group1))                                       if(!vector.contains(group1)) flag =
                 flag = group1.isMember(principal);                            group1.isMember(principal);
        }                                                              }
        if(flag)                                                       if(flag) return flag;
            return flag;                                          }
    }



                                           GroupImpl synopsis -- page 4 of 5
        return false;                                     return false;
    }                                                }
                                                }
    private Vector groupMembers;
    private String group;
}




                                   GroupImpl synopsis -- page 5 of 5

				
DOCUMENT INFO
Shared By:
Stats:
views:1781
posted:1/21/2011
language:English
pages:5