Docstoc

2 AclImpl synopsis

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

       Source code generated by decompilation of AclImpl.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:   AclImpl.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.*;                                           import java.security.acl.*;
import java.util.*;                                                   import java.util.*;




                                                         AclImpl synopsis -- page 1 of 9
// Referenced classes of package sun.security.acl:                                       /**
//            OwnerImpl, AclEnumerator                                                    * Additional class for verification Acl interface
                                                                                          */
public class AclImpl extends OwnerImpl                                                   public class AclImpl extends OwnerImpl implements Acl {
    implements Acl
{
                                                                                             private   Hashtable allowedUsersTable;
                                                                                             private   Hashtable allowedGroupsTable;
                                                                                             private   Hashtable deniedUsersTable;
                                                                                             private   Hashtable deniedGroupsTable;
                                                                                             private   String aclName;
                                                                                             private   Vector zeroSet;1
      public AclImpl(Principal principal, String s)
      {                                                                                      public AclImpl(Principal principal, String s) {
          super(principal);
          allowedUsersTable = new Hashtable(23);                                                 super(principal);
          allowedGroupsTable = new Hashtable(23);                                                allowedUsersTable = new Hashtable(23);
          deniedUsersTable = new Hashtable(23);                                                  allowedGroupsTable = new Hashtable(23);
          deniedGroupsTable = new Hashtable(23);                                                 deniedUsersTable = new Hashtable(23);
          aclName = null;                                                                        deniedGroupsTable = new Hashtable(23);
          zeroSet = new Vector(1, 1);                                                            aclName = null;
          try                                                                                    zeroSet = new Vector(1, 1);
          {                                                                                      try {
              setName(principal, s);
          }                                                                                            setName(principal, s);
          catch(Exception exception) { }
      }                                                                                          } catch(Exception exception) { }
                                                                                             }
      public void setName(Principal principal, String s)
          throws NotOwnerException                                                           public void setName(Principal principal, String s)
      {                                                                                                  throws NotOwnerException {
          if(!isOwner(principal))
          {                                                                                      if(!isOwner(principal)) {
              throw new NotOwnerException();
          } else                                                                                     throw new NotOwnerException();
          {                                                                                      } else {
              aclName = s;
              return;                                                                                  aclName = s;

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

                                                                         AclImpl synopsis -- page 2 of 9
        }                                                                 return;
    }                                                                }
                                                                }
    public String getName()
    {                                                           public String getName() {
        return aclName;
    }                                                                return aclName;
                                                                }
    public synchronized boolean addEntry(Principal
principal, AclEntry aclentry)                                  public synchronized boolean addEntry(Principal
        throws NotOwnerException                           principal, AclEntry aclentry)
    {                                                                                      throws NotOwnerException
        if(!isOwner(principal))                            {
            throw new NotOwnerException();                         if(!isOwner(principal)) throw new
        Hashtable hashtable = findTable(aclentry);                 NotOwnerException();
        Principal principal1 = aclentry.getPrincipal();            Hashtable hashtable = findTable(aclentry);
        if(hashtable.get(principal1) != null)                      Principal principal1 = aclentry.getPrincipal();
        {                                                          if(hashtable.get(principal1) != null) {
            return false;
        } else                                                           return false;
        {                                                            } else {
            hashtable.put(principal1, aclentry);
            return true;                                                  hashtable.put(principal1, aclentry);
        }                                                                 return true;
    }                                                                }
                                                                }
    public synchronized boolean removeEntry(Principal
    principal, AclEntry aclentry)                               public synchronized boolean removeEntry(Principal
        throws NotOwnerException                                principal, AclEntry aclentry)
    {                                                                  throws NotOwnerException
        if(!isOwner(principal))                                 {
        {                                                           if(!isOwner(principal)) {
            throw new NotOwnerException();
        } else                                                           throw new NotOwnerException();
        {                                                            } else {
            Hashtable hashtable = findTable(aclentry);
            Principal principal1 =                                        Hashtable hashtable = findTable(aclentry);
            aclentry.getPrincipal();                                      Principal principal1 =
            Object obj = hashtable.remove(principal1);                    aclentry.getPrincipal();


                                               AclImpl synopsis -- page 3 of 9
        return obj != null;                                           Object obj = hashtable.remove(principal1);
    }                                                                 return obj != null;
}                                                                }
                                                            }
public synchronized Enumeration
getPermissions(Principal principal)                         public synchronized Enumeration
{                                                           getPermissions(Principal principal) {
    Enumeration enumeration2 =
    subtract(getGroupPositive(principal),                        Enumeration enumeration2 =
    getGroupNegative(principal));                                subtract(getGroupPositive(principal),
    Enumeration enumeration3 =                                   getGroupNegative(principal));
    subtract(getGroupNegative(principal),                        Enumeration enumeration3 =
    getGroupPositive(principal));                                subtract(getGroupNegative(principal),
    Enumeration enumeration =                                    getGroupPositive(principal));
    subtract(getIndividualPositive(principal),                   Enumeration enumeration =
    getIndividualNegative(principal));                           subtract(getIndividualPositive(principal),
    Enumeration enumeration1 =                                   getIndividualNegative(principal));
    subtract(getIndividualNegative(principal),                   Enumeration enumeration1 =
    getIndividualPositive(principal));                           subtract(getIndividualNegative(principal),
    Enumeration enumeration4 = subtract(enumeration2,            getIndividualPositive(principal));
    enumeration1);                                               Enumeration enumeration4 = subtract(enumeration2,
    Enumeration enumeration5 = union(enumeration,                enumeration1);
    enumeration4);                                               Enumeration enumeration5 = union(enumeration,
    enumeration =                                                enumeration4);
    subtract(getIndividualPositive(principal),                   enumeration =
    getIndividualNegative(principal));                           subtract(getIndividualPositive(principal),
    enumeration1 =                                               getIndividualNegative(principal));
    subtract(getIndividualNegative(principal),                   enumeration1 =
    getIndividualPositive(principal));                           subtract(getIndividualNegative(principal),
    enumeration4 = subtract(enumeration3,                        getIndividualPositive(principal));
    enumeration);                                                enumeration4 = subtract(enumeration3,
    Enumeration enumeration6 = union(enumeration1,               enumeration);
    enumeration4);                                               Enumeration enumeration6 = union(enumeration1,
    return subtract(enumeration5, enumeration6);                 enumeration4);
}                                                                return subtract(enumeration5, enumeration6);
                                                            }
public boolean checkPermission(Principal principal,
Permission permission)                                      public boolean checkPermission(Principal principal,
{                                                           Permission permission) {


                                           AclImpl synopsis -- page 4 of 9
    for(Enumeration enumeration =
    getPermissions(principal);                                   for(Enumeration enumeration =
    enumeration.hasMoreElements();)                              getPermissions(principal);
    {                                                            enumeration.hasMoreElements();) {
        Permission permission1 =
        (Permission)enumeration.nextElement();                        Permission permission1 =
        if(permission1.equals(permission))                            (Permission)enumeration.nextElement();
            return true;                                              if(permission1.equals(permission))
    }                                                                     return true;
                                                                 }
    return false;
}                                                                return false;
                                                            }
public synchronized Enumeration entries()
{                                                           public synchronized Enumeration entries() {
    return new AclEnumerator(this, allowedUsersTable,
    allowedGroupsTable, deniedUsersTable,                        return new AclEnumerator(this, allowedUsersTable,
    deniedGroupsTable);                                          allowedGroupsTable, deniedUsersTable,
}                                                                deniedGroupsTable);
                                                            }
public String toString()
{                                                           public String toString() {
    StringBuffer stringbuffer = new StringBuffer();
    for(Enumeration enumeration = entries();                     StringBuffer stringbuffer = new StringBuffer();
    enumeration.hasMoreElements();                               for(Enumeration enumeration = entries();
    stringbuffer.append("\n"))                                   enumeration.hasMoreElements();
    {                                                            stringbuffer.append("\n")) {
        AclEntry aclentry =
       (AclEntry)enumeration.nextElement();                           AclEntry aclentry =
        stringbuffer.append(aclentry.toString().trim(                 (AclEntry)enumeration.nextElement();
        ));                                                           stringbuffer.append(aclentry.toString().trim(
    }                                                                 ));
                                                                 }
    return stringbuffer.toString();
}                                                                return stringbuffer.toString();
                                                            }
private Hashtable findTable(AclEntry aclentry)
{                                                           private Hashtable findTable(AclEntry aclentry) {
    Hashtable hashtable = null;


                                           AclImpl synopsis -- page 5 of 9
    Principal principal = aclentry.getPrincipal();               Hashtable hashtable = null;
    if(principal instanceof Group)                               Principal principal = aclentry.getPrincipal();
    {                                                            if(principal instanceof Group) {
         if(aclentry.isNegative())
              hashtable = deniedGroupsTable;                          if(aclentry.isNegative())
         else                                                              hashtable = deniedGroupsTable;
              hashtable = allowedGroupsTable;                         else
    } else                                                                 hashtable = allowedGroupsTable;
    if(aclentry.isNegative())                                    } else
         hashtable = deniedUsersTable;                           if(aclentry.isNegative())
    else                                                              hashtable = deniedUsersTable;
         hashtable = allowedUsersTable;                          else
    return hashtable;                                                 hashtable = allowedUsersTable;
}                                                                return hashtable;
                                                            }
private static Enumeration union(Enumeration
enumeration, Enumeration enumeration1)                      private static Enumeration union(Enumeration
{                                                           enumeration, Enumeration enumeration1) {
    Vector vector = new Vector(20, 20);
    for(; enumeration.hasMoreElements();                         Vector vector = new Vector(20, 20);
    vector.addElement(enumeration.nextElement()));               for(; enumeration.hasMoreElements();
    do                                                           vector.addElement(enumeration.nextElement()));
    {                                                            do {
        if(!enumeration1.hasMoreElements())
            break;                                                   if(!enumeration1.hasMoreElements())
        Object obj = enumeration1.nextElement();                         break;
        if(!vector.contains(obj))                                    Object obj = enumeration1.nextElement();
            vector.addElement(obj);                                  if(!vector.contains(obj))
    } while(true);                                                       vector.addElement(obj);
    return vector.elements();                                    } while(true);
}                                                                return vector.elements();
                                                            }
private Enumeration subtract(Enumeration enumeration,
Enumeration enumeration1)                                   private Enumeration subtract(Enumeration enumeration,
{                                                           Enumeration enumeration1) {
    Vector vector = new Vector(20, 20);
    for(; enumeration.hasMoreElements();                         Vector vector = new Vector(20, 20);
    vector.addElement(enumeration.nextElement()));               for(; enumeration.hasMoreElements();
    do                                                           vector.addElement(enumeration.nextElement()));


                                           AclImpl synopsis -- page 6 of 9
    {                                                            do {
        if(!enumeration1.hasMoreElements())
            break;                                                   if(!enumeration1.hasMoreElements())
        Object obj = enumeration1.nextElement();                         break;
        if(vector.contains(obj))                                     Object obj = enumeration1.nextElement();
            vector.removeElement(obj);                               if(vector.contains(obj))
    } while(true);                                                       vector.removeElement(obj);
    return vector.elements();                                    } while(true);
}                                                                return vector.elements();
                                                            }
private Enumeration getGroupPositive(Principal
principal)                                                  private Enumeration getGroupPositive(Principal
{                                                           principal) {
    Enumeration enumeration = zeroSet.elements();
    Enumeration enumeration1 =                                   Enumeration enumeration = zeroSet.elements();
    allowedGroupsTable.keys();                                   Enumeration enumeration1 =
    do                                                           allowedGroupsTable.keys();
    {                                                            do {
        if(!enumeration1.hasMoreElements())
            break;                                                    if(!enumeration1.hasMoreElements())
        Group group =                                                     break;
        (Group)enumeration1.nextElement();                            Group group =
        if(group.isMember(principal))                                 (Group)enumeration1.nextElement();
        {                                                             if(group.isMember(principal)) {
            AclEntry aclentry =
            (AclEntry)allowedGroupsTable.get(group);                         AclEntry aclentry =
            enumeration =                                                    (AclEntry)allowedGroupsTable.get(group);
            union(aclentry.permissions(),                                    enumeration =
            enumeration);                                                    union(aclentry.permissions(),
        }                                                                    enumeration);
    } while(true);                                                   }
    return enumeration;                                          } while(true);
}                                                                return enumeration;
                                                            }
private Enumeration getGroupNegative(Principal
principal)                                                  private Enumeration getGroupNegative(Principal
{                                                           principal) {
    Enumeration enumeration = zeroSet.elements();
                                                                 Enumeration enumeration = zeroSet.elements();


                                           AclImpl synopsis -- page 7 of 9
    Enumeration enumeration1 =
    deniedGroupsTable.keys();                                    Enumeration enumeration1 =
    do                                                           deniedGroupsTable.keys();
    {                                                            do {
        if(!enumeration1.hasMoreElements())
            break;                                                    if(!enumeration1.hasMoreElements())
        Group group =                                                     break;
        (Group)enumeration1.nextElement();                            Group group =
        if(group.isMember(principal))                                 (Group)enumeration1.nextElement();
        {                                                             if(group.isMember(principal)) {
            AclEntry aclentry =
            (AclEntry)deniedGroupsTable.get(group);                          AclEntry aclentry =
            enumeration =                                                    (AclEntry)deniedGroupsTable.get(group);
            union(aclentry.permissions(),                                    enumeration =
            enumeration);                                                    union(aclentry.permissions(),
        }                                                                    enumeration);
    } while(true);                                                   }
    return enumeration;                                          } while(true);
}                                                                return enumeration;
                                                            }
private Enumeration getIndividualPositive(Principal
principal)                                                  private Enumeration getIndividualPositive(Principal
{                                                           principal) {
    Enumeration enumeration = zeroSet.elements();
    AclEntry aclentry =                                          Enumeration enumeration = zeroSet.elements();
    (AclEntry)allowedUsersTable.get(principal);                  AclEntry aclentry =
    if(aclentry != null)                                         (AclEntry)allowedUsersTable.get(principal);
        enumeration = aclentry.permissions();                    if(aclentry != null)
    return enumeration;                                              enumeration = aclentry.permissions();
}                                                                return enumeration;
                                                            }
private Enumeration getIndividualNegative(Principal
principal)                                                  private Enumeration getIndividualNegative(Principal
{                                                           principal) {
    Enumeration enumeration = zeroSet.elements();
    AclEntry aclentry =                                          Enumeration enumeration = zeroSet.elements();
    (AclEntry)deniedUsersTable.get(principal);                   AclEntry aclentry =
    if(aclentry != null)                                         (AclEntry)deniedUsersTable.get(principal);
        enumeration = aclentry.permissions();                    if(aclentry != null)


                                           AclImpl synopsis -- page 8 of 9
        return enumeration;                                             enumeration = aclentry.permissions();
    }                                                               return enumeration;
                                                               }
    private   Hashtable allowedUsersTable;
    private   Hashtable allowedGroupsTable;
    private   Hashtable deniedUsersTable;
    private   Hashtable deniedGroupsTable;
    private   String aclName;
    private   Vector zeroSet;
}                                                         }




                                              AclImpl synopsis -- page 9 of 9

				
DOCUMENT INFO
Shared By:
Stats:
views:2755
posted:1/21/2011
language:English
pages:9