org.eclipse.osgi_3.7.2.v20120110-1415

  public void flush()
  {
    resolverExports = null;
    resolverBundles = null;
    resolverGenerics = null;
    unresolvedBundles = null;
    bundleMapping = null;
    List<BundleDescription> removed = removalPending.getAllValues();
    for (Iterator localIterator = removed.iterator(); localIterator.hasNext();)
    {
      BundleDescription removedDesc = (BundleDescription)localIterator.next();
      state.removeBundleComplete(removedDesc);
    }
    removalPending.clear();
    initialized = false;
  }
  
  public State getState()
  {
    return state;
  }
  
  public void setState(State newState)
  {
    if (state != null) {
      throw new IllegalStateException("Cannot change the State of a Resolver");
    }
    state = newState;
    flush();
  }
  
  private void setDebugOptions()
  {
    FrameworkDebugOptions options = FrameworkDebugOptions.getDefault();
    if (options == null) {
      return;
    }
    DEBUG = options.getBooleanOption("org.eclipse.osgi/resolver/debug", false);
    DEBUG_WIRING = options.getBooleanOption("org.eclipse.osgi/resolver/wiring", false);
    DEBUG_IMPORTS = options.getBooleanOption("org.eclipse.osgi/resolver/imports", false);
    DEBUG_REQUIRES = options.getBooleanOption("org.eclipse.osgi/resolver/requires", false);
    DEBUG_GENERICS = options.getBooleanOption("org.eclipse.osgi/resolver/generics", false);
    DEBUG_USES = options.getBooleanOption("org.eclipse.osgi/resolver/uses", false);
    DEBUG_CYCLES = options.getBooleanOption("org.eclipse.osgi/resolver/cycles", false);
  }
  
  private void printWirings()
  {
    log("****** Result Wirings ******");
    List<ResolverBundle> bundles = resolverBundles.getAllValues();
    for (Iterator localIterator = bundles.iterator(); localIterator.hasNext();)
    {
      ResolverBundle rb = (ResolverBundle)localIterator.next();
      if (!rb.getBundleDescription().isResolved())
      {
        log("    * WIRING for " + rb);
        
        BundleConstraint[] requireBundles = rb.getRequires();
        if (requireBundles.length == 0) {
          log("        (r) no requires");
        } else {
          for (int i = 0; i < requireBundles.length; i++) {
            if (requireBundles[i].getSelectedSupplier() == null) {
              log("        (r) " + rb.getBundleDescription() + " -> NULL!!!");
            } else {
              log("        (r) " + rb.getBundleDescription() + " -> " + requireBundles[i].getSelectedSupplier());
            }
          }
        }
        BundleConstraint hostSpec = rb.getHost();
        if (hostSpec != null)
        {
          VersionSupplier[] hosts = hostSpec.getPossibleSuppliers();
          if (hosts != null) {
            for (int i = 0; i < hosts.length; i++) {
              log("        (h) " + rb.getBundleDescription() + " -> " + hosts[i].getBundleDescription());
            }
          }
        }
        ResolverImport[] imports = rb.getImportPackages();
        if (imports.length == 0) {
          log("        (w) no imports");
        } else {
          for (int i = 0; i < imports.length; i++) {
            if ((imports[i].isDynamic()) && (imports[i].getSelectedSupplier() == null)) {
              log("        (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> DYNAMIC");
            } else if ((imports[i].isOptional()) && (imports[i].getSelectedSupplier() == null)) {
              log("        (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> OPTIONAL (could not be wired)");
            } else if (imports[i].getSelectedSupplier() == null) {
              log("        (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> NULL!!!");
            } else {
              log(
                "        (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> " + ((ResolverExport)imports[i].getSelectedSupplier()).getExporter() + ":" + imports[i].getSelectedSupplier().getName());
            }
          }
        }
      }
    }
  }
  
  static void log(String message)
  {
    Debug.println(message);
  }
  
  VersionHashMap<ResolverExport> getResolverExports()
  {
    return resolverExports;
  }
  
  public void setSelectionPolicy(Comparator<BaseDescription> selectionPolicy)
  {
    this.selectionPolicy = selectionPolicy;
  }
  
  public Comparator<BaseDescription> getSelectionPolicy()
  {
    return selectionPolicy;
  }
  
  public void setCompositeResolveHelperRegistry(CompositeResolveHelperRegistry compositeHelpers)
  {
    this.compositeHelpers = compositeHelpers;
  }
  
  CompositeResolveHelperRegistry getCompositeHelpers()
  {
    return compositeHelpers;
  }
  
  private void reorderGenerics()
  {
    for (Iterator localIterator = resolverGenerics.values().iterator(); localIterator.hasNext();)
    {
      VersionHashMap<GenericCapability> namespace = (VersionHashMap)localIterator.next();
      namespace.reorder();
    }
  }
  
  void removeGenerics(GenericCapability[] generics)
  {
    GenericCapability[] arrayOfGenericCapability;
    int j = (arrayOfGenericCapability = generics).length;
    for (int i = 0; i < j; i++)
    {
      GenericCapability capability = arrayOfGenericCapability[i];
      VersionHashMap<GenericCapability> namespace = (VersionHashMap)resolverGenerics.get(capability.getGenericDescription().getType());
      if (namespace != null) {
        namespace.remove(capability);
      }
    }
  }
  
  void addGenerics(GenericCapability[] generics)
  {
    GenericCapability[] arrayOfGenericCapability;
    int j = (arrayOfGenericCapability = generics).length;
    for (int i = 0; i < j; i++)
    {
      GenericCapability capability = arrayOfGenericCapability[i];
      String type = capability.getGenericDescription().getType();
      VersionHashMap<GenericCapability> namespace = (VersionHashMap)resolverGenerics.get(type);
      if (namespace == null)
      {
        namespace = new VersionHashMap(this);
        resolverGenerics.put(type, namespace);
      }
      namespace.put(capability.getName(), capability);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.ResolverImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import org.eclipse.osgi.service.resolver.ImportPackageSpecification;

public class ResolverImport
  extends ResolverConstraint
{
  private String name;
  
  ResolverImport(ResolverBundle bundle, ImportPackageSpecification ips)
  {
    super(bundle, ips);
  }
  
  boolean isOptional()
  {
    return "optional".equals(((ImportPackageSpecification)constraint).getDirective("resolution"));
  }
  
  boolean isDynamic()
  {
    return "dynamic".equals(((ImportPackageSpecification)constraint).getDirective("resolution"));
  }
  
  public String getName()
  {
    if (name != null) {
      return name;
    }
    return super.getName();
  }
  
  void setName(String requestedPackage)
  {
    name = requestedPackage;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.ResolverImport
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.Version;

public class VersionHashMap<V extends VersionSupplier>
  extends MappedList<String, V>
  implements Comparator<V>
{
  private final ResolverImpl resolver;
  private final boolean preferSystemPackages;
  
  public VersionHashMap(ResolverImpl resolver)
  {
    this.resolver = resolver;
    Dictionary[] allProperties = resolver.getState().getPlatformProperties();
    Object preferSystem = allProperties.length == 0 ? "true" : allProperties[0].get("osgi.resolver.preferSystemPackages");
    if (preferSystem == null) {
      preferSystem = "true";
    }
    preferSystemPackages = Boolean.valueOf(preferSystem.toString()).booleanValue();
  }
  
  protected int insertionIndex(List<V> existing, V value)
  {
    int index = existing.size();
    if (compare((VersionSupplier)existing.get(existing.size() - 1), value) > 0)
    {
      index = Collections.binarySearch(existing, value, this);
      if (index < 0) {
        index = -index - 1;
      }
    }
    return index;
  }
  
  public void put(V[] versionSuppliers)
  {
    for (int i = 0; i < versionSuppliers.length; i++) {
      put(versionSuppliers[i].getName(), versionSuppliers[i]);
    }
  }
  
  public boolean contains(V vs)
  {
    return contains(vs, false) != null;
  }
  
  private V contains(V vs, boolean remove)
  {
    List<V> existing = (List)internal.get(vs.getName());
    if (existing == null) {
      return null;
    }
    int index = existing.indexOf(vs);
    if (index >= 0)
    {
      if (remove)
      {
        existing.remove(index);
        if (existing.size() == 0) {
          internal.remove(vs.getName());
        }
      }
      return vs;
    }
    return null;
  }
  
  public V remove(V toBeRemoved)
  {
    return contains(toBeRemoved, true);
  }
  
  public void remove(V[] versionSuppliers)
  {
    for (int i = 0; i < versionSuppliers.length; i++) {
      remove(versionSuppliers[i]);
    }
  }
  
  void reorder()
  {
    for (Iterator<List<V>> it = internal.values().iterator(); it.hasNext();)
    {
      List<V> existing = (List)it.next();
      if (existing.size() > 1) {
        Collections.sort(existing, this);
      }
    }
  }
  
  public int compare(V vs1, V vs2)
  {
    if (resolver.getSelectionPolicy() != null) {
      return resolver.getSelectionPolicy().compare(vs1.getBaseDescription(), vs2.getBaseDescription());
    }
    if (preferSystemPackages)
    {
      String systemBundle = resolver.getSystemBundle();
      if ((systemBundle.equals(vs1.getBundleDescription().getSymbolicName())) && (!systemBundle.equals(vs2.getBundleDescription().getSymbolicName()))) {
        return -1;
      }
      if ((!systemBundle.equals(vs1.getBundleDescription().getSymbolicName())) && (systemBundle.equals(vs2.getBundleDescription().getSymbolicName()))) {
        return 1;
      }
    }
    if (vs1.getBundleDescription().isResolved() != vs2.getBundleDescription().isResolved()) {
      return vs1.getBundleDescription().isResolved() ? -1 : 1;
    }
    int versionCompare = -vs1.getVersion().compareTo(vs2.getVersion());
    if (versionCompare != 0) {
      return versionCompare;
    }
    return vs1.getBundleDescription().getBundleId() <= vs2.getBundleDescription().getBundleId() ? -1 : 1;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.VersionHashMap
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleCapability;

public abstract class VersionSupplier
{
  protected final BaseDescription base;
  private final BundleCapability capability;
  private VersionSupplier substitute;
  
  VersionSupplier(BaseDescription base)
  {
    this.base = base;
    capability = base.getCapability();
  }
  
  public Version getVersion()
  {
    return base.getVersion();
  }
  
  public String getName()
  {
    return base.getName();
  }
  
  public BaseDescription getBaseDescription()
  {
    return base;
  }
  
  VersionSupplier getSubstitute()
  {
    return substitute;
  }
  
  void setSubstitute(VersionSupplier substitute)
  {
    this.substitute = substitute;
  }
  
  public abstract BundleDescription getBundleDescription();
  
  abstract ResolverBundle getResolverBundle();
  
  public String toString()
  {
    return base.toString();
  }
  
  BundleCapability getCapability()
  {
    return capability;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.VersionSupplier
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.Permission;
import java.util.Enumeration;
import java.util.NoSuchElementException;

class BundlePermissions$1
  implements Enumeration<Permission>
{
  public boolean hasMoreElements()
  {
    return false;
  }
  
  public Permission nextElement()
  {
    throw new NoSuchElementException();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.BundlePermissions.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.osgi.framework.Bundle;

public final class BundlePermissions
  extends PermissionCollection
{
  private static final long serialVersionUID = -5443618108312606612L;
  static final Enumeration<Permission> EMPTY_ENUMERATION = new Enumeration()
  {
    public boolean hasMoreElements()
    {
      return false;
    }
    
    public Permission nextElement()
    {
      throw new NoSuchElementException();
    }
  };
  private final Bundle bundle;
  private final SecurityAdmin securityAdmin;
  private final PermissionInfoCollection impliedPermissions;
  private final PermissionInfoCollection restrictedPermissions;
  
  public BundlePermissions(Bundle bundle, SecurityAdmin securityAdmin, PermissionInfoCollection impliedPermissions, PermissionInfoCollection restrictedPermissions)
  {
    this.bundle = bundle;
    this.securityAdmin = securityAdmin;
    this.impliedPermissions = impliedPermissions;
    this.restrictedPermissions = restrictedPermissions;
    setReadOnly();
  }
  
  public void add(Permission permission)
  {
    throw new SecurityException();
  }
  
  public Enumeration<Permission> elements()
  {
    return EMPTY_ENUMERATION;
  }
  
  public boolean implies(Permission permission)
  {
    if ((impliedPermissions != null) && (impliedPermissions.implies(permission))) {
      return true;
    }
    if ((restrictedPermissions != null) && (!restrictedPermissions.implies(permission))) {
      return false;
    }
    return securityAdmin.checkPermission(permission, this);
  }
  
  public Bundle getBundle()
  {
    return bundle;
  }
  
  void clearPermissionCache()
  {
    if (impliedPermissions != null) {
      impliedPermissions.clearPermissionCache();
    }
    if (restrictedPermissions != null) {
      restrictedPermissions.clearPermissionCache();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.BundlePermissions
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.AccessControlContext;
import java.util.ArrayList;
import java.util.List;

class EquinoxSecurityManager$CheckContext
{
  List<List<SecurityRow.Decision[]>> depthCondSets = new ArrayList(2);
  List<AccessControlContext> accs = new ArrayList(2);
  List<Class<?>> CondClassSet;
  
  public int getDepth()
  {
    return depthCondSets.size() - 1;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.EquinoxSecurityManager.CheckContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.Permission;
import java.security.PrivilegedAction;

class EquinoxSecurityManager$CheckPermissionAction
  implements PrivilegedAction<Object>
{
  Permission perm;
  Object context;
  EquinoxSecurityManager fsm;
  
  EquinoxSecurityManager$CheckPermissionAction(EquinoxSecurityManager fsm, Permission perm, Object context)
  {
    this.fsm = fsm;
    this.perm = perm;
    this.context = context;
  }
  
  public Object run()
  {
    fsm.internalCheckPermission(perm, context);
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.EquinoxSecurityManager.CheckPermissionAction
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.osgi.service.condpermadmin.Condition;

public class EquinoxSecurityManager
  extends SecurityManager
{
  static
  {
    Class<?> c = CheckPermissionAction.class;
    c = CheckContext.class;
    c.getName();
  }
  
  static class CheckContext
  {
    List<List<SecurityRow.Decision[]>> depthCondSets = new ArrayList(2);
    List<AccessControlContext> accs = new ArrayList(2);
    List<Class<?>> CondClassSet;
    
    public int getDepth()
    {
      return depthCondSets.size() - 1;
    }
  }
  
  static class CheckPermissionAction
    implements PrivilegedAction<Object>
  {
    Permission perm;
    Object context;
    EquinoxSecurityManager fsm;
    
    CheckPermissionAction(EquinoxSecurityManager fsm, Permission perm, Object context)
    {
      this.fsm = fsm;
      this.perm = perm;
      this.context = context;
    }
    
    public Object run()
    {
      fsm.internalCheckPermission(perm, context);
      return null;
    }
  }
  
  private final ThreadLocal<CheckContext> localCheckContext = new ThreadLocal();
  
  boolean addConditionsForDomain(SecurityRow.Decision[] results)
  {
    CheckContext cc = (CheckContext)localCheckContext.get();
    if (cc == null) {
      return false;
    }
    List<SecurityRow.Decision[]> condSets = (List)depthCondSets.get(cc.getDepth());
    if (condSets == null)
    {
      condSets = new ArrayList(1);
      depthCondSets.set(cc.getDepth(), condSets);
    }
    condSets.add(results);
    return true;
  }
  
  boolean inCheckPermission()
  {
    return localCheckContext.get() != null;
  }
  
  public void checkPermission(Permission perm, Object context)
  {
    AccessController.doPrivileged(new CheckPermissionAction(this, perm, context));
  }
  
  public AccessControlContext getContextToBeChecked()
  {
    CheckContext cc = (CheckContext)localCheckContext.get();
    if ((cc != null) && (accs != null) && (!accs.isEmpty())) {
      return (AccessControlContext)accs.get(accs.size() - 1);
    }
    return null;
  }
  
  void internalCheckPermission(Permission perm, Object context)
  {
    AccessControlContext acc = (AccessControlContext)context;
    CheckContext cc = (CheckContext)localCheckContext.get();
    if (cc == null)
    {
      cc = new CheckContext();
      localCheckContext.set(cc);
    }
    depthCondSets.add(null);
    accs.add(acc);
    try
    {
      acc.checkPermission(perm);
      
      List<SecurityRow.Decision[]> conditionSets = (List)depthCondSets.get(cc.getDepth());
      if (conditionSets == null) {
        return;
      }
      Map<Class<? extends Condition>, Dictionary<Object, Object>> conditionDictionaries = new HashMap();
      for (Iterator localIterator = conditionSets.iterator(); localIterator.hasNext();)
      {
        SecurityRow.Decision[] domainDecisions = (SecurityRow.Decision[])localIterator.next();
        boolean grant = false;
        for (int i = 0; i < domainDecisions.length; i++)
        {
          if (domainDecisions[i] == null) {
            break;
          }
          if ((decision & 0x4) == 0)
          {
            if ((decision & 0x8) == 0)
            {
              if ((decision & 0x1) == 0) {
                break;
              }
              grant = true;
              break;
            }
            int decision = getPostponedDecision(domainDecisions[i], conditionDictionaries, cc);
            if ((decision & 0x4) == 0)
            {
              if ((decision & 0x1) == 0) {
                break;
              }
              grant = true;
              break;
            }
          }
        }
        if (!grant) {
          throw new SecurityException("Conditions not satisfied");
        }
      }
    }
    finally
    {
      depthCondSets.remove(cc.getDepth());
      accs.remove(accs.size() - 1);
    }
    depthCondSets.remove(cc.getDepth());
    accs.remove(accs.size() - 1);
  }
  
  private int getPostponedDecision(SecurityRow.Decision decision, Map<Class<? extends Condition>, Dictionary<Object, Object>> conditionDictionaries, CheckContext cc)
  {
    Condition[] postponed = postponed;
    for (int i = 0; i < postponed.length; i++)
    {
      Dictionary<Object, Object> condContext = (Dictionary)conditionDictionaries.get(postponed[i].getClass());
      if (condContext == null)
      {
        condContext = new Hashtable();
        conditionDictionaries.put(postponed[i].getClass(), condContext);
      }
      if (CondClassSet == null) {
        CondClassSet = new ArrayList(2);
      }
      if (CondClassSet.contains(postponed[i].getClass())) {
        return 4;
      }
      CondClassSet.add(postponed[i].getClass());
      try
      {
        boolean mutable = postponed[i].isMutable();
        boolean isSatisfied = postponed[i].isSatisfied(new Condition[] { postponed[i] }, condContext);
        decision.handleImmutable(postponed[i], isSatisfied, mutable);
        if (!isSatisfied) {
          return 4;
        }
      }
      finally
      {
        CondClassSet.remove(postponed[i].getClass());
      }
      CondClassSet.remove(postponed[i].getClass());
    }
    return decision;
  }
  
  public void checkPermission(Permission perm)
  {
    checkPermission(perm, getSecurityContext());
  }
  
  public Object getSecurityContext()
  {
    return AccessController.getContext();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.EquinoxSecurityManager
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.osgi.service.permissionadmin.PermissionInfo;

public class PermissionAdminTable
{
  private final Map<String, PermissionInfoCollection> locations = new HashMap();
  
  String[] getLocations()
  {
    return (String[])locations.keySet().toArray(new String[locations.size()]);
  }
  
  PermissionInfo[] getPermissions(String location)
  {
    PermissionInfoCollection collection = (PermissionInfoCollection)locations.get(location);
    if (collection != null) {
      return collection.getPermissionInfos();
    }
    return null;
  }
  
  void setPermissions(String location, PermissionInfo[] permissions)
  {
    if (permissions == null)
    {
      locations.remove(location);
      return;
    }
    locations.put(location, new PermissionInfoCollection(permissions));
  }
  
  PermissionInfoCollection getCollection(String location)
  {
    return (PermissionInfoCollection)locations.get(location);
  }
  
  PermissionInfoCollection[] getCollections()
  {
    String[] currentLocations = getLocations();
    PermissionInfoCollection[] results = new PermissionInfoCollection[currentLocations.length];
    for (int i = 0; i < results.length; i++) {
      results[i] = getCollection(currentLocations[i]);
    }
    return results;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.PermissionAdminTable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.security.AllPermission;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import org.osgi.service.permissionadmin.PermissionInfo;

public final class PermissionInfoCollection
  extends PermissionCollection
{
  private static final long serialVersionUID = 3140511562980923957L;
  private static final Class<?>[] twoStringClassArray = { String.class, String.class };
  private static final Class<?>[] oneStringClassArray = { String.class };
  private static final Class<?>[] noArgClassArray = new Class[0];
  private static final Class<?>[][] permClassArrayArgs = { noArgClassArray, oneStringClassArray, twoStringClassArray };
  private final Map<Class<? extends Permission>, PermissionCollection> cachedPermissionCollections = new HashMap();
  private final boolean hasAllPermission;
  private final PermissionInfo[] permInfos;
  
  public PermissionInfoCollection(PermissionInfo[] permInfos)
  {
    this.permInfos = permInfos;
    boolean tempAllPermissions = false;
    for (int i = 0; (i < permInfos.length) && (!tempAllPermissions); i++) {
      if (permInfos[i].getType().equals(AllPermission.class.getName())) {
        tempAllPermissions = true;
      }
    }
    hasAllPermission = tempAllPermissions;
    setReadOnly();
  }
  
  public void add(Permission arg0)
  {
    throw new SecurityException();
  }
  
  public Enumeration<Permission> elements()
  {
    return BundlePermissions.EMPTY_ENUMERATION;
  }
  
  public boolean implies(Permission perm)
  {
    if (hasAllPermission) {
      return true;
    }
    Class<? extends Permission> permClass = perm.getClass();
    PermissionCollection collection;
    synchronized (cachedPermissionCollections)
    {
      collection = (PermissionCollection)cachedPermissionCollections.get(permClass);
    }
    PermissionCollection collection;
    if (collection == null)
    {
      collection = perm.newPermissionCollection();
      if (collection == null) {
        collection = new PermissionsHash();
      }
      try
      {
        addPermissions(collection, permClass);
      }
      catch (Exception e)
      {
        throw ((SecurityException)new SecurityException("Exception creating permissions: " + permClass + ": " + e.getMessage()).initCause(e));
      }
      synchronized (cachedPermissionCollections)
      {
        PermissionCollection exists = (PermissionCollection)cachedPermissionCollections.get(permClass);
        if (exists != null) {
          collection = exists;
        } else {
          cachedPermissionCollections.put(permClass, collection);
        }
      }
    }
    return collection.implies(perm);
  }
  
  PermissionInfo[] getPermissionInfos()
  {
    return permInfos;
  }
  
  private void addPermissions(PermissionCollection collection, Class<? extends Permission> permClass)
    throws NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException
  {
    String permClassName = permClass.getName();
    Constructor<? extends Permission> constructor = null;
    int numArgs = -1;
    for (int i = permClassArrayArgs.length - 1; i >= 0; i--) {
      try
      {
        constructor = permClass.getConstructor(permClassArrayArgs[i]);
        numArgs = i;
      }
      catch (NoSuchMethodException localNoSuchMethodException) {}
    }
    if (constructor == null) {
      throw new NoSuchMethodException(permClass.getName() + ".<init>()");
    }
    for (int i = 0; i < permInfos.length; i++) {
      if (permInfos[i].getType().equals(permClassName))
      {
        String[] args = new String[numArgs];
        if (numArgs > 0) {
          args[0] = permInfos[i].getName();
        }
        if (numArgs > 1) {
          args[1] = permInfos[i].getActions();
        }
        if (permInfos[i].getType().equals("java.io.FilePermission")) {
          if (!args[0].equals("<<ALL FILES>>"))
          {
            File file = new File(args[0]);
            if (!file.isAbsolute()) {
              continue;
            }
          }
        }
        collection.add((Permission)constructor.newInstance(args));
      }
    }
  }
  
  void clearPermissionCache()
  {
    synchronized (cachedPermissionCollections)
    {
      cachedPermissionCollections.clear();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.PermissionInfoCollection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Enumeration;
import java.util.Hashtable;

class PermissionsHash
  extends PermissionCollection
{
  private static final long serialVersionUID = 3258408426341284153L;
  Hashtable<Permission, Permission> perms = new Hashtable(8);
  
  public void add(Permission perm)
  {
    if (isReadOnly()) {
      throw new SecurityException();
    }
    perms.put(perm, perm);
  }
  
  public Enumeration<Permission> elements()
  {
    return perms.keys();
  }
  
  public boolean implies(Permission perm)
  {
    Permission p = (Permission)perms.get(perm);
    if ((p != null) && (p.implies(perm))) {
      return true;
    }
    Enumeration<Permission> permsEnum = elements();
    while (permsEnum.hasMoreElements()) {
      if (((Permission)permsEnum.nextElement()).implies(perm)) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.PermissionsHash
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import org.eclipse.osgi.framework.adaptor.PermissionStorage;

public class SecurePermissionStorage
  implements PermissionStorage, PrivilegedExceptionAction<String[]>
{
  private final PermissionStorage storage;
  private String location;
  private String[] data;
  private String[] infos;
  private int action;
  private static final int GET = 1;
  private static final int SET = 2;
  private static final int LOCATION = 3;
  private static final int GET_INFOS = 4;
  private static final int SAVE_INFOS = 5;
  
  public SecurePermissionStorage(PermissionStorage storage)
  {
    this.storage = storage;
  }
  
  public String[] run()
    throws IOException
  {
    switch (action)
    {
    case 1: 
      return storage.getPermissionData(location);
    case 2: 
      storage.setPermissionData(location, data);
      return null;
    case 3: 
      return storage.getLocations();
    case 5: 
      storage.saveConditionalPermissionInfos(infos);
      return null;
    case 4: 
      return storage.getConditionalPermissionInfos();
    }
    throw new UnsupportedOperationException();
  }
  
  public String[] getPermissionData(String loc)
    throws IOException
  {
    location = loc;
    action = 1;
    try
    {
      return (String[])AccessController.doPrivileged(this);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
  
  public String[] getLocations()
    throws IOException
  {
    action = 3;
    try
    {
      return (String[])AccessController.doPrivileged(this);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
  
  public void setPermissionData(String location, String[] data)
    throws IOException
  {
    this.location = location;
    this.data = data;
    action = 2;
    try
    {
      AccessController.doPrivileged(this);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
  
  public void saveConditionalPermissionInfos(String[] updatedInfos)
    throws IOException
  {
    action = 5;
    infos = updatedInfos;
    try
    {
      AccessController.doPrivileged(this);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
  
  public String[] getConditionalPermissionInfos()
    throws IOException
  {
    action = 4;
    try
    {
      return (String[])AccessController.doPrivileged(this);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.SecurePermissionStorage
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;

class SecurityAdmin$MockBundle
  implements Bundle
{
  private final Map<X509Certificate, List<X509Certificate>> signers;
  
  SecurityAdmin$MockBundle(Map<X509Certificate, List<X509Certificate>> signers)
  {
    this.signers = signers;
  }
  
  public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
  {
    return null;
  }
  
  public BundleContext getBundleContext()
  {
    return null;
  }
  
  public long getBundleId()
  {
    return -1L;
  }
  
  public URL getEntry(String path)
  {
    return null;
  }
  
  public Enumeration<String> getEntryPaths(String path)
  {
    return null;
  }
  
  public Dictionary<String, String> getHeaders()
  {
    return new Hashtable();
  }
  
  public Dictionary<String, String> getHeaders(String locale)
  {
    return getHeaders();
  }
  
  public long getLastModified()
  {
    return 0L;
  }
  
  public String getLocation()
  {
    return "";
  }
  
  public ServiceReference<?>[] getRegisteredServices()
  {
    return null;
  }
  
  public URL getResource(String name)
  {
    return null;
  }
  
  public Enumeration<URL> getResources(String name)
    throws IOException
  {
    return null;
  }
  
  public ServiceReference<?>[] getServicesInUse()
  {
    return null;
  }
  
  public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
  {
    return new HashMap(signers);
  }
  
  public int getState()
  {
    return 1;
  }
  
  public String getSymbolicName()
  {
    return null;
  }
  
  public Version getVersion()
  {
    return Version.emptyVersion;
  }
  
  public boolean hasPermission(Object permission)
  {
    return false;
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    throw new IllegalStateException();
  }
  
  public void start(int options)
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void start()
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void stop(int options)
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void stop()
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void uninstall()
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void update()
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public void update(InputStream in)
    throws BundleException
  {
    throw new IllegalStateException();
  }
  
  public int compareTo(Bundle o)
  {
    return 0;
  }
  
  public <A> A adapt(Class<A> type)
  {
    throw new IllegalStateException();
  }
  
  public File getDataFile(String filename)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.SecurityAdmin.MockBundle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.security.Principal;

class SecurityAdmin$MockPrincipal
  implements Principal
{
  private final String name;
  
  SecurityAdmin$MockPrincipal(String name)
  {
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if ((obj instanceof MockPrincipal)) {
      return name.equals(name);
    }
    return false;
  }
  
  public int hashCode()
  {
    return name.hashCode();
  }
  
  public String toString()
  {
    return getName();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.SecurityAdmin.MockPrincipal
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.permadmin;

import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Principal;
import java.security.PublicKey;
import java.security.SignatureException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Set;

class SecurityAdmin$MockX509Certificate
  extends X509Certificate
{
  private final Principal subject;
  private final Principal issuer;
  
  SecurityAdmin$MockX509Certificate(Principal subject, Principal issuer)
  {
    this.subject = subject;
    this.issuer = issuer;
  }
  
  public Principal getSubjectDN()
  {
    return subject;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if ((obj instanceof MockX509Certificate)) {
      return (subject.equals(subject)) && (issuer.equals(issuer));
    }
    return false;
  }
  
  public int hashCode()
  {
    return subject.hashCode() + issuer.hashCode();
  }
  
  public String toString()
  {
    return subject.toString();
  }
  
  public void checkValidity()
    throws CertificateExpiredException, CertificateNotYetValidException
  {
    throw new UnsupportedOperationException();
  }
  
  public void checkValidity(Date var0)
    throws CertificateExpiredException, CertificateNotYetValidException
  {
    throw new UnsupportedOperationException();
  }
  
  public int getBasicConstraints()
  {
    throw new UnsupportedOperationException();
  }
  
  public Principal getIssuerDN()
  {
    return issuer;
  }
  
  public boolean[] getIssuerUniqueID()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean[] getKeyUsage()
  {
    throw new UnsupportedOperationException();
  }
  
  public Date getNotAfter()
  {
    throw new UnsupportedOperationException();
  }
  
  public Date getNotBefore()
  {
    throw new UnsupportedOperationException();
  }
  
  public BigInteger getSerialNumber()
  {
    throw new UnsupportedOperationException();
  }
  
  public String getSigAlgName()
  {
    throw new UnsupportedOperationException();
  }
  
  public String getSigAlgOID()
  {
    throw new UnsupportedOperationException();
  }
  
  public byte[] getSigAlgParams()
  {
    throw new UnsupportedOperationException();
  }
  
  public byte[] getSignature()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean[] getSubjectUniqueID()
  {
    throw new UnsupportedOperationException();
  }
  
  public byte[] getTBSCertificate()
    throws CertificateEncodingException
  {
    throw new UnsupportedOperationException();
  }
  
  public int getVersion()
  {
    throw new UnsupportedOperationException();
  }
  
  public byte[] getEncoded()
    throws CertificateEncodingException
  {
    throw new UnsupportedOperationException();
  }
  
  public PublicKey getPublicKey()
  {
    throw new UnsupportedOperationException();
  }
  
  public void verify(PublicKey var0)
    throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, CertificateException
  {
    throw new UnsupportedOperationException();
  }
  
  public void verify(PublicKey var0, String var1)
    throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, Certificat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd