org.eclipse.osgi_3.8.2.v20130124-134944

 ((a[(i - 1)] == 'e') || (a[(i - 1)] == 'E')) && (
        (a[i] == 'l') || (a[i] == 'L')))
      {
        int matchlen = 10;
        mask |= 0x100;
      }
      else if ((i >= 6) && 
        ((a[(i - 6)] == 'c') || (a[(i - 6)] == 'C')) && 
        ((a[(i - 5)] == 'o') || (a[(i - 5)] == 'O')) && 
        ((a[(i - 4)] == 'n') || (a[(i - 4)] == 'N')) && 
        ((a[(i - 3)] == 't') || (a[(i - 3)] == 'T')) && 
        ((a[(i - 2)] == 'e') || (a[(i - 2)] == 'E')) && 
        ((a[(i - 1)] == 'x') || (a[(i - 1)] == 'X')) && (
        (a[i] == 't') || (a[i] == 'T')))
      {
        int matchlen = 7;
        mask |= 0x400;
      }
      else if ((i >= 4) && 
        ((a[(i - 4)] == 'w') || (a[(i - 4)] == 'W')) && 
        ((a[(i - 3)] == 'e') || (a[(i - 3)] == 'E')) && 
        ((a[(i - 2)] == 'a') || (a[(i - 2)] == 'A')) && 
        ((a[(i - 1)] == 'v') || (a[(i - 1)] == 'V')) && (
        (a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 5;
        mask |= 0x800;
      }
      else if ((i >= 0) && (a[i] == '*'))
      {
        int matchlen = 1;
        mask |= 0xFDF;
      }
      else
      {
        throw new IllegalArgumentException("invalid permission: " + actions);
      }
      int matchlen;
      seencomma = false;
      while ((i >= matchlen) && (!seencomma))
      {
        switch (a[(i - matchlen)])
        {
        case ',': 
          seencomma = true;
        case '\t': 
        case '\n': 
        case '\f': 
        case '\r': 
        case ' ': 
          break;
        default: 
          throw new IllegalArgumentException("invalid permission: " + actions);
        }
        i--;
      }
      i -= matchlen;
    }
    if (seencomma) {
      throw new IllegalArgumentException("invalid permission: " + actions);
    }
    return mask;
  }
  
  private static Filter parseFilter(String filterString)
  {
    if (filterString == null) {
      return null;
    }
    filterString = filterString.trim();
    if (filterString.equals("*")) {
      return null;
    }
    try
    {
      return FrameworkUtil.createFilter(filterString);
    }
    catch (InvalidSyntaxException e)
    {
      IllegalArgumentException iae = new IllegalArgumentException("invalid filter");
      iae.initCause(e);
      throw iae;
    }
  }
  
  public boolean implies(Permission p)
  {
    if (!(p instanceof AdminPermission)) {
      return false;
    }
    AdminPermission requested = (AdminPermission)p;
    if (bundle != null) {
      return false;
    }
    if (filter != null) {
      return false;
    }
    return implies0(requested, 0);
  }
  
  boolean implies0(AdminPermission requested, int effective)
  {
    effective |= action_mask;
    int desired = action_mask;
    if ((effective & desired) != desired) {
      return false;
    }
    Filter f = filter;
    if (f == null) {
      return true;
    }
    if (bundle == null) {
      return false;
    }
    Map<String, Object> requestedProperties = requested.getProperties();
    if (requestedProperties == null) {
      return true;
    }
    return f.matches(requestedProperties);
  }
  
  public String getActions()
  {
    String result = actions;
    if (result == null)
    {
      StringBuffer sb = new StringBuffer();
      
      int mask = action_mask;
      if ((mask & 0x1) == 1)
      {
        sb.append("class");
        sb.append(',');
      }
      if ((mask & 0x2) == 2)
      {
        sb.append("execute");
        sb.append(',');
      }
      if ((mask & 0x200) == 512)
      {
        sb.append("extensionLifecycle");
        sb.append(',');
      }
      if ((mask & 0x4) == 4)
      {
        sb.append("lifecycle");
        sb.append(',');
      }
      if ((mask & 0x8) == 8)
      {
        sb.append("listener");
        sb.append(',');
      }
      if ((mask & 0x10) == 16)
      {
        sb.append("metadata");
        sb.append(',');
      }
      if ((mask & 0x40) == 64)
      {
        sb.append("resolve");
        sb.append(',');
      }
      if ((mask & 0x80) == 128)
      {
        sb.append("resource");
        sb.append(',');
      }
      if ((mask & 0x100) == 256)
      {
        sb.append("startlevel");
        sb.append(',');
      }
      if ((mask & 0x400) == 1024)
      {
        sb.append("context");
        sb.append(',');
      }
      if ((mask & 0x800) == 2048)
      {
        sb.append("weave");
        sb.append(',');
      }
      if (sb.length() > 0) {
        sb.setLength(sb.length() - 1);
      }
      actions = (result = sb.toString());
    }
    return result;
  }
  
  public PermissionCollection newPermissionCollection()
  {
    return new AdminPermissionCollection();
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof AdminPermission)) {
      return false;
    }
    AdminPermission ap = (AdminPermission)obj;
    
    return (action_mask == action_mask) && ((bundle == bundle) || ((bundle != null) && (bundle.equals(bundle)))) && (filter == null ? filter == null : filter.equals(filter));
  }
  
  public int hashCode()
  {
    int h = 527 + getName().hashCode();
    h = 31 * h + getActions().hashCode();
    if (bundle != null) {
      h = 31 * h + bundle.hashCode();
    }
    return h;
  }
  
  private synchronized void writeObject(ObjectOutputStream s)
    throws IOException
  {
    if (bundle != null) {
      throw new NotSerializableException("cannot serialize");
    }
    if (actions == null) {
      getActions();
    }
    s.defaultWriteObject();
  }
  
  private synchronized void readObject(ObjectInputStream s)
    throws IOException, ClassNotFoundException
  {
    s.defaultReadObject();
    setTransients(parseFilter(getName()), parseActions(actions));
  }
  
  private Map<String, Object> getProperties()
  {
    Map<String, Object> result = properties;
    if (result != null) {
      return result;
    }
    Object mark = recurse.get();
    if (mark == bundle) {
      return null;
    }
    recurse.set(bundle);
    try
    {
      final Map<String, Object> map = new HashMap(4);
      AccessController.doPrivileged(new PrivilegedAction()
      {
        public Object run()
        {
          map.put("id", new Long(bundle.getBundleId()));
          map.put("location", bundle.getLocation());
          String name = bundle.getSymbolicName();
          if (name != null) {
            map.put("name", name);
          }
          SignerProperty signer = new SignerProperty(bundle);
          if (signer.isBundleSigned()) {
            map.put("signer", signer);
          }
          return null;
        }
      });
      return properties = map;
    }
    finally
    {
      recurse.set(null);
    }
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.AdminPermission
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectInputStream.GetField;
import java.io.ObjectOutputStream;
import java.io.ObjectOutputStream.PutField;
import java.io.ObjectStreamField;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

final class AdminPermissionCollection
  extends PermissionCollection
{
  private static final long serialVersionUID = 3906372644575328048L;
  private transient Map<String, AdminPermission> permissions;
  private boolean all_allowed;
  
  public AdminPermissionCollection()
  {
    permissions = new HashMap();
  }
  
  public void add(Permission permission)
  {
    if (!(permission instanceof AdminPermission)) {
      throw new IllegalArgumentException("invalid permission: " + permission);
    }
    if (isReadOnly()) {
      throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
    }
    AdminPermission ap = (AdminPermission)permission;
    if (bundle != null) {
      throw new IllegalArgumentException("cannot add to collection: " + ap);
    }
    String name = ap.getName();
    synchronized (this)
    {
      Map<String, AdminPermission> pc = permissions;
      AdminPermission existing = (AdminPermission)pc.get(name);
      if (existing != null)
      {
        int oldMask = action_mask;
        int newMask = action_mask;
        if (oldMask != newMask) {
          pc.put(name, new AdminPermission(filter, oldMask | newMask));
        }
      }
      else
      {
        pc.put(name, ap);
      }
      if ((!all_allowed) && 
        (name.equals("*"))) {
        all_allowed = true;
      }
    }
  }
  
  public boolean implies(Permission permission)
  {
    if (!(permission instanceof AdminPermission)) {
      return false;
    }
    AdminPermission requested = (AdminPermission)permission;
    if (filter != null) {
      return false;
    }
    int effective = 0;
    Collection<AdminPermission> perms;
    synchronized (this)
    {
      pc = permissions;
      if (all_allowed)
      {
        AdminPermission ap = (AdminPermission)pc.get("*");
        if (ap != null)
        {
          effective |= action_mask;
          int desired = action_mask;
          if ((effective & desired) == desired) {
            return true;
          }
        }
      }
      perms = pc.values();
    }
    Collection<AdminPermission> perms;
    for (Map<String, AdminPermission> pc = perms.iterator(); pc.hasNext();)
    {
      AdminPermission perm = (AdminPermission)pc.next();
      if (perm.implies0(requested, effective)) {
        return true;
      }
    }
    return false;
  }
  
  public synchronized Enumeration<Permission> elements()
  {
    List<Permission> all = new ArrayList(permissions.values());
    return Collections.enumeration(all);
  }
  
  private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("permissions", Hashtable.class), new ObjectStreamField("all_allowed", Boolean.TYPE) };
  
  private synchronized void writeObject(ObjectOutputStream out)
    throws IOException
  {
    Hashtable<String, AdminPermission> hashtable = new Hashtable(permissions);
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", hashtable);
    pfields.put("all_allowed", all_allowed);
    out.writeFields();
  }
  
  private synchronized void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    ObjectInputStream.GetField gfields = in.readFields();
    Hashtable<String, AdminPermission> hashtable = (Hashtable)gfields.get("permissions", null);
    permissions = new HashMap(hashtable);
    all_allowed = gfields.get("all_allowed", false);
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.AdminPermissionCollection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

public abstract interface AllServiceListener
  extends ServiceListener
{}

/* Location:
 * Qualified Name:     org.osgi.framework.AllServiceListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

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.List;
import java.util.Map;

public abstract interface Bundle
  extends Comparable<Bundle>
{
  public static final int UNINSTALLED = 1;
  public static final int INSTALLED = 2;
  public static final int RESOLVED = 4;
  public static final int STARTING = 8;
  public static final int STOPPING = 16;
  public static final int ACTIVE = 32;
  public static final int START_TRANSIENT = 1;
  public static final int START_ACTIVATION_POLICY = 2;
  public static final int STOP_TRANSIENT = 1;
  public static final int SIGNERS_ALL = 1;
  public static final int SIGNERS_TRUSTED = 2;
  
  public abstract int getState();
  
  public abstract void start(int paramInt)
    throws BundleException;
  
  public abstract void start()
    throws BundleException;
  
  public abstract void stop(int paramInt)
    throws BundleException;
  
  public abstract void stop()
    throws BundleException;
  
  public abstract void update(InputStream paramInputStream)
    throws BundleException;
  
  public abstract void update()
    throws BundleException;
  
  public abstract void uninstall()
    throws BundleException;
  
  public abstract Dictionary<String, String> getHeaders();
  
  public abstract long getBundleId();
  
  public abstract String getLocation();
  
  public abstract ServiceReference<?>[] getRegisteredServices();
  
  public abstract ServiceReference<?>[] getServicesInUse();
  
  public abstract boolean hasPermission(Object paramObject);
  
  public abstract URL getResource(String paramString);
  
  public abstract Dictionary<String, String> getHeaders(String paramString);
  
  public abstract String getSymbolicName();
  
  public abstract Class<?> loadClass(String paramString)
    throws ClassNotFoundException;
  
  public abstract Enumeration<URL> getResources(String paramString)
    throws IOException;
  
  public abstract Enumeration<String> getEntryPaths(String paramString);
  
  public abstract URL getEntry(String paramString);
  
  public abstract long getLastModified();
  
  public abstract Enumeration<URL> findEntries(String paramString1, String paramString2, boolean paramBoolean);
  
  public abstract BundleContext getBundleContext();
  
  public abstract Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int paramInt);
  
  public abstract Version getVersion();
  
  public abstract <A> A adapt(Class<A> paramClass);
  
  public abstract File getDataFile(String paramString);
}

/* Location:
 * Qualified Name:     org.osgi.framework.Bundle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

public abstract interface BundleActivator
{
  public abstract void start(BundleContext paramBundleContext)
    throws Exception;
  
  public abstract void stop(BundleContext paramBundleContext)
    throws Exception;
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleActivator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.Dictionary;

public abstract interface BundleContext
  extends BundleReference
{
  public abstract String getProperty(String paramString);
  
  public abstract Bundle getBundle();
  
  public abstract Bundle installBundle(String paramString, InputStream paramInputStream)
    throws BundleException;
  
  public abstract Bundle installBundle(String paramString)
    throws BundleException;
  
  public abstract Bundle getBundle(long paramLong);
  
  public abstract Bundle[] getBundles();
  
  public abstract void addServiceListener(ServiceListener paramServiceListener, String paramString)
    throws InvalidSyntaxException;
  
  public abstract void addServiceListener(ServiceListener paramServiceListener);
  
  public abstract void removeServiceListener(ServiceListener paramServiceListener);
  
  public abstract void addBundleListener(BundleListener paramBundleListener);
  
  public abstract void removeBundleListener(BundleListener paramBundleListener);
  
  public abstract void addFrameworkListener(FrameworkListener paramFrameworkListener);
  
  public abstract void removeFrameworkListener(FrameworkListener paramFrameworkListener);
  
  public abstract ServiceRegistration<?> registerService(String[] paramArrayOfString, Object paramObject, Dictionary<String, ?> paramDictionary);
  
  public abstract ServiceRegistration<?> registerService(String paramString, Object paramObject, Dictionary<String, ?> paramDictionary);
  
  public abstract <S> ServiceRegistration<S> registerService(Class<S> paramClass, S paramS, Dictionary<String, ?> paramDictionary);
  
  public abstract ServiceReference<?>[] getServiceReferences(String paramString1, String paramString2)
    throws InvalidSyntaxException;
  
  public abstract ServiceReference<?>[] getAllServiceReferences(String paramString1, String paramString2)
    throws InvalidSyntaxException;
  
  public abstract ServiceReference<?> getServiceReference(String paramString);
  
  public abstract <S> ServiceReference<S> getServiceReference(Class<S> paramClass);
  
  public abstract <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> paramClass, String paramString)
    throws InvalidSyntaxException;
  
  public abstract <S> S getService(ServiceReference<S> paramServiceReference);
  
  public abstract boolean ungetService(ServiceReference<?> paramServiceReference);
  
  public abstract File getDataFile(String paramString);
  
  public abstract Filter createFilter(String paramString)
    throws InvalidSyntaxException;
  
  public abstract Bundle getBundle(String paramString);
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.util.EventObject;

public class BundleEvent
  extends EventObject
{
  static final long serialVersionUID = 4080640865971756012L;
  private final Bundle bundle;
  private final int type;
  public static final int INSTALLED = 1;
  public static final int STARTED = 2;
  public static final int STOPPED = 4;
  public static final int UPDATED = 8;
  public static final int UNINSTALLED = 16;
  public static final int RESOLVED = 32;
  public static final int UNRESOLVED = 64;
  public static final int STARTING = 128;
  public static final int STOPPING = 256;
  public static final int LAZY_ACTIVATION = 512;
  private final Bundle origin;
  
  public BundleEvent(int type, Bundle bundle, Bundle origin)
  {
    super(bundle);
    if (origin == null) {
      throw new IllegalArgumentException("null origin");
    }
    this.bundle = bundle;
    this.type = type;
    this.origin = origin;
  }
  
  public BundleEvent(int type, Bundle bundle)
  {
    super(bundle);
    this.bundle = bundle;
    this.type = type;
    origin = bundle;
  }
  
  public Bundle getBundle()
  {
    return bundle;
  }
  
  public int getType()
  {
    return type;
  }
  
  public Bundle getOrigin()
  {
    return origin;
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleEvent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

public class BundleException
  extends Exception
{
  static final long serialVersionUID = 3571095144220455665L;
  private final int type;
  public static final int UNSPECIFIED = 0;
  public static final int UNSUPPORTED_OPERATION = 1;
  public static final int INVALID_OPERATION = 2;
  public static final int MANIFEST_ERROR = 3;
  public static final int RESOLVE_ERROR = 4;
  public static final int ACTIVATOR_ERROR = 5;
  public static final int SECURITY_ERROR = 6;
  public static final int STATECHANGE_ERROR = 7;
  public static final int NATIVECODE_ERROR = 8;
  public static final int DUPLICATE_BUNDLE_ERROR = 9;
  public static final int START_TRANSIENT_ERROR = 10;
  public static final int READ_ERROR = 11;
  public static final int REJECTED_BY_HOOK = 12;
  
  public BundleException(String msg, Throwable cause)
  {
    this(msg, 0, cause);
  }
  
  public BundleException(String msg)
  {
    this(msg, 0);
  }
  
  public BundleException(String msg, int type, Throwable cause)
  {
    super(msg, cause);
    this.type = type;
  }
  
  public BundleException(String msg, int type)
  {
    super(msg);
    this.type = type;
  }
  
  public Throwable getNestedException()
  {
    return getCause();
  }
  
  public Throwable getCause()
  {
    return super.getCause();
  }
  
  public Throwable initCause(Throwable cause)
  {
    return super.initCause(cause);
  }
  
  public int getType()
  {
    return type;
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.util.EventListener;

public abstract interface BundleListener
  extends EventListener
{
  public abstract void bundleChanged(BundleEvent paramBundleEvent);
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.BasicPermission;
import java.security.Permission;
import java.security.PermissionCollection;

public final class BundlePermission
  extends BasicPermission
{
  private static final long serialVersionUID = 3257846601685873716L;
  public static final String PROVIDE = "provide";
  public static final String REQUIRE = "require";
  public static final String HOST = "host";
  public static final String FRAGMENT = "fragment";
  private static final int ACTION_PROVIDE = 1;
  private static final int ACTION_REQUIRE = 2;
  private static final int ACTION_HOST = 4;
  private static final int ACTION_FRAGMENT = 8;
  private static final int ACTION_ALL = 15;
  static final int ACTION_NONE = 0;
  private transient int action_mask;
  private volatile String actions = null;
  
  public BundlePermission(String symbolicName, String actions)
  {
    this(symbolicName, parseActions(actions));
  }
  
  BundlePermission(String symbolicName, int mask)
  {
    super(symbolicName);
    setTransients(mask);
  }
  
  private synchronized void setTransients(int mask)
  {
    if ((mask == 0) || ((mask & 0xF) != mask)) {
      throw new IllegalArgumentException("invalid action string");
    }
    action_mask = mask;
  }
  
  synchronized int getActionsMask()
  {
    return action_mask;
  }
  
  private static int parseActions(String actions)
  {
    boolean seencomma = false;
    
    int mask = 0;
    if (actions == null) {
      return mask;
    }
    char[] a = actions.toCharArray();
    
    int i = a.length - 1;
    if (i < 0) {}
    while (i != -1)
    {
      return mask;
      char c;
      while ((i != -1) && (((c = a[i]) == ' ') || (c == '\r') || (c == '\n') || (c == '\f') || (c == '\t')))
      {
        char c;
        i--;
      }
      if ((i >= 6) && ((a[(i - 6)] == 'p') || (a[(i - 6)] == 'P')) && 
        ((a[(i - 5)] == 'r') || (a[(i - 5)] == 'R')) && 
        ((a[(i - 4)] == 'o') || (a[(i - 4)] == 'O')) && 
        ((a[(i - 3)] == 'v') || (a[(i - 3)] == 'V')) && 
        ((a[(i - 2)] == 'i') || (a[(i - 2)] == 'I')) && 
        ((a[(i - 1)] == 'd') || (a[(i - 1)] == 'D')) && (
        (a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 7;
        mask |= 0x3;
      }
      else if ((i >= 6) && ((a[(i - 6)] == 'r') || (a[(i - 6)] == 'R')) && 
        ((a[(i - 5)] == 'e') || (a[(i - 5)] == 'E')) && 
        ((a[(i - 4)] == 'q') || (a[(i - 4)] == 'Q')) && 
        ((a[(i - 3)] == 'u') || (a[(i - 3)] == 'U')) && 
        ((a[(i - 2)] == 'i') || (a[(i - 2)] == 'I')) && 
        ((a[(i - 1)] == 'r') || (a[(i - 1)] == 'R')) && (
        (a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 7;
        mask |= 0x2;
      }
      else if ((i >= 3) && ((a[(i - 3)] == 'h') || (a[(i - 3)] == 'H')) && 
        ((a[(i - 2)] == 'o') || (a[(i - 2)] == 'O')) && 
        ((a[(i - 1)] == 's') || (a[(i - 1)] == 'S')) && (
        (a[i] == 't') || (a[i] == 'T')))
      {
        int matchlen = 4;
        mask |= 0x4;
      }
      else if ((i >= 7) && ((a[(i - 7)] == 'f') || (a[(i - 7)] == 'F')) && 
        ((a[(i - 6)] == 'r') || (a[(i - 6)] == 'R')) && 
        ((a[(i - 5)] == 'a') || (a[(i - 5)] == 'A')) && 
        ((a[(i - 4)] == 'g') || (a[(i - 4)] == 'G')) && 
        ((a[(i - 3)] == 'm') || (a[(i - 3)] == 'M')) && 
        ((a[(i - 2)] == 'e') || (a[(i - 2)] == 'E')) && 
        ((a[(i - 1)] == 'n') || (a[(i - 1)] == 'N')) && (
        (a[i] == 't') || (a[i] == 'T')))
      {
        int matchlen = 8;
        mask |= 0x8;
      }
      else
      {
        throw new IllegalArgumentException("invalid permission: " + actions);
      }
      int matchlen;
      seencomma = false;
      while ((i >= matchlen) && (!seencomma))
      {
        switch (a[(i - matchlen)])
        {
        case ',': 
          seencomma = true;
        case '\t': 
        case '\n': 
        case '\f': 
        case '\r': 
        case ' ': 
          break;
        default: 
          throw new IllegalArgumentException("invalid permission: " + actions);
        }
        i--;
      }
      i -= matchlen;
    }
    if (seencomma) {
      throw new IllegalArgumentException("invalid permission: " + actions);
    }
    return mask;
  }
  
  public boolean implies(Permission p)
  {
    if (!(p instanceof BundlePermission)) {
      return false;
    }
    BundlePermission requested = (BundlePermission)p;
    
    int effective = getActionsMask();
    int desired = requested.getActionsMask();
    return ((effective & desired) == desired) && (super.implies(requested));
  }
  
  public String getActions()
  {
    String result = actions;
    if (result == null)
    {
      StringBuffer sb = new StringBuffer();
      boolean comma = false;
      if ((action_mask & 0x1) == 1)
      {
        sb.append("provide");
        comma = true;
      }
      if ((action_mask & 0x2) == 2)
      {
        if (comma) {
          sb.append(',');
        }
        sb.append("require");
        comma = true;
      }
      if ((action_mask & 0x4) == 4)
      {
        if (comma) {
          sb.append(',');
        }
        sb.append("host");
        comma = true;
      }
      if ((action_mask & 0x8) == 8)
      {
        if (comma) {
          sb.append(',');
        }
        sb.append("fragment");
      }
      actions = (result = sb.toString());
    }
    return result;
  }
  
  public PermissionCollection newPermissionCollection()
  {
    return new BundlePermissionCollection();
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof BundlePermission)) {
      return false;
    }
    BundlePermission bp = (BundlePermission)obj;
    
    return (getActionsMask() == bp.getActionsMask()) && (getName().equals(bp.getName()));
  }
  
  public int hashCode()
  {
    int h = 527 + getName().hashCode();
    h = 31 * h + getActions().hashCode();
    return h;
  }
  
  private synchronized void writeObject(ObjectOutputStream s)
    throws IOException
  {
    if (actions == null) {
      getActions();
    }
    s.defaultWriteObject();
  }
  
  private synchronized void readObject(ObjectInputStream s)
    throws IOException, ClassNotFoundException
  {
    s.defaultReadObject();
    setTransients(parseActions(actions));
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundlePermission
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectInputStream.GetField;
import java.io.ObjectOutputStream;
import java.io.ObjectOutputStream.PutField;
import java.io.ObjectStreamField;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

final class BundlePermissionCollection
  extends PermissionCollection
{
  private static final long serialVersionUID = 3258407326846433079L;
  private transient Map<String, BundlePermission> permissions;
  private boolean all_allowed;
  
  public BundlePermissionCollection()
  {
    permissions = new HashMap();
    all_allowed = false;
  }
  
  public void add(Permission permission)
  {
    if (!(permission instanceof BundlePermission)) {
      throw new IllegalArgumentException("invalid permission: " + permission);
    }
    if (isReadOnly()) {
      throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
    }
    BundlePermission bp = (BundlePermission)permission;
    String name = bp.getName();
    synchronized (this)
    {
      Map<String, BundlePermission> pc = permissions;
      BundlePermission existing = (BundlePermission)pc.get(name);
      if (existing != null)
      {
        int oldMask = existing.getActionsMask();
        int newMask = bp.getActionsMask();
        if (oldMask != newMask) {
          pc.put(name, new BundlePermission(name, oldMask | newMask));
        }
      }
      else
      {
        pc.put(name, bp);
      }
      if ((!all_allowed) && 
        (name.equals("*"))) {
        all_allowed = true;
      }
    }
  }
  
  public boolean implies(Permission permission)
  {
    if (!(permission instanceof BundlePermission)) {
      return false;
    }
    BundlePermission requested = (BundlePermission)permission;
    String requestedName = requested.getName();
    int desired = requested.getActionsMask();
    int effective = 0;
    synchronized (this)
    {
      Map<String, BundlePermission> pc = permissions;
      if (all_allowed)
      {
        BundlePermission bp = (BundlePermission)pc.get("*");
        if (bp != null)
        {
          effective |= bp.getActionsMask();
          if ((effective & desired) == desired) {
            return true;
          }
        }
      }
      BundlePermission bp = (BundlePermission)pc.get(requestedName);
      if (bp != null)
      {
        effective |= bp.getActionsMask();
        if ((effective & desired) == desired) {
          return true;
        }
      }
      int offset = requestedName.length() - 1;
      int last;
      while ((last = requestedName.lastIndexOf(".", offset)) != -1)
      {
        int last;
        requestedName = requestedName.substring(0, last + 1) + "*";
        bp = (BundlePermission)pc.get(requestedName);
        if (bp != null)
        {
          effective |= bp.getActionsMask();
          if ((effective & desired) == desired) {
            return true;
          }
        }
        offset = last - 1;
      }
      return false;
    }
  }
  
  public synchronized Enumeration<Permission> elements()
  {
    List<Permission> all = new ArrayList(permissions.values());
    return Collections.enumeration(all);
  }
  
  private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("permissions", Hashtable.class), new ObjectStreamField("all_allowed", Boolean.TYPE) };
  
  private synchronized void writeObject(ObjectOutputStream out)
    throws IOException
  {
    Hashtable<String, BundlePermission> hashtable = new Hashtable(permissions);
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", hashtable);
    pfields.put("all_allowed", all_allowed);
    out.writeFields();
  }
  
  private synchronized void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    ObjectInputStream.GetField gfields = in.readFields();
    Hashtable<String, BundlePermission> hashtable = (Hashtable)gfields.get("permissions", null);
    permissions = new HashMap(hashtable);
    all_allowed = gfields.get("all_allowed", false);
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundlePermissionCollection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

public abstract interface BundleReference
{
  public abstract Bundle getBundle();
}

/* Location:
 * Qualified Name:     org.osgi.framework.BundleReference
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.security.PrivilegedAction;
import java.util.Map;

class CapabilityPermission$1
  implements PrivilegedAction<Object>
{
  final CapabilityPermission this$0;
  
  CapabilityPermission$1(CapabilityPermission paramCapabilityPermission, Map paramMap) {}
  
  public Object run()
  {
    val$props.put("id", new Long(this$0.bundle.getBundleId()));
    val$props.put("location", this$0.bundle.getLocation());
    String name = this$0.bundle.getSymbolicName();
    if (name != null) {
      val$props.put("name", name);
    }
    SignerProperty signer = new SignerProperty(this$0.bundle);
    if (signer.isBundleSigned()) {
      val$props.put("signer", signer);
    }
    return null;
  }
}

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

import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

final class CapabilityPermission$Properties
  extends AbstractMap<String, Object>
{
  private final Map<String, Object> properties;
  private final Map<String, Object> attributes;
  private volatile transient Set<Map.Entry<String, Object>> entries;
  
  CapabilityPermission$Properties(Map<String, Object> properties, Map<String, Object> attributes)
  {
    this.properties = properties;
    this.attributes = attributes;
    entries = null;
  }
  
  public Object get(Object k)
  {
    if (!(k instanceof String)) {
      return null;
    }
    String key = (String)k;
    if (key.charAt(0) == '@') {
      return attributes.get(key.substring(1));
    }
    Object value = properties.get(key);
    if (value != null) {
      return value;
    }
    return attributes.get(key);
  }
  
  public Set<Map.Entry<String, Object>> entrySet()
  {
    if (entries != null) {
      return entries;
    }
    Set<Map.Entry<String, Object>> all = new HashSet(attributes.size() + properties.size());
    all.addAll(attributes.entrySet());
    all.addAll(properties.entrySet());
    return entries = Collections.unmodifiableSet(all);
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.CapabilityPermission.Properties
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.framework;

import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.AccessController;
import java.security.BasicPermission;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.PrivilegedAction;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public final class CapabilityPermission
  extends BasicPermission
{
  static final long serialVersionUID = -7662148639076511574L;
  public static final String REQUIRE = "require";
  public static final String PROVIDE = "provide";
  private static final int ACTION_REQUIRE = 1;
  private static final int ACTION_PROVIDE = 2;
  private static final int ACTION_ALL = 3;
  static final int ACTION_NONE = 0;
  transient int action_mask;
  private volatile String actions = null;
  final transient Map<String, Object> attributes;
  final transient Bundle bundle;
  transient Filter filter;
  private volatile transient Map<String, Object> properties;
  
  public CapabilityPermission(String name, String actions)
  {
    this(name, parseActions(actions));
    if ((filter != null) && ((action_mask & 0x3) != 1)) {
      throw new IllegalArgumentException("invalid action string for filter expression");
    }
  }
  
  public CapabilityPermission(String namespace, Map<String, ?> attributes, Bundle providingBundle, String actions)
  {
    super(namespace);
    setTransients(namespace, parseActions(actions));
    if (attributes == null) {
      throw new IllegalArgumentException("attributes must not be null");
    }
    if (providingBundle == null) {
      throw new IllegalArgumentException("bundle must not be null");
    }
    this.attributes = new HashMap(attributes);
    bundle = providingBundle;
    if ((action_mask & 0x3) != 1) {
      throw new IllegalArgumentException("invalid action string");
    }
  }
  
  CapabilityPermission(String name, int mask)
  {
    super(name);
    setTransients(name, mask);
    attributes = null;
    bundle = null;
  }
  
  private void setTransients(String name, int mask)
  {
    if ((mask == 0) || ((mask & 0x3) != mask)) {
      throw new IllegalArgumentException("invalid action string");
    }
    action_mask = mask;
    filter = parseFilter(name);
  }
  
  private static int parseActions(String actions)
  {
    boolean seencomma = false;
    
    int mask = 0;
    if (actions == null) {
      return mask;
    }
    char[] a = actions.toCharArray();
    
    int i = a.length - 1;
    if (i < 0) {}
    while (i != -1)
    {
      return mask;
      char c;
      while ((i != -1) && (((c = a[i]) == ' ') || (c == '\r') || (c == '\n') || (c == '\f') || (c == '\t')))
      {
        char c;
        i--;
      }
      if ((i >= 6) && ((a[(i - 6)] == 'r') || (a[(i - 6)] == 'R')) && 
        ((a[(i - 5)] == 'e') || (a[(i - 5)] == 'E')) && 
        ((a[(i - 4)] == 'q') || (a[(i - 4)] == 'Q')) && 
        ((a[(i - 3)] == 'u') || (a[(i - 3)] == 'U')) && 
        ((a[(i - 2)] == 'i') || (a[(i - 2)] == 'I')) && 
        ((a[(i - 1)] == 'r') || (a[(i - 1)] == 'R')) && (
        (a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 7;
        mask |= 0x1;
      }
      else if ((i >= 6) && ((a[(i - 6)] == 'p') || (a[(i - 6)] == 'P')) && 
        ((a[(i - 5)] == 'r') || (a[(i - 5)] == 'R')) && 
        ((a[(i - 4)] == 'o') || (a[(i - 4)] == 'O')) && 
        ((a[(i - 3)] == 'v') || (a[(i - 3)] == 'V')) && 
        ((a[(i - 2)] == 'i') || (a[(i - 2)] == 'I')) && 
        ((a[(i - 1)] == 'd') || (a[(i - 1)] == 'D')) && (
        (a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 7;
        mask |= 0x2;
      }
      else
      {
        throw new IllegalArgumentException("invalid permission: " + actions);
      }
      int matchlen;
      seencomma = false;
      while ((i >= matchlen) && (!seencomma))
      {
        switch (a[(i - matchlen)])
        {
        case ',': 
          seencomma = true;
        case '\t': 
        case '\n': 
        case '\f': 
        case '\r': 
        case ' ': 
          break;
        default: 
          throw new IllegalArgumentException("invalid permission: " + actions);
        }
        i--;
      }
      i -= matchlen;
    }
    if (seencomma) {
      throw new IllegalArgumentException("invalid permission: " + actions);
    }
    return mask;
  }
  
  private static Filter parseFilter(String filterString)
  {
    filterString = filterString.trim();
    if (filterString.charAt(0) != '(') {
      return null;
    }
    try
    {
      return FrameworkUtil.createFilter(filterString);
    }
    catch (InvalidSyntaxException e)
    {
      IllegalArgumentException iae = new IllegalArgumentException("invalid filter");
      iae.initCause(e);
      throw iae;
    }
  }
  
  public boolean implies(Permission p)
  {
    if (!(p instanceof CapabilityPermission)) {
      return false;
    }
    CapabilityPermission requested = (CapabilityPermission)p;
    if (bundle != null) {
      return false;
    }
    if (filter != null) {
      return false;
    }
    return implies0(requested, 0);
  }
  
  boolean implies0(CapabilityPermission requested, int effective)
  {
    effective |= action_mask;
    int desired = action_mask;
    if ((effective & desired) != desired) {
      return false;
    }
    Filter f = filter;
    if (f == null) {
      return super.implies(requested);
    }
    return f.matches(requested.getProperties());
  }
  
  public String getActions()
  {
    String result = actions;
    if (result == null)
    {
      StringBuffer sb = new StringBuffer();
      boolean comma = false;
      
      int mask = action_mask;
      if ((mask & 0x1) == 1)
      {
        sb.append("
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