Docstoc

4 OwnerImpl synopsis

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

     Source code generated by decompilation of OwnerImpl.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:   OwnerImpl.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.Enumeration;                                        import java.util.Enumeration;




                                                       OwnerImpl synopsis -- page 1 of 3
// Referenced classes of package sun.security.acl:                                        /**
//            GroupImpl                                                                    * Additional class for verification Owner interface
                                                                                           */
public class OwnerImpl                                                                    public class OwnerImpl implements Owner {
    implements Owner
{
                                                                                                private Group ownerGroup;2

      public OwnerImpl(Principal principal)                                                     public OwnerImpl(Principal principal) {
      {
          ownerGroup = new GroupImpl("AclOwners");                                                    ownerGroup = new GroupImpl("AclOwners");
          ownerGroup.addMember(principal);                                                            ownerGroup.addMember(principal);
      }                                                                                         }

      public synchronized boolean addOwner(Principal                                            public synchronized boolean addOwner(Principal
      principal, Principal principal1)                                                          principal, Principal principal1)
          throws NotOwnerException                                                                  throws NotOwnerException {
      {
          if(!isOwner(principal))                                                                     if(!isOwner(principal))
          {                                                                                           {
              throw new NotOwnerException();                                                              throw new NotOwnerException();
          } else                                                                                      } else {
          {
              ownerGroup.addMember(principal1);                                                             if (ownerGroup.isMember(principal1))
                                                                                                            return false;
                                                                                                            if (!ownerGroup.isMember(principal1)) {
                                                                                                                ownerGroup.addMember(principal1);
                                                                                                                return true;
                                                                                                            }
           }                                                                                          }
                  return false;1                                                                      return false;
      }                                                                                         }

      public synchronized boolean deleteOwner(Principal                                         public synchronized boolean deleteOwner(Principal
      principal, Principal principal1)                                                          principal, Principal principal1)


1 While that line contains the same command in both files, there is a logical difference: only on the left side is it definitely executed within the relevant "else" block. On the right
  side, its execution is subject to another "if" condition, and there is a possiblity that an alternative "return true" command may get executed, which does not exist on the left side.
2 In the left column, the same declaration appears at the end of the class definition.

                                                                        OwnerImpl synopsis -- page 2 of 3
        throws NotOwnerException, LastOwnerException                  throws NotOwnerException, LastOwnerException {
    {
        if(!isOwner(principal))                                       if(!isOwner(principal)) throw new
             throw new NotOwnerException();                           NotOwnerException();
        Enumeration enumeration = ownerGroup.members();               Enumeration enumeration = ownerGroup.members();
        Object obj = enumeration.nextElement();                       Object obj = enumeration.nextElement();
        if(enumeration.hasMoreElements())                             if(enumeration.hasMoreElements()) {
             return ownerGroup.removeMember(principal1);                  return ownerGroup.removeMember(principal1);
        else                                                          } else {
             throw new LastOwnerException();                              throw new LastOwnerException();
                                                                      }
    }                                                            }

    public synchronized boolean isOwner(Principal                public synchronized boolean isOwner(Principal
    principal)                                                   principal)
    {                                                            {
        return ownerGroup.isMember(principal);                       return ownerGroup.isMember(principal);
    }                                                            }

    private Group ownerGroup;
}                                                           }




                                               OwnerImpl synopsis -- page 3 of 3

				
DOCUMENT INFO
Shared By:
Stats:
views:1393
posted:1/21/2011
language:English
pages:3