org.eclipse.osgi_3.7.2.v20120110-1415

eException
  {
    throw new UnsupportedOperationException();
  }
  
  public Set<String> getCriticalExtensionOIDs()
  {
    throw new UnsupportedOperationException();
  }
  
  public byte[] getExtensionValue(String var0)
  {
    throw new UnsupportedOperationException();
  }
  
  public Set<String> getNonCriticalExtensionOIDs()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean hasUnsupportedCriticalExtension()
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.permadmin.SecurityAdmin.MockX509Certificate
 * 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.math.BigInteger;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.AllPermission;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Principal;
import java.security.ProtectionDomain;
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.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.PermissionStorage;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.osgi.framework.AdminPermission;
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;
import org.osgi.service.condpermadmin.ConditionInfo;
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.permissionadmin.PermissionInfo;

public final class SecurityAdmin
  implements PermissionAdmin, ConditionalPermissionAdmin
{
  private static final PermissionCollection DEFAULT_DEFAULT;
  private static final String ADMIN_IMPLIED_ACTIONS = "resource,metadata,class,context";
  
  static
  {
    AllPermission allPerm = new AllPermission();
    DEFAULT_DEFAULT = allPerm.newPermissionCollection();
    if (DEFAULT_DEFAULT != null) {
      DEFAULT_DEFAULT.add(allPerm);
    }
  }
  
  private static final PermissionInfo[] EMPTY_PERM_INFO = new PermissionInfo[0];
  private final PermissionAdminTable permAdminTable = new PermissionAdminTable();
  private SecurityTable condAdminTable;
  private PermissionInfoCollection permAdminDefaults;
  private long timeStamp = 0L;
  private long nextID = System.currentTimeMillis();
  private final PermissionStorage permissionStorage;
  private final Object lock = new Object();
  private final Framework framework;
  private final PermissionInfo[] impliedPermissionInfos;
  private final EquinoxSecurityManager supportedSecurityManager;
  
  private SecurityAdmin(EquinoxSecurityManager supportedSecurityManager, Framework framework, PermissionInfo[] impliedPermissionInfos, PermissionInfoCollection permAdminDefaults)
  {
    this.supportedSecurityManager = supportedSecurityManager;
    this.framework = framework;
    this.impliedPermissionInfos = impliedPermissionInfos;
    this.permAdminDefaults = permAdminDefaults;
    permissionStorage = null;
  }
  
  public SecurityAdmin(EquinoxSecurityManager supportedSecurityManager, Framework framework, PermissionStorage permissionStorage)
    throws IOException
  {
    this.supportedSecurityManager = supportedSecurityManager;
    this.framework = framework;
    this.permissionStorage = new SecurePermissionStorage(permissionStorage);
    impliedPermissionInfos = getPermissionInfos(getClass().getResource("implied.permissions"), framework);
    String[] encodedDefaultInfos = permissionStorage.getPermissionData(null);
    PermissionInfo[] defaultInfos = getPermissionInfos(encodedDefaultInfos);
    if (defaultInfos != null) {
      permAdminDefaults = new PermissionInfoCollection(defaultInfos);
    }
    String[] locations = permissionStorage.getLocations();
    if (locations != null) {
      for (int i = 0; i < locations.length; i++)
      {
        String[] encodedLocationInfos = permissionStorage.getPermissionData(locations[i]);
        if (encodedLocationInfos != null)
        {
          PermissionInfo[] locationInfos = getPermissionInfos(encodedLocationInfos);
          permAdminTable.setPermissions(locations[i], locationInfos);
        }
      }
    }
    String[] encodedCondPermInfos = permissionStorage.getConditionalPermissionInfos();
    if (encodedCondPermInfos == null)
    {
      condAdminTable = new SecurityTable(this, new SecurityRow[0]);
    }
    else
    {
      SecurityRow[] rows = new SecurityRow[encodedCondPermInfos.length];
      try
      {
        for (int i = 0; i < rows.length; i++) {
          rows[i] = SecurityRow.createSecurityRow(this, encodedCondPermInfos[i]);
        }
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        rows = new SecurityRow[0];
      }
      condAdminTable = new SecurityTable(this, rows);
    }
  }
  
  private static PermissionInfo[] getPermissionInfos(String[] encodedInfos)
  {
    if (encodedInfos == null) {
      return null;
    }
    PermissionInfo[] results = new PermissionInfo[encodedInfos.length];
    for (int i = 0; i < results.length; i++) {
      results[i] = new PermissionInfo(encodedInfos[i]);
    }
    return results;
  }
  
  boolean checkPermission(Permission permission, BundlePermissions bundlePermissions)
  {
    PermissionInfoCollection curPermAdminDefaults;
    synchronized (lock)
    {
      Bundle bundle = bundlePermissions.getBundle();
      PermissionInfoCollection locationCollection = (bundle instanceof AbstractBundle) ? permAdminTable.getCollection(((AbstractBundle)bundle).getBundleData().getLocation()) : null;
      SecurityTable curCondAdminTable = condAdminTable;
      curPermAdminDefaults = permAdminDefaults;
    }
    PermissionInfoCollection curPermAdminDefaults;
    SecurityTable curCondAdminTable;
    PermissionInfoCollection locationCollection;
    if (locationCollection != null) {
      return locationCollection.implies(permission);
    }
    if (curCondAdminTable.isEmpty()) {
      return curPermAdminDefaults != null ? curPermAdminDefaults.implies(permission) : DEFAULT_DEFAULT.implies(permission);
    }
    int result = curCondAdminTable.evaluate(bundlePermissions, permission);
    if ((result & 0x1) != 0) {
      return true;
    }
    if ((result & 0x2) != 0) {
      return false;
    }
    if ((result & 0x8) != 0) {
      return true;
    }
    return false;
  }
  
  public PermissionInfo[] getDefaultPermissions()
  {
    synchronized (lock)
    {
      if (permAdminDefaults == null) {
        return null;
      }
      return permAdminDefaults.getPermissionInfos();
    }
  }
  
  public String[] getLocations()
  {
    synchronized (lock)
    {
      String[] results = permAdminTable.getLocations();
      return results.length == 0 ? null : results;
    }
  }
  
  /* Error */
  public PermissionInfo[] getPermissions(String location)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 608	org/eclipse/osgi/internal/permadmin/SecurityAdmin:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_2
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 613	org/eclipse/osgi/internal/permadmin/SecurityAdmin:permAdminTable	Lorg/eclipse/osgi/internal/permadmin/PermissionAdminTable;
    //   11: aload_1
    //   12: invokevirtual 674	org/eclipse/osgi/internal/permadmin/PermissionAdminTable:getPermissions	(Ljava/lang/String;)[Lorg/osgi/service/permissionadmin/PermissionInfo;
    //   15: aload_2
    //   16: monitorexit
    //   17: areturn
    //   18: aload_2
    //   19: monitorexit
    //   20: athrow
    // Line number table:
    //   Java source line #154	-> byte code offset #0
    //   Java source line #155	-> byte code offset #7
    //   Java source line #154	-> byte code offset #18
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	21	0	this	SecurityAdmin
    //   0	21	1	location	String
    //   5	14	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	17	18	finally
    //   18	20	18	finally
  }
  
  public void setDefaultPermissions(PermissionInfo[] permissions)
  {
    
    synchronized (lock)
    {
      if (permissions == null) {
        permAdminDefaults = null;
      } else {
        permAdminDefaults = new PermissionInfoCollection(permissions);
      }
      try
      {
        permissionStorage.setPermissionData(null, getEncodedPermissionInfos(permissions));
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  private static void checkAllPermission()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(new AllPermission());
    }
  }
  
  private static String[] getEncodedPermissionInfos(PermissionInfo[] permissions)
  {
    if (permissions == null) {
      return null;
    }
    String[] encoded = new String[permissions.length];
    for (int i = 0; i < encoded.length; i++) {
      encoded[i] = permissions[i].getEncoded();
    }
    return encoded;
  }
  
  public void setPermissions(String location, PermissionInfo[] permissions)
  {
    
    synchronized (lock)
    {
      permAdminTable.setPermissions(location, permissions);
      try
      {
        permissionStorage.setPermissionData(location, getEncodedPermissionInfos(permissions));
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  void delete(SecurityRow securityRow, boolean firstTry)
  {
    ConditionalPermissionUpdate update = newConditionalPermissionUpdate();
    
    List<ConditionalPermissionInfo> rows = update.getConditionalPermissionInfos();
    for (Iterator<ConditionalPermissionInfo> iRows = rows.iterator(); iRows.hasNext();)
    {
      ConditionalPermissionInfo info = (ConditionalPermissionInfo)iRows.next();
      if (securityRow.getName().equals(info.getName()))
      {
        iRows.remove();
        synchronized (lock)
        {
          if ((!update.commit()) && 
            (firstTry)) {
            delete(securityRow, false);
          }
        }
      }
    }
  }
  
  /**
   * @deprecated
   */
  public ConditionalPermissionInfo addConditionalPermissionInfo(ConditionInfo[] conds, PermissionInfo[] perms)
  {
    return setConditionalPermissionInfo(null, conds, perms, true);
  }
  
  public ConditionalPermissionInfo newConditionalPermissionInfo(String name, ConditionInfo[] conditions, PermissionInfo[] permissions, String decision)
  {
    return new SecurityRowSnapShot(name, conditions, permissions, decision);
  }
  
  public ConditionalPermissionInfo newConditionalPermissionInfo(String encoded)
  {
    return SecurityRow.createSecurityRowSnapShot(encoded);
  }
  
  /* Error */
  public ConditionalPermissionUpdate newConditionalPermissionUpdate()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 608	org/eclipse/osgi/internal/permadmin/SecurityAdmin:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: new 338	org/eclipse/osgi/internal/permadmin/SecurityTableUpdate
    //   10: dup
    //   11: aload_0
    //   12: aload_0
    //   13: getfield 615	org/eclipse/osgi/internal/permadmin/SecurityAdmin:condAdminTable	Lorg/eclipse/osgi/internal/permadmin/SecurityTable;
    //   16: invokevirtual 713	org/eclipse/osgi/internal/permadmin/SecurityTable:getRows	()[Lorg/eclipse/osgi/internal/permadmin/SecurityRow;
    //   19: aload_0
    //   20: getfield 606	org/eclipse/osgi/internal/permadmin/SecurityAdmin:timeStamp	J
    //   23: invokespecial 718	org/eclipse/osgi/internal/permadmin/SecurityTableUpdate:<init>	(Lorg/eclipse/osgi/internal/permadmin/SecurityAdmin;[Lorg/eclipse/osgi/internal/permadmin/SecurityRow;J)V
    //   26: aload_1
    //   27: monitorexit
    //   28: areturn
    //   29: aload_1
    //   30: monitorexit
    //   31: athrow
    // Line number table:
    //   Java source line #239	-> byte code offset #0
    //   Java source line #240	-> byte code offset #7
    //   Java source line #239	-> byte code offset #29
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	32	0	this	SecurityAdmin
    //   5	25	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	28	29	finally
    //   29	31	29	finally
  }
  
  public AccessControlContext getAccessControlContext(String[] signers)
  {
    SecurityAdmin snapShot = getSnapShot();
    return new AccessControlContext(new ProtectionDomain[] { createProtectionDomain(createMockBundle(signers), snapShot) });
  }
  
  /* Error */
  /**
   * @deprecated
   */
  public ConditionalPermissionInfo getConditionalPermissionInfo(String name)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 608	org/eclipse/osgi/internal/permadmin/SecurityAdmin:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_2
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 615	org/eclipse/osgi/internal/permadmin/SecurityAdmin:condAdminTable	Lorg/eclipse/osgi/internal/permadmin/SecurityTable;
    //   11: aload_1
    //   12: invokevirtual 716	org/eclipse/osgi/internal/permadmin/SecurityTable:getRow	(Ljava/lang/String;)Lorg/eclipse/osgi/internal/permadmin/SecurityRow;
    //   15: aload_2
    //   16: monitorexit
    //   17: areturn
    //   18: aload_2
    //   19: monitorexit
    //   20: athrow
    // Line number table:
    //   Java source line #253	-> byte code offset #0
    //   Java source line #254	-> byte code offset #7
    //   Java source line #253	-> byte code offset #18
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	21	0	this	SecurityAdmin
    //   0	21	1	name	String
    //   5	14	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	17	18	finally
    //   18	20	18	finally
  }
  
  /**
   * @deprecated
   */
  public Enumeration<ConditionalPermissionInfo> getConditionalPermissionInfos()
  {
    synchronized (lock)
    {
      SecurityRow[] rows = condAdminTable.getRows();
      List<ConditionalPermissionInfo> vRows = new ArrayList(rows.length);
      for (int i = 0; i < rows.length; i++) {
        vRows.add(rows[i]);
      }
      return Collections.enumeration(vRows);
    }
  }
  
  /**
   * @deprecated
   */
  public ConditionalPermissionInfo setConditionalPermissionInfo(String name, ConditionInfo[] conds, PermissionInfo[] perms)
  {
    return setConditionalPermissionInfo(name, conds, perms, true);
  }
  
  private SecurityAdmin getSnapShot()
  {
    synchronized (lock)
    {
      SecurityAdmin sa = new SecurityAdmin(supportedSecurityManager, framework, impliedPermissionInfos, permAdminDefaults);
      SecurityRow[] rows = condAdminTable.getRows();
      SecurityRow[] rowsSnapShot = new SecurityRow[rows.length];
      for (int i = 0; i < rows.length; i++) {
        rowsSnapShot[i] = new SecurityRow(sa, rows[i].getName(), rows[i].getConditionInfos(), rows[i].getPermissionInfos(), rows[i].getAccessDecision());
      }
      condAdminTable = new SecurityTable(sa, rowsSnapShot);
    }
    SecurityAdmin sa;
    return sa;
  }
  
  private ConditionalPermissionInfo setConditionalPermissionInfo(String name, ConditionInfo[] conds, PermissionInfo[] perms, boolean firstTry)
  {
    ConditionalPermissionUpdate update = newConditionalPermissionUpdate();
    
    List<ConditionalPermissionInfo> rows = update.getConditionalPermissionInfos();
    ConditionalPermissionInfo newInfo = newConditionalPermissionInfo(name, conds, perms, "allow");
    int index = -1;
    if (name != null) {
      for (int i = 0; (i < rows.size()) && (index < 0); i++)
      {
        ConditionalPermissionInfo info = (ConditionalPermissionInfo)rows.get(i);
        if (name.equals(info.getName())) {
          index = i;
        }
      }
    }
    if (index < 0)
    {
      rows.add(0, newInfo);
      index = 0;
    }
    else
    {
      rows.set(index, newInfo);
    }
    synchronized (lock)
    {
      if ((!update.commit()) && 
        (firstTry)) {
        setConditionalPermissionInfo(name, conds, perms, false);
      }
      return condAdminTable.getRow(index);
    }
  }
  
  boolean commit(List<ConditionalPermissionInfo> rows, long updateStamp)
  {
    
    synchronized (lock)
    {
      if (updateStamp != timeStamp) {
        return false;
      }
      SecurityRow[] newRows = new SecurityRow[rows.size()];
      Collection<String> names = new ArrayList();
      for (int i = 0; i < newRows.length; i++)
      {
        Object rowObj = rows.get(i);
        if (!(rowObj instanceof ConditionalPermissionInfo)) {
          throw new IllegalStateException("Invalid type \"" + rowObj.getClass().getName() + "\" at row: " + i);
        }
        ConditionalPermissionInfo infoBaseRow = (ConditionalPermissionInfo)rowObj;
        String name = infoBaseRow.getName();
        if (name == null) {
          name = generateName();
        }
        if (names.contains(name)) {
          throw new IllegalStateException("Duplicate name \"" + name + "\" at row: " + i);
        }
        newRows[i] = new SecurityRow(this, name, infoBaseRow.getConditionInfos(), infoBaseRow.getPermissionInfos(), infoBaseRow.getAccessDecision());
      }
      condAdminTable = new SecurityTable(this, newRows);
      try
      {
        permissionStorage.saveConditionalPermissionInfos(condAdminTable.getEncodedRows());
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      timeStamp += 1L;
      return true;
    }
  }
  
  private String generateName()
  {
    return "generated_" + Long.toString(nextID++);
  }
  
  public BundleProtectionDomain createProtectionDomain(Bundle bundle)
  {
    return createProtectionDomain(bundle, this);
  }
  
  private BundleProtectionDomain createProtectionDomain(Bundle bundle, SecurityAdmin sa)
  {
    PermissionInfoCollection impliedPermissions = getImpliedPermission(bundle);
    PermissionInfo[] restrictedInfos = getFileRelativeInfos(getPermissionInfos(bundle.getEntry("OSGI-INF/permissions.perm"), framework), bundle);
    PermissionInfoCollection restrictedPermissions = restrictedInfos == null ? null : new PermissionInfoCollection(restrictedInfos);
    BundlePermissions bundlePermissions = new BundlePermissions(bundle, sa, impliedPermissions, restrictedPermissions);
    return new BundleProtectionDomain(bundlePermissions, null, bundle);
  }
  
  private PermissionInfoCollection getImpliedPermission(Bundle bundle)
  {
    if (impliedPermissionInfos == null) {
      return null;
    }
    PermissionInfo impliedAdminPermission = new PermissionInfo(AdminPermission.class.getName(), "(id=" + bundle.getBundleId() + ")", "resource,metadata,class,context");
    PermissionInfo[] bundleImpliedInfos = new PermissionInfo[impliedPermissionInfos.length + 1];
    System.arraycopy(impliedPermissionInfos, 0, bundleImpliedInfos, 0, impliedPermissionInfos.length);
    bundleImpliedInfos[impliedPermissionInfos.length] = impliedAdminPermission;
    return new PermissionInfoCollection(getFileRelativeInfos(bundleImpliedInfos, bundle));
  }
  
  private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle)
  {
    if ((permissionInfos == null) || (!(bundle instanceof AbstractBundle))) {
      return permissionInfos;
    }
    PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
    for (int i = 0; i < permissionInfos.length; i++)
    {
      results[i] = permissionInfos[i];
      if (("java.io.FilePermission".equals(permissionInfos[i].getType())) && 
        (!"<<ALL FILES>>".equals(permissionInfos[i].getName())))
      {
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute())
        {
          File target = ((AbstractBundle)bundle).getBundleData().getDataFile(permissionInfos[i].getName());
          if (target != null) {
            results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          }
        }
      }
    }
    return results;
  }
  
  public void clearCaches()
  {
    SecurityRow[] condAdminRows;
    synchronized (lock)
    {
      PermissionInfoCollection[] permAdminCollections = permAdminTable.getCollections();
      condAdminRows = condAdminTable.getRows();
    }
    SecurityRow[] condAdminRows;
    PermissionInfoCollection[] permAdminCollections;
    for (int i = 0; i < permAdminCollections.length; i++) {
      permAdminCollections[i].clearPermissionCache();
    }
    for (int i = 0; i < condAdminRows.length; i++) {
      condAdminRows[i].clearCaches();
    }
  }
  
  EquinoxSecurityManager getSupportedSecurityManager()
  {
    return supportedSecurityManager != null ? supportedSecurityManager : getSupportedSystemSecurityManager();
  }
  
  private static EquinoxSecurityManager getSupportedSystemSecurityManager()
  {
    try
    {
      EquinoxSecurityManager equinoxManager = (EquinoxSecurityManager)System.getSecurityManager();
      return (equinoxManager != null) && (equinoxManager.inCheckPermission()) ? equinoxManager : null;
    }
    catch (ClassCastException localClassCastException) {}
    return null;
  }
  
  /* Error */
  private static PermissionInfo[] getPermissionInfos(URL resource, Framework framework)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +5 -> 6
    //   4: aconst_null
    //   5: areturn
    //   6: getstatic 616	org/eclipse/osgi/internal/permadmin/SecurityAdmin:EMPTY_PERM_INFO	[Lorg/osgi/service/permissionadmin/PermissionInfo;
    //   9: astore_2
    //   10: aconst_null
    //   11: astore_3
    //   12: new 291	java/io/DataInputStream
    //   15: dup
    //   16: aload_0
    //   17: invokevirtual 653	java/net/URL:openStream	()Ljava/io/InputStream;
    //   20: invokespecial 621	java/io/DataInputStream:<init>	(Ljava/io/InputStream;)V
    //   23: astore_3
    //   24: new 314	java/util/ArrayList
    //   27: dup
    //   28: invokespecial 659	java/util/ArrayList:<init>	()V
    //   31: astore 4
    //   33: new 290	java/io/BufferedReader
    //   36: dup
    //   37: new 294	java/io/InputStreamReader
    //   40: dup
    //   41: aload_3
    //   42: ldc_w 283
    //   45: invokespecial 627	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   48: invokespecial 618	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   51: astore 5
    //   53: goto +21 -> 74
    //   56: pop
    //   57: new 290	java/io/BufferedReader
    //   60: dup
    //   61: new 294	java/io/InputStreamReader
    //   64: dup
    //   65: aload_3
    //   66: invokespecial 626	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   69: invokespecial 618	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   72: astore 5
    //   74: aload 5
    //   76: invokevirtual 619	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   79: astore 6
    //   81: aload 6
    //   83: ifnonnull +6 -> 89
    //   86: goto +84 -> 170
    //   89: aload 6
    //   91: invokevirtual 641	java/lang/String:trim	()Ljava/lang/String;
    //   94: astore 6
    //   96: aload 6
    //   98: invokevirtual 638	java/lang/String:length	()I
    //   101: ifeq -27 -> 74
    //   104: aload 6
    //   106: ldc_w 274
    //   109: invokevirtual 643	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   112: ifne -38 -> 74
    //   115: aload 6
    //   117: ldc_w 277
    //   120: invokevirtual 643	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   123: ifeq +6 -> 129
    //   126: goto -52 -> 74
    //   129: aload 4
    //   131: new 344	org/osgi/service/permissionadmin/PermissionInfo
    //   134: dup
    //   135: aload 6
    //   137: invokespecial 723	org/osgi/service/permissionadmin/PermissionInfo:<init>	(Ljava/lang/String;)V
    //   140: invokeinterface 732 2 0
    //   145: pop
    //   146: goto -72 -> 74
    //   149: astore 7
    //   151: aload_1
    //   152: ifnull -78 -> 74
    //   155: aload_1
    //   156: iconst_2
    //   157: aload_1
    //   158: lconst_0
    //   159: invokevirtual 665	org/eclipse/osgi/framework/internal/core/Framework:getBundle	(J)Lorg/eclipse/osgi/framework/internal/core/AbstractBundle;
    //   162: aload 7
    //   164: invokevirtual 666	org/eclipse/osgi/framework/internal/core/Framework:publishFrameworkEvent	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;)V
    //   167: goto -93 -> 74
    //   170: aload 4
    //   172: invokeinterface 729 1 0
    //   177: istore 6
    //   179: iload 6
    //   181: ifle +55 -> 236
    //   184: aload 4
    //   186: iload 6
    //   188: anewarray 344	org/osgi/service/permissionadmin/PermissionInfo
    //   191: invokeinterface 735 2 0
    //   196: checkcast 289	[Lorg/osgi/service/permissionadmin/PermissionInfo;
    //   199: astore_2
    //   200: goto +36 -> 236
    //   203: pop
    //   204: aload_3
    //   205: ifnull +43 -> 248
    //   208: aload_3
    //   209: invokevirtual 620	java/io/DataInputStream:close	()V
    //   212: goto +36 -> 248
    //   215: pop
    //   216: goto +32 -> 248
    //   219: astore 8
    //   221: aload_3
    //   222: ifnull +11 -> 233
    //   225: aload_3
    //   226: invokevirtual 620	java/io/DataInputStream:close	()V
    //   229: goto +4 -> 233
    //   232: pop
    //   233: aload 8
    //   235: athrow
    //   236: aload_3
    //   237: ifnull +11 -> 248
    //   240: aload_3
    //   241: invokevirtual 620	java/io/DataInputStream:close	()V
    //   244: goto +4 -> 248
    //   247: pop
    //   248: aload_2
    //   249: areturn
    // Line number table:
    //   Java source line #429	-> byte code offset #0
    //   Java source line #430	-> byte code offset #4
    //   Java source line #431	-> byte code offset #6
    //   Java source line #432	-> byte code offset #10
    //   Java source line #434	-> byte code offset #12
    //   Java source line #435	-> byte code offset #24
    //   Java source line #438	-> byte code offset #33
    //   Java source line #439	-> byte code offset #56
    //   Java source line #440	-> byte code offset #57
    //   Java source line #444	-> byte code offset #74
    //   Java source line #445	-> byte code offset #81
    //   Java source line #446	-> byte code offset #86
    //   Java source line #447	-> byte code offset #89
    //   Java source line #448	-> byte code offset #96
    //   Java source line #449	-> byte code offset #126
    //   Java source line #452	-> byte code offset #129
    //   Java source line #453	-> byte code offset #149
    //   Java source line #455	-> byte code offset #151
    //   Java source line #456	-> byte code offset #155
    //   Java source line #443	-> byte code offset #167
    //   Java source line #459	-> byte code offset #170
    //   Java source line #460	-> byte code offset #179
    //   Java source line #461	-> byte code offset #184
    //   Java source line #462	-> byte code offset #203
    //   Java source line #466	-> byte code offset #204
    //   Java source line #467	-> byte code offset #208
    //   Java source line #468	-> byte code offset #215
    //   Java source line #464	-> byte code offset #219
    //   Java source line #466	-> byte code offset #221
    //   Java source line #467	-> byte code offset #225
    //   Java source line #468	-> byte code offset #232
    //   Java source line #471	-> byte code offset #233
    //   Java source line #466	-> byte code offset #236
    //   Java source line #467	-> byte code offset #240
    //   Java source line #468	-> byte code offset #247
    //   Java source line #472	-> byte code offset #248
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	250	0	resource	URL
    //   0	250	1	framework	Framework
    //   9	240	2	info	PermissionInfo[]
    //   11	230	3	in	java.io.DataInputStream
    //   31	154	4	permissions	List<PermissionInfo>
    //   51	3	5	reader	java.io.BufferedReader
    //   72	3	5	reader	java.io.BufferedReader
    //   79	57	6	line	String
    //   177	10	6	size	int
    //   149	14	7	iae	IllegalArgumentException
    //   219	15	8	localObject	Object
    //   56	1	11	localUnsupportedEncodingException	java.io.UnsupportedEncodingException
    //   203	1	12	localIOException1	IOException
    //   215	1	13	localIOException2	IOException
    //   232	1	14	localIOException3	IOException
    //   247	1	15	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   33	53	56	java/io/UnsupportedEncodingException
    //   129	146	149	java/lang/IllegalArgumentException
    //   12	200	203	java/io/IOException
    //   204	212	215	java/io/IOException
    //   12	204	219	finally
    //   221	229	232	java/io/IOException
    //   236	244	247	java/io/IOException
  }
  
  private static Bundle createMockBundle(String[] signers)
  {
    Map<X509Certificate, List<X509Certificate>> signersMap = new HashMap();
    for (int i = 0; i < signers.length; i++)
    {
      List<String> chain = parseDNchain(signers[i]);
      List<X509Certificate> signersList = new ArrayList();
      Principal subject = null;Principal issuer = null;
      X509Certificate first = null;
      for (Iterator<String> iChain = chain.iterator(); iChain.hasNext();)
      {
        subject = issuer == null ? new MockPrincipal((String)iChain.next()) : issuer;
        issuer = iChain.hasNext() ? new MockPrincipal((String)iChain.next()) : subject;
        X509Certificate cert = new MockX509Certificate(subject, issuer);
        if (first == null) {
          first = cert;
        }
        signersList.add(cert);
      }
      if (subject != issuer) {
        signersList.add(new MockX509Certificate(issuer, issuer));
      }
      signersMap.put(first, signersList);
    }
    return new MockBundle(signersMap);
  }
  
  static class MockBundle
    implements Bundle
  {
    private final Map<X509Certificate, List<X509Certificate>> signers;
    
    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;
    }
  }
  
  private static class MockX509Certificate
    extends X509Certificate
  {
    private final Principal subject;
    private final Principal issuer;
    
    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, CertificateException
    {
      throw new UnsupportedOperationException();
    }
    
    public Set<String> getCriticalExtensionOIDs()
    {
      throw new UnsupportedOperationException();
    }
    
    public byte[] getExtensionValue(String var0)
    {
      throw new UnsupportedOperationException();
    }
    
    public Set<String> getNonCriticalExtensionOIDs()
    {
      throw new UnsupportedOperationException();
    }
    
    public boolean hasUnsupportedCriticalExtension()
    {
      throw new UnsupportedOperationException();
    }
  }
  
  private static class MockPrincipal
    implements Principal
  {
    private final String name;
    
    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();
    }
  }
  
  private static List<String> parseDNchain(String dnChain)
  {
    if (dnChain == null) {
      throw new IllegalArgumentException("The DN chain must not be null.");
    }
    List<String> parsed = new ArrayList();
    int startIndex = 0;
    startIndex = skipSpaces(dnChain, startIndex);
    label124:
    while (startIndex < dnChain.length())
    {
      int endIndex = startIndex;
      boolean inQuote = false;
      while (endIndex < dnChain.length())
      {
        char c = dnChain.charAt(endIndex);
        switch (c)
        {
        case '"': 
          inQuote = !inQuote;
          break;
        case '\\': 
          endIndex++;
          break;
        case ';': 
          if (!inQuote) {
            break label124;
          }
        }
        endIndex++;
      }
      if (endIndex > dnChain.length()) {
        throw new IllegalArgumentException("unterminated escape");
      }
      parsed.add(dnChain.substring(startIndex, endIndex));
      startIndex = endIndex + 1;
      startIndex = skipSpaces(dnChain, startIndex);
    }
    return parsed;
  }
  
  private static int skipSpaces(String dnChain, int startIndex)
  {
    while ((startIndex < dnChain.length()) && (dnChain.charAt(startIndex) == ' ')) {
      startIndex++;
    }
    return startIndex;
  }
}

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

import java.util.Map;
import org.osgi.service.condpermadmin.Condition;

class SecurityRow$Decision
{
  final int decision;
  final Condition[] postponed;
  private final SecurityRow row;
  private final BundlePermissi
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