org.eclipse.osgi_3.8.2.v20130124-134944

      {
        entry = currentContent.getEntry(entryName);
      }
      catch (SecurityException e)
      {
        exception = e;
      }
      if (entry == null) {
        throw new InvalidContentException(NLS.bind(SignedContentMessages.file_is_removed_from_jar, entryName, currentContent.getBaseFile().toString()), exception);
      }
      entry.getBytes();
    }
  }
}

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

import org.eclipse.osgi.util.NLS;

public class SignedContentMessages
  extends NLS
{
  public static String file_is_removed_from_jar;
  public static String File_In_Jar_Is_Tampered;
  public static String Security_File_Is_Tampered;
  public static String Signature_Not_Verify;
  public static String SF_File_Parsing_Error;
  public static String PKCS7_SignerInfo_Version_Not_Supported;
  public static String PKCS7_Invalid_File;
  public static String PKCS7_Parse_Signing_Time;
  public static String Algorithm_Not_Supported;
  public static String Factory_SignedContent_Error;
  public static String Default_Trust_Keystore_Load_Failed;
  public static String Default_Trust_Read_Only;
  public static String Default_Trust_Cert_Not_Found;
  public static String Default_Trust_Existing_Cert;
  public static String Default_Trust_Existing_Alias;
  private static final String BUNDLE_PACKAGE = "org.eclipse.osgi.internal.signedcontent.";
  private static final String BUNDLE_FILENAME = "SignedContentMessages";
  private static final String BUNDLE_NAME = "org.eclipse.osgi.internal.signedcontent.SignedContentMessages";
  
  static
  {
    NLS.initializeMessages("org.eclipse.osgi.internal.signedcontent.SignedContentMessages", SignedContentMessages.class);
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
import org.eclipse.osgi.framework.util.KeyedElement;
import org.eclipse.osgi.signedcontent.SignedContent;
import org.eclipse.osgi.signedcontent.SignerInfo;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

public class SignedStorageHook
  implements StorageHook
{
  public static final String KEY = SignedStorageHook.class.getName();
  public static final int HASHCODE = KEY.hashCode();
  private static final int STORAGE_VERSION = 3;
  private static List<SignerInfo> savedSignerInfo = new ArrayList(5);
  private static long firstIDSaved = -1L;
  private static long lastIDSaved = -1L;
  private static List<SignerInfo> loadedSignerInfo = new ArrayList(5);
  private static long lastIDLoaded;
  private BaseData bundledata;
  SignedContentImpl signedContent;
  
  public int getStorageVersion()
  {
    return 3;
  }
  
  public StorageHook create(BaseData data)
    throws BundleException
  {
    SignedStorageHook hook = new SignedStorageHook();
    bundledata = data;
    return hook;
  }
  
  public void initialize(Dictionary<String, String> manifest)
    throws BundleException
  {}
  
  public StorageHook load(BaseData target, DataInputStream is)
    throws IOException
  {
    if (lastIDLoaded > target.getBundleID()) {
      loadedSignerInfo.clear();
    }
    lastIDLoaded = target.getBundleID();
    SignedStorageHook hook = new SignedStorageHook();
    bundledata = target;
    boolean signed = is.readBoolean();
    if (!signed) {
      return hook;
    }
    int numSigners = is.readInt();
    SignerInfo[] signerInfos = new SignerInfo[numSigners];
    for (int i = 0; i < numSigners; i++) {
      signerInfos[i] = readSignerInfo(is);
    }
    int resultsSize = is.readInt();
    Map<String, Object> contentMDResults = null;
    if (resultsSize > 0)
    {
      contentMDResults = new HashMap(resultsSize);
      for (int i = 0; i < resultsSize; i++)
      {
        String path = is.readUTF();
        int numEntrySigners = is.readInt();
        SignerInfo[] entrySigners = new SignerInfo[numEntrySigners];
        byte[][] entryResults = new byte[numEntrySigners][];
        for (int j = 0; j < numEntrySigners; j++)
        {
          entrySigners[j] = readSignerInfo(is);
          int resultSize = is.readInt();
          entryResults[j] = new byte[resultSize];
          is.readFully(entryResults[j]);
        }
        contentMDResults.put(path, new Object[] { entrySigners, entryResults });
      }
    }
    SignedContentImpl result = new SignedContentImpl(signerInfos, contentMDResults);
    for (int i = 0; i < numSigners; i++)
    {
      boolean hasTSA = is.readBoolean();
      if (hasTSA)
      {
        SignerInfo tsaSigner = readSignerInfo(is);
        Date signingDate = new Date(is.readLong());
        result.addTSASignerInfo(signerInfos[i], tsaSigner, signingDate);
      }
    }
    signedContent = result;
    return hook;
  }
  
  public void save(DataOutputStream os)
    throws IOException
  {
    getFirstLastID();
    if (firstIDSaved == bundledata.getBundleID()) {
      savedSignerInfo.clear();
    }
    if (lastIDSaved == bundledata.getBundleID()) {
      firstIDSaved = lastIDSaved = -1L;
    }
    os.writeBoolean(signedContent != null);
    if (signedContent == null) {
      return;
    }
    SignerInfo[] signerInfos = signedContent.getSignerInfos();
    os.writeInt(signerInfos.length);
    for (int i = 0; i < signerInfos.length; i++) {
      saveSignerInfo(signerInfos[i], os);
    }
    Map<String, Object> contentMDResults = signedContent.getContentMDResults();
    os.writeInt(contentMDResults == null ? -1 : contentMDResults.size());
    if (contentMDResults != null)
    {
      SignerInfo[] entrySigners;
      int i;
      for (Iterator localIterator = contentMDResults.entrySet().iterator(); localIterator.hasNext(); i < entrySigners.length)
      {
        Map.Entry<String, Object> entry = (Map.Entry)localIterator.next();
        String path = (String)entry.getKey();
        os.writeUTF(path);
        Object[] signerResults = (Object[])entry.getValue();
        entrySigners = (SignerInfo[])signerResults[0];
        byte[][] entryResults = (byte[][])signerResults[1];
        os.writeInt(entrySigners.length);
        i = 0; continue;
        saveSignerInfo(entrySigners[i], os);
        os.writeInt(entryResults[i].length);
        os.write(entryResults[i]);i++;
      }
    }
    for (int i = 0; i < signerInfos.length; i++)
    {
      SignerInfo tsaInfo = signedContent.getTSASignerInfo(signerInfos[i]);
      os.writeBoolean(tsaInfo != null);
      if (tsaInfo != null)
      {
        saveSignerInfo(tsaInfo, os);
        Date signingTime = signedContent.getSigningTime(signerInfos[i]);
        os.writeLong(signingTime != null ? signingTime.getTime() : Long.MIN_VALUE);
      }
    }
  }
  
  private void saveSignerInfo(SignerInfo signerInfo, DataOutputStream os)
    throws IOException
  {
    int cacheIdx = savedSignerInfo.indexOf(signerInfo);
    os.writeInt(cacheIdx);
    if (cacheIdx >= 0) {
      return;
    }
    Certificate[] certs = signerInfo.getCertificateChain();
    int anchorIndex = -1;
    os.writeInt(certs == null ? 0 : certs.length);
    if (certs != null) {
      for (int i = 0; i < certs.length; i++)
      {
        if (certs[i].equals(signerInfo.getTrustAnchor())) {
          anchorIndex = i;
        }
        try
        {
          certBytes = certs[i].getEncoded();
        }
        catch (CertificateEncodingException e)
        {
          byte[] certBytes;
          throw ((IOException)new IOException(e.getMessage()).initCause(e));
        }
        byte[] certBytes;
        os.writeInt(certBytes.length);
        os.write(certBytes);
      }
    }
    os.writeInt(anchorIndex);
    os.writeUTF(signerInfo.getMessageDigestAlgorithm());
    savedSignerInfo.add(signerInfo);
  }
  
  private SignerInfo readSignerInfo(DataInputStream is)
    throws IOException
  {
    int index = is.readInt();
    if (index >= 0) {
      return (SignerInfo)loadedSignerInfo.get(index);
    }
    int numCerts = is.readInt();
    Certificate[] certs = new Certificate[numCerts];
    for (int i = 0; i < numCerts; i++)
    {
      int certSize = is.readInt();
      byte[] certBytes = new byte[certSize];
      is.readFully(certBytes);
      try
      {
        certs[i] = PKCS7Processor.certFact.generateCertificate(new ByteArrayInputStream(certBytes));
      }
      catch (CertificateException e)
      {
        throw ((IOException)new IOException(e.getMessage()).initCause(e));
      }
    }
    int anchorIdx = is.readInt();
    SignerInfoImpl result = new SignerInfoImpl(certs, anchorIdx >= 0 ? certs[anchorIdx] : null, is.readUTF());
    loadedSignerInfo.add(result);
    return result;
  }
  
  private void getFirstLastID()
  {
    if (firstIDSaved >= 0L) {
      return;
    }
    Bundle[] bundles = bundledata.getAdaptor().getContext().getBundles();
    if (bundles.length > 1)
    {
      firstIDSaved = bundles[1].getBundleId();
      lastIDSaved = bundles[(bundles.length - 1)].getBundleId();
    }
  }
  
  public void copy(StorageHook storageHook) {}
  
  public void validate()
    throws IllegalArgumentException
  {}
  
  public Dictionary<String, String> getManifest(boolean firstLoad)
    throws BundleException
  {
    return null;
  }
  
  public boolean forgetStatusChange(int status)
  {
    return false;
  }
  
  public boolean forgetStartLevelChange(int startlevel)
  {
    return false;
  }
  
  public int getKeyHashCode()
  {
    return HASHCODE;
  }
  
  public boolean compare(KeyedElement other)
  {
    return other.getKey() == KEY;
  }
  
  public Object getKey()
  {
    return KEY;
  }
  
  public SignedContent getSignedContent()
  {
    return signedContent;
  }
}

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

import java.security.cert.Certificate;
import org.eclipse.osgi.signedcontent.SignerInfo;

public class SignerInfoImpl
  implements SignerInfo
{
  private final Certificate[] chain;
  private final String mdAlgorithm;
  private volatile Certificate trustAnchor;
  
  public SignerInfoImpl(Certificate[] chain, Certificate trustAnchor, String mdAlgorithm)
  {
    this.chain = chain;
    this.trustAnchor = trustAnchor;
    this.mdAlgorithm = mdAlgorithm;
  }
  
  public Certificate[] getCertificateChain()
  {
    return chain;
  }
  
  public Certificate getTrustAnchor()
  {
    return trustAnchor;
  }
  
  public boolean isTrusted()
  {
    return trustAnchor != null;
  }
  
  void setTrustAnchor(Certificate trustAnchor)
  {
    this.trustAnchor = trustAnchor;
  }
  
  public String getMessageDigestAlgorithm()
  {
    return mdAlgorithm;
  }
  
  public int hashCode()
  {
    int result = mdAlgorithm.hashCode();
    for (int i = 0; i < chain.length; i++) {
      result += chain[i].hashCode();
    }
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof SignerInfo)) {
      return false;
    }
    if (obj == this) {
      return true;
    }
    SignerInfo other = (SignerInfo)obj;
    if (!mdAlgorithm.equals(other.getMessageDigestAlgorithm())) {
      return false;
    }
    Certificate[] otherCerts = other.getCertificateChain();
    if (otherCerts.length != chain.length) {
      return false;
    }
    for (int i = 0; i < chain.length; i++) {
      if (!chain[i].equals(otherCerts[i])) {
        return false;
      }
    }
    return trustAnchor == null ? false : other.getTrustAnchor() == null ? true : trustAnchor.equals(other.getTrustAnchor());
  }
}

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

import java.security.cert.Certificate;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.FilterImpl;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine;
import org.eclipse.osgi.signedcontent.SignerInfo;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.util.tracker.ServiceTracker;

public class TrustEngineListener
{
  private static volatile TrustEngineListener instance;
  private final BundleContext context;
  private final ServiceTracker<AuthorizationEngine, AuthorizationEngine> authorizationTracker;
  static Class class$1;
  
  TrustEngineListener(BundleContext context)
  {
    this.context = context;
    
    String authEngineProp = FrameworkProperties.getProperty("osgi.signedcontent.authorization.engine");
    Filter filter = null;
    if (authEngineProp != null) {
      try
      {
        filter = FilterImpl.newInstance("(&(objectClass=" + AuthorizationEngine.class.getName() + ")(" + "osgi.signedcontent.authorization.engine" + "=" + authEngineProp + "))");
      }
      catch (InvalidSyntaxException e)
      {
        SignedBundleHook.log("Invalid authorization filter", 2, e);
      }
    }
    if (filter != null) {
      authorizationTracker = new ServiceTracker(context, filter, null);
    } else {
      authorizationTracker = new ServiceTracker(context, AuthorizationEngine.class.getName(), null);
    }
    authorizationTracker.open();
    instance = this;
  }
  
  public static TrustEngineListener getInstance()
  {
    return instance;
  }
  
  void stopTrustEngineListener()
  {
    authorizationTracker.close();
    instance = null;
  }
  
  public void addedTrustAnchor(Certificate anchor)
  {
    Bundle[] bundles = context.getBundles();
    Set<Bundle> unresolved = new HashSet();
    for (int i = 0; i < bundles.length; i++)
    {
      SignedContentImpl signedContent = getSignedContent(bundles[i]);
      if ((signedContent != null) && (signedContent.isSigned()))
      {
        SignerInfo[] infos = signedContent.getSignerInfos();
        for (int j = 0; j < infos.length; j++)
        {
          if (infos[j].getTrustAnchor() == null) {
            unresolved.add(bundles[i]);
          }
          SignerInfo tsa = signedContent.getTSASignerInfo(infos[j]);
          if ((tsa != null) && (tsa.getTrustAnchor() == null)) {
            unresolved.add(bundles[i]);
          }
        }
      }
      if (unresolved.contains(bundles[i]))
      {
        SignedBundleFile.determineTrust(signedContent, 2);
        
        checkAuthorization(signedContent, bundles[i]);
      }
    }
    if (unresolved.size() > 0) {
      resolveBundles((Bundle[])unresolved.toArray(new Bundle[unresolved.size()]), false);
    }
  }
  
  private void checkAuthorization(SignedContentImpl signedContent, Bundle bundle)
  {
    AuthorizationEngine authEngine = getAuthorizationEngine();
    if (authEngine != null) {
      authEngine.authorize(signedContent, bundle);
    }
  }
  
  AuthorizationEngine getAuthorizationEngine()
  {
    return (AuthorizationEngine)authorizationTracker.getService();
  }
  
  /* Error */
  private void resolveBundles(Bundle[] bundles, boolean refresh)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 261	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:context	Lorg/osgi/framework/BundleContext;
    //   4: getstatic 259	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:class$1	Ljava/lang/Class;
    //   7: dup
    //   8: ifnonnull +28 -> 36
    //   11: pop
    //   12: ldc 7
    //   14: invokestatic 264	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   17: dup
    //   18: putstatic 259	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:class$1	Ljava/lang/Class;
    //   21: goto +15 -> 36
    //   24: new 125	java/lang/NoClassDefFoundError
    //   27: dup_x1
    //   28: swap
    //   29: invokevirtual 270	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   32: invokespecial 265	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   35: athrow
    //   36: invokevirtual 263	java/lang/Class:getName	()Ljava/lang/String;
    //   39: invokeinterface 305 2 0
    //   44: astore_3
    //   45: aload_3
    //   46: ifnonnull +4 -> 50
    //   49: return
    //   50: aload_0
    //   51: getfield 261	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:context	Lorg/osgi/framework/BundleContext;
    //   54: aload_3
    //   55: invokeinterface 304 2 0
    //   60: checkcast 148	org/osgi/service/packageadmin/PackageAdmin
    //   63: astore 4
    //   65: aload 4
    //   67: ifnonnull +4 -> 71
    //   70: return
    //   71: iload_2
    //   72: ifeq +14 -> 86
    //   75: aload 4
    //   77: aload_1
    //   78: invokeinterface 306 2 0
    //   83: goto +31 -> 114
    //   86: aload 4
    //   88: aload_1
    //   89: invokeinterface 307 2 0
    //   94: pop
    //   95: goto +19 -> 114
    //   98: astore 5
    //   100: aload_0
    //   101: getfield 261	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:context	Lorg/osgi/framework/BundleContext;
    //   104: aload_3
    //   105: invokeinterface 303 2 0
    //   110: pop
    //   111: aload 5
    //   113: athrow
    //   114: aload_0
    //   115: getfield 261	org/eclipse/osgi/internal/signedcontent/TrustEngineListener:context	Lorg/osgi/framework/BundleContext;
    //   118: aload_3
    //   119: invokeinterface 303 2 0
    //   124: pop
    //   125: return
    // Line number table:
    //   Java source line #100	-> byte code offset #0
    //   Java source line #101	-> byte code offset #45
    //   Java source line #102	-> byte code offset #49
    //   Java source line #103	-> byte code offset #50
    //   Java source line #104	-> byte code offset #65
    //   Java source line #105	-> byte code offset #70
    //   Java source line #107	-> byte code offset #71
    //   Java source line #108	-> byte code offset #75
    //   Java source line #110	-> byte code offset #86
    //   Java source line #111	-> byte code offset #95
    //   Java source line #112	-> byte code offset #100
    //   Java source line #113	-> byte code offset #111
    //   Java source line #112	-> byte code offset #114
    //   Java source line #114	-> byte code offset #125
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	126	0	this	TrustEngineListener
    //   0	126	1	bundles	Bundle[]
    //   0	126	2	refresh	boolean
    //   44	75	3	ref	org.osgi.framework.ServiceReference<?>
    //   63	24	4	pa	org.osgi.service.packageadmin.PackageAdmin
    //   98	14	5	localObject	Object
    //   24	1	6	localClassNotFoundException	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   12	17	24	java/lang/ClassNotFoundException
    //   71	98	98	finally
  }
  
  public void removedTrustAnchor(Certificate anchor)
  {
    Bundle[] bundles = context.getBundles();
    Set<Bundle> usingAnchor = new HashSet();
    Set<SignerInfo> untrustedSigners = new HashSet();
    for (int i = 0; i < bundles.length; i++)
    {
      SignedContentImpl signedContent = getSignedContent(bundles[i]);
      if ((signedContent != null) && (signedContent.isSigned()))
      {
        SignerInfo[] infos = signedContent.getSignerInfos();
        for (int j = 0; j < infos.length; j++)
        {
          if (anchor.equals(infos[j].getTrustAnchor()))
          {
            untrustedSigners.add(infos[j]);
            usingAnchor.add(bundles[i]);
          }
          SignerInfo tsa = signedContent.getTSASignerInfo(infos[j]);
          if ((tsa != null) && (anchor.equals(tsa.getTrustAnchor())))
          {
            usingAnchor.add(bundles[i]);
            untrustedSigners.add(tsa);
          }
        }
      }
    }
    for (Iterator<SignerInfo> untrusted = untrustedSigners.iterator(); untrusted.hasNext();) {
      ((SignerInfoImpl)untrusted.next()).setTrustAnchor(null);
    }
    for (Iterator<Bundle> untrustedBundles = usingAnchor.iterator(); untrustedBundles.hasNext();)
    {
      Bundle bundle = (Bundle)untrustedBundles.next();
      SignedContentImpl signedContent = getSignedContent(bundle);
      
      SignedBundleFile.determineTrust(signedContent, 2);
      
      checkAuthorization(signedContent, bundle);
    }
    if (usingAnchor.size() > 0) {
      resolveBundles((Bundle[])usingAnchor.toArray(new Bundle[usingAnchor.size()]), true);
    }
  }
  
  private SignedContentImpl getSignedContent(Bundle bundle)
  {
    BaseData data = (BaseData)((AbstractBundle)bundle).getBundleData();
    SignedStorageHook hook = (SignedStorageHook)data.getStorageHook(SignedStorageHook.KEY);
    if (hook == null) {
      return null;
    }
    return (SignedContentImpl)hook.getSignedContent();
  }
}

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

import java.security.PrivilegedAction;
import org.osgi.framework.launch.Framework;

class Equinox$1
  implements PrivilegedAction<Framework>
{
  final Equinox this$0;
  
  Equinox$1(Equinox paramEquinox) {}
  
  public Framework run()
  {
    return this$0.createImpl0();
  }
}

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

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.PrivilegedAction;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.internal.baseadaptor.DevClassPathHelper;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.framework.launch.Framework;

public class Equinox
  implements Framework
{
  private static final String implName = "org.eclipse.osgi.framework.internal.core.EquinoxLauncher";
  private Framework impl;
  private final boolean useSeparateCL;
  private final Map<String, Object> configuration;
  
  public Equinox(Map<String, ?> configuration)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(new AllPermission());
    }
    useSeparateCL = FrameworkProperties.inUse();
    
    Map<String, Object> empty = Collections.EMPTY_MAP;
    this.configuration = (configuration == null ? empty : new HashMap(configuration));
  }
  
  private Framework createImpl()
  {
    if (System.getSecurityManager() == null) {
      return createImpl0();
    }
    (Framework)AccessController.doPrivileged(new PrivilegedAction()
    {
      public Framework run()
      {
        return createImpl0();
      }
    });
  }
  
  Framework createImpl0()
  {
    try
    {
      Class<?> implClazz = getImplClass();
      Constructor<?> constructor = implClazz.getConstructor(new Class[] { Map.class });
      return (Framework)constructor.newInstance(new Object[] { configuration });
    }
    catch (ClassNotFoundException localClassNotFoundException2)
    {
      throw new NoClassDefFoundError("org.eclipse.osgi.framework.internal.core.EquinoxLauncher");
    }
    catch (IllegalAccessException e)
    {
      throw new RuntimeException(e.getMessage(), e);
    }
    catch (NoSuchMethodException e)
    {
      throw new NoSuchMethodError(e.getMessage());
    }
    catch (InstantiationException e)
    {
      throw new RuntimeException(e.getMessage(), e);
    }
    catch (InvocationTargetException e)
    {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
  
  private Class<?> getImplClass()
    throws ClassNotFoundException
  {
    ClassLoader thisCL = getClass().getClassLoader();
    if ((!useSeparateCL) || (!(thisCL instanceof URLClassLoader))) {
      return Class.forName("org.eclipse.osgi.framework.internal.core.EquinoxLauncher");
    }
    URL[] cp = getFrameworkURLs((URLClassLoader)thisCL);
    EquinoxFWClassLoader fwCL = new EquinoxFWClassLoader(cp, thisCL);
    return fwCL.loadClass("org.eclipse.osgi.framework.internal.core.EquinoxLauncher");
  }
  
  /* Error */
  private URL[] getFrameworkURLs(URLClassLoader frameworkLoader)
  {
    // Byte code:
    //   0: aload_1
    //   1: invokevirtual 433	java/net/URLClassLoader:getURLs	()[Ljava/net/URL;
    //   4: astore_2
    //   5: new 210	java/util/ArrayList
    //   8: dup
    //   9: aload_2
    //   10: arraylength
    //   11: invokespecial 436	java/util/ArrayList:<init>	(I)V
    //   14: astore_3
    //   15: iconst_0
    //   16: istore 4
    //   18: goto +299 -> 317
    //   21: aconst_null
    //   22: astore 5
    //   24: aload_2
    //   25: iload 4
    //   27: aaload
    //   28: invokevirtual 428	java/net/URL:getFile	()Ljava/lang/String;
    //   31: ldc 2
    //   33: invokevirtual 418	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   36: ifeq +24 -> 60
    //   39: new 206	java/net/URL
    //   42: dup
    //   43: aload_2
    //   44: iload 4
    //   46: aaload
    //   47: ldc 4
    //   49: invokespecial 432	java/net/URL:<init>	(Ljava/net/URL;Ljava/lang/String;)V
    //   52: invokevirtual 427	java/net/URL:openStream	()Ljava/io/InputStream;
    //   55: astore 5
    //   57: goto +47 -> 104
    //   60: new 206	java/net/URL
    //   63: dup
    //   64: new 200	java/lang/StringBuffer
    //   67: dup
    //   68: ldc 5
    //   70: invokespecial 421	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   73: aload_2
    //   74: iload 4
    //   76: aaload
    //   77: invokevirtual 430	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   80: invokevirtual 422	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   83: ldc 1
    //   85: invokevirtual 422	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   88: ldc 4
    //   90: invokevirtual 422	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   93: invokevirtual 420	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   96: invokespecial 431	java/net/URL:<init>	(Ljava/lang/String;)V
    //   99: invokevirtual 427	java/net/URL:openStream	()Ljava/io/InputStream;
    //   102: astore 5
    //   104: aload 5
    //   106: new 217	org/eclipse/osgi/framework/util/Headers
    //   109: dup
    //   110: bipush 10
    //   112: invokespecial 440	org/eclipse/osgi/framework/util/Headers:<init>	(I)V
    //   115: invokestatic 455	org/eclipse/osgi/util/ManifestElement:parseBundleManifest	(Ljava/io/InputStream;Ljava/util/Map;)Ljava/util/Map;
    //   118: astore 6
    //   120: aload_0
    //   121: aload 6
    //   123: ldc 3
    //   125: invokespecial 449	org/eclipse/osgi/launch/Equinox:getValue	(Ljava/util/Map;Ljava/lang/String;)Ljava/lang/String;
    //   128: astore 7
    //   130: aload 7
    //   132: ifnonnull +20 -> 152
    //   135: aload 5
    //   137: ifnull +177 -> 314
    //   140: aload 5
    //   142: invokevirtual 402	java/io/InputStream:close	()V
    //   145: goto +169 -> 314
    //   148: pop
    //   149: goto +165 -> 314
    //   152: invokestatic 438	org/eclipse/osgi/framework/internal/core/Constants:getInternalSymbolicName	()Ljava/lang/String;
    //   155: astore 8
    //   157: aload 8
    //   159: aload 7
    //   161: invokevirtual 417	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   164: ifeq +28 -> 192
    //   167: aload_0
    //   168: aload_2
    //   169: iload 4
    //   171: aaload
    //   172: aload 7
    //   174: aload_3
    //   175: invokespecial 450	org/eclipse/osgi/launch/Equinox:addDevClassPaths	(Ljava/net/URL;Ljava/lang/String;Ljava/util/List;)V
    //   178: aload_3
    //   179: aload_2
    //   180: iload 4
    //   182: aaload
    //   183: invokeinterface 458 2 0
    //   188: pop
    //   189: goto +111 -> 300
    //   192: aload_0
    //   193: aload 6
    //   195: aload 8
    //   197: invokespecial 447	org/eclipse/osgi/launch/Equinox:isFrameworkFragment	(Ljava/util/Map;Ljava/lang/String;)Z
    //   200: ifne +20 -> 220
    //   203: aload 5
    //   205: ifnull +109 -> 314
    //   208: aload 5
    //   210: invokevirtual 402	java/io/InputStream:close	()V
    //   213: goto +101 -> 314
    //   216: pop
    //   217: goto +97 -> 314
    //   220: aload_0
    //   221: aload_2
    //   222: iload 4
    //   224: aaload
    //   225: aload 7
    //   227: aload_3
    //   228: invokespecial 450	org/eclipse/osgi/launch/Equinox:addDevClassPaths	(Ljava/net/URL;Ljava/lang/String;Ljava/util/List;)V
    //   231: aload_3
    //   232: aload_2
    //   233: iload 4
    //   235: aaload
    //   236: invokeinterface 458 2 0
    //   241: pop
    //   242: goto +58 -> 300
    //   245: pop
    //   246: aload 5
    //   248: ifnull +66 -> 314
    //   251: aload 5
    //   253: invokevirtual 402	java/io/InputStream:close	()V
    //   256: goto +58 -> 314
    //   259: pop
    //   260: goto +54 -> 314
    //   263: pop
    //   264: aload 5
    //   266: ifnull +48 -> 314
    //   269: aload 5
    //   271: invokevirtual 402	java/io/InputStream:close	()V
    //   274: goto +40 -> 314
    //   277: pop
    //   278: goto +36 -> 314
    //   281: astore 9
    //   283: aload 5
    //   285: ifnull +12 -> 297
    //   288: aload 5
    //   290: invokevirtual 402	java/io/InputStream:close	()V
    //   293: goto +4 -> 297
    //   296: pop
    //   297: aload 9
    //   299: athrow
    //   300: aload 5
    //   302: ifnull +12 -> 314
    //   305: aload 5
    //   307: invokevirtual 402	java/io/InputStream:close	()V
    //   310: goto +4 -> 314
    //   313: pop
    //   314: iinc 4 1
    //   317: iload 4
    //   319: aload_2
    //   320: arraylength
    //   321: if_icmplt -300 -> 21
    //   324: aload_3
    //   325: aload_3
    //   326: invokeinterface 457 1 0
    //   331: anewarray 206	java/net/URL
    //   334: invokeinterface 459 2 0
    //   339: checkcast 185	[Ljava/net/URL;
    //   342: areturn
    // Line number table:
    //   Java source line #88	-> byte code offset #0
    //   Java source line #89	-> byte code offset #5
    //   Java source line #90	-> byte code offset #15
    //   Java source line #92	-> byte code offset #21
    //   Java source line #94	-> byte code offset #24
    //   Java source line #95	-> byte code offset #39
    //   Java source line #96	-> byte code offset #57
    //   Java source line #97	-> byte code offset #60
    //   Java source line #99	-> byte code offset #104
    //   Java source line #100	-> byte code offset #120
    //   Java source line #101	-> byte code offset #130
    //   Java source line #120	-> byte code offset #135
    //   Java source line #122	-> byte code offset #140
    //   Java source line #123	-> byte code offset #145
    //   Java source line #102	-> byte code offset #149
    //   Java source line #103	-> byte code offset #152
    //   Java source line #104	-> byte code offset #157
    //   Java source line #106	-> byte code offset #167
    //   Java source line #107	-> byte code offset #178
    //   Java source line #108	-> byte code offset #189
    //   Java source line #109	-> byte code offset #192
    //   Java source line #120	-> byte code offset #203
    //   Java source line #122	-> byte code offset #208
    //   Java source line #123	-> byte code offset #213
    //   Java source line #110	-> byte code offset #217
    //   Java source line #112	-> byte code offset #220
    //   Java source line #113	-> byte code offset #231
    //   Java source line #115	-> byte code offset #242
    //   Java source line #120	-> byte code offset #246
    //   Java source line #122	-> byte code offset #251
    //   Java source line #123	-> byte code offset #256
    //   Java source line #116	-> byte code offset #260
    //   Java source line #117	-> byte code offset #263
    //   Java source line #120	-> byte code offset #264
    //   Java source line #122	-> byte code offset #269
    //   Java source line #123	-> byte code offset #274
    //   Java source line #118	-> byte code offset #278
    //   Java source line #119	-> byte code offset #281
    //   Java source line #120	-> byte code offset #283
    //   Java source line #122	-> byte code offset #288
    //   Java source line #123	-> byte code offset #293
    //   Java source line #126	-> byte code offset #297
    //   Java source line #120	-> byte code offset #300
    //   Java source line #122	-> byte code offset #305
    //   Java source line #123	-> byte code offset #310
    //   Java source line #90	-> byte code offset #314
    //   Java source line #128	-> byte code offset #324
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	343	0	this	Equinox
    //   0	343	1	frameworkLoader	URLClassLoader
    //   4	316	2	cp	URL[]
    //   14	312	3	result	List<URL>
    //   16	302	4	i	int
    //   22	284	5	manifest	InputStream
    //   118	4	6	headers	Map<String, String>
    //   152	42	6	headers	Map<String, String>
    //   220	1	6	headers	Map<String, String>
    //   128	3	7	bsnSpec	String
    //   152	21	7	bsnSpec	String
    //   220	6	7	bsnSpec	String
    //   155	41	8	internalBSN	String
    //   220	1	8	internalBSN	String
    //   281	17	9	localObject	Object
    //   148	1	15	localIOException1	IOException
    //   216	1	16	localIOException2	IOException
    //   245	1	17	localIOException3	IOException
    //   259	1	18	localIOException4	IOException
    //   263	1	19	localBundleException	BundleException
    //   277	1	20	localIOException5	IOException
    //   296	1	21	localIOException6	IOException
    //   313	1	22	localIOException7	IOException
    // Exception table:
    //   from	to	target	type
    //   140	145	148	java/io/IOException
    //   208	213	216	java/io/IOException
    //   24	135	245	java/io/IOException
    //   152	203	245	java/io/IOException
    //   220	242	245	java/io/IOException
    //   251	256	259	java/io/IOException
    //   24	135	263	org/osgi/framework/BundleException
    //   152	203	263	org/osgi/framework/BundleException
    //   220	242	263	org/osgi/framework/BundleException
    //   269	274	277	java/io/IOException
    //   24	135	281	finally
    //   152	203	281	finally
    //   220	246	281	finally
    //   263	264	281	finally
    //   288	293	296	java/io/IOException
    //   305	310	313	java/io/IOException
  }
  
  private void addDevClassPaths(URL cp, String bsn, List<URL> result)
  {
    if (!cp.getPath().endsWith("/")) {
      return;
    }
    String[] devPaths = DevClassPathHelper.getDevClassPath(bsn);
    if (devPaths == null) {
      return;
    }
    for (int i = 0; i < devPaths.length; i++) {
      try
      {
        char lastChar = devPaths[i].charAt(devPaths[i].length() - 1);
        URL url;
        URL url;
        if ((devPaths[i].endsWith(".jar")) || (lastChar == '/') || (lastChar == '\\')) {
          url = new URL(cp, devPaths[i]);
        } else {
          url = new URL(cp, devPaths[i] + "/");
        }
        result.add(url);
      }
      catch (MalformedURLException localMalformedURLException) {}
    }
  }
  
  private boolean isFrameworkFragment(Map<String, String> headers, String internalBSN)
  {
    String hostBSN = getValue(headers, "Fragment-Host");
    return (internalBSN.equals(hostBSN)) || ("system.bundle".equals(hostBSN));
  }
  
  private String getValue(Map<String, String> headers, String key)
  {
    String headerSpec = (String)headers.get(key);
    if (headerSpec == null) {
      return null;
    }
    try
    {
      elements = ManifestElement.parseHeader(key, headerSpec);
    }
    catch (BundleException localBundleException)
    {
      ManifestElement[] elements;
      return null;
    }
    ManifestElement[] elements;
    if (elements == null) {
      return null;
    }
    return elements[0].getValue();
  }
  
  private synchronized Framework getImpl()
  {
    if (impl == null) {
      impl = createImpl();
    }
    return impl;
  }
  
  public void init()
    throws BundleException
  {
    getImpl().init();
  }
  
  public FrameworkEvent waitForStop(long timeout)
    throws InterruptedException
  {
    return getImpl().waitForStop(timeout);
  }
  
  public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
  {
    return getImpl().findEntries(path, filePattern, recurse);
  }
  
  public BundleContext getBundleContext()
  {
    return getImpl().getBundleContext();
  }
  
  public long getBundleId()
  {
    return getImpl().getBundleId();
  }
  
  public URL getEntry(String path)
  {
    return getImpl().getEntry(path);
  }
  
  public Enumeration<String> getEntryPaths(String path)
  {
    return getImpl().getEntryPaths(path);
  }
  
  public Dictionary<String, String> getHeaders()
  {
    return getImpl().getHeaders();
  }
  
  public Dictionary<String, String> getHeaders(String locale)
  {
    return getImpl().getHeaders(locale);
  }
  
  public long getLastModified()
  {
    return getImpl().getLastModified();
  }
  
  public String getLocation()
  {
    return getImpl().getLocation();
  }
  
  public ServiceReference<?>[] getRegisteredServices()
  {
    return getImpl().getRegisteredServices();
  }
  
  public URL getResource(String name)
  {
    return getImpl().getResource(name);
  }
  
  public Enumeration<URL> getResources(String name)
    throws IOException
  {
    return getImpl().getResources(name);
  }
  
  public ServiceReference<?>[] getServicesInUse()
  {
    return getImpl().getServicesInUse();
  }
  
  public int getState()
  {
    return getImpl().getState();
  }
  
  public String getSymbolicName()
  {
    return getImpl().getSymbolicName();
  }
  
  public boolean hasPermission(Object permission)
  {
    return getImpl().hasPermission(permission);
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    return getImpl().loadClass(name);
  }
  
  public void start(int options)
    throws BundleException
  {
    getImpl().start(options);
  }
  
  public void start()
    throws BundleException
  {
    getImpl().start();
  }
  
  public void stop(int options)
    throws BundleException
  {
    getImpl().stop(options);
  }
  
  public void stop()
    throws BundleException
  {
    getImpl().stop();
  }
  
  public void uninstall()
    throws BundleException
  {
    getImpl().uninstall();
  }
  
  public void update()
    throws BundleException
  {
    getI
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 85 86 87

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