org.eclipse.osgi_3.8.2.v20130124-134944

require");
        comma = true;
      }
      if ((mask & 0x2) == 2)
      {
        if (comma) {
          sb.append(',');
        }
        sb.append("provide");
      }
      actions = (result = sb.toString());
    }
    return result;
  }
  
  public PermissionCollection newPermissionCollection()
  {
    return new CapabilityPermissionCollection();
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof CapabilityPermission)) {
      return false;
    }
    CapabilityPermission cp = (CapabilityPermission)obj;
    
    return (action_mask == action_mask) && (getName().equals(cp.getName())) && ((attributes == attributes) || ((attributes != null) && (attributes.equals(attributes)))) && (
      (bundle == bundle) || ((bundle != null) && (bundle.equals(bundle))));
  }
  
  public int hashCode()
  {
    int h = 527 + getName().hashCode();
    h = 31 * h + getActions().hashCode();
    if (attributes != null) {
      h = 31 * h + attributes.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(getName(), parseActions(actions));
  }
  
  private Map<String, Object> getProperties()
  {
    Map<String, Object> result = properties;
    if (result != null) {
      return result;
    }
    final Map<String, Object> props = new HashMap(5);
    props.put("capability.namespace", getName());
    if (bundle == null) {
      return properties = props;
    }
    AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        props.put("id", new Long(bundle.getBundleId()));
        props.put("location", bundle.getLocation());
        String name = bundle.getSymbolicName();
        if (name != null) {
          props.put("name", name);
        }
        SignerProperty signer = new SignerProperty(bundle);
        if (signer.isBundleSigned()) {
          props.put("signer", signer);
        }
        return null;
      }
    });
    return properties = new Properties(props, attributes);
  }
  
  private static final class 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;
    
    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
 * 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.Iterator;
import java.util.List;
import java.util.Map;

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

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

/**
 * @deprecated
 */
public abstract interface Configurable
{
  /**
   * @deprecated
   */
  public abstract Object getConfigurationObject();
}

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

public abstract interface Constants
{
  public static final String SYSTEM_BUNDLE_LOCATION = "System Bundle";
  public static final String SYSTEM_BUNDLE_SYMBOLICNAME = "system.bundle";
  public static final String BUNDLE_CATEGORY = "Bundle-Category";
  public static final String BUNDLE_CLASSPATH = "Bundle-ClassPath";
  public static final String BUNDLE_COPYRIGHT = "Bundle-Copyright";
  public static final String BUNDLE_DESCRIPTION = "Bundle-Description";
  public static final String BUNDLE_NAME = "Bundle-Name";
  public static final String BUNDLE_NATIVECODE = "Bundle-NativeCode";
  public static final String EXPORT_PACKAGE = "Export-Package";
  /**
   * @deprecated
   */
  public static final String EXPORT_SERVICE = "Export-Service";
  public static final String IMPORT_PACKAGE = "Import-Package";
  public static final String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
  /**
   * @deprecated
   */
  public static final String IMPORT_SERVICE = "Import-Service";
  public static final String BUNDLE_VENDOR = "Bundle-Vendor";
  public static final String BUNDLE_VERSION = "Bundle-Version";
  public static final String BUNDLE_DOCURL = "Bundle-DocURL";
  public static final String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
  public static final String BUNDLE_ACTIVATOR = "Bundle-Activator";
  public static final String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
  /**
   * @deprecated
   */
  public static final String PACKAGE_SPECIFICATION_VERSION = "specification-version";
  public static final String BUNDLE_NATIVECODE_PROCESSOR = "processor";
  public static final String BUNDLE_NATIVECODE_OSNAME = "osname";
  public static final String BUNDLE_NATIVECODE_OSVERSION = "osversion";
  public static final String BUNDLE_NATIVECODE_LANGUAGE = "language";
  /**
   * @deprecated
   */
  public static final String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
  public static final String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
  public static final String SINGLETON_DIRECTIVE = "singleton";
  public static final String FRAGMENT_ATTACHMENT_DIRECTIVE = "fragment-attachment";
  public static final String FRAGMENT_ATTACHMENT_ALWAYS = "always";
  public static final String FRAGMENT_ATTACHMENT_RESOLVETIME = "resolve-time";
  public static final String FRAGMENT_ATTACHMENT_NEVER = "never";
  public static final String BUNDLE_LOCALIZATION = "Bundle-Localization";
  public static final String BUNDLE_LOCALIZATION_DEFAULT_BASENAME = "OSGI-INF/l10n/bundle";
  public static final String REQUIRE_BUNDLE = "Require-Bundle";
  public static final String BUNDLE_VERSION_ATTRIBUTE = "bundle-version";
  public static final String FRAGMENT_HOST = "Fragment-Host";
  public static final String SELECTION_FILTER_ATTRIBUTE = "selection-filter";
  public static final String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion";
  public static final String VERSION_ATTRIBUTE = "version";
  public static final String BUNDLE_SYMBOLICNAME_ATTRIBUTE = "bundle-symbolic-name";
  public static final String RESOLUTION_DIRECTIVE = "resolution";
  public static final String RESOLUTION_MANDATORY = "mandatory";
  public static final String RESOLUTION_OPTIONAL = "optional";
  public static final String USES_DIRECTIVE = "uses";
  public static final String INCLUDE_DIRECTIVE = "include";
  public static final String EXCLUDE_DIRECTIVE = "exclude";
  public static final String MANDATORY_DIRECTIVE = "mandatory";
  public static final String VISIBILITY_DIRECTIVE = "visibility";
  public static final String VISIBILITY_PRIVATE = "private";
  public static final String VISIBILITY_REEXPORT = "reexport";
  public static final String EXTENSION_DIRECTIVE = "extension";
  public static final String EXTENSION_FRAMEWORK = "framework";
  public static final String EXTENSION_BOOTCLASSPATH = "bootclasspath";
  public static final String BUNDLE_ACTIVATIONPOLICY = "Bundle-ActivationPolicy";
  public static final String ACTIVATION_LAZY = "lazy";
  public static final String FRAMEWORK_VERSION = "org.osgi.framework.version";
  public static final String FRAMEWORK_VENDOR = "org.osgi.framework.vendor";
  public static final String FRAMEWORK_LANGUAGE = "org.osgi.framework.language";
  public static final String FRAMEWORK_OS_NAME = "org.osgi.framework.os.name";
  public static final String FRAMEWORK_OS_VERSION = "org.osgi.framework.os.version";
  public static final String FRAMEWORK_PROCESSOR = "org.osgi.framework.processor";
  /**
   * @deprecated
   */
  public static final String FRAMEWORK_EXECUTIONENVIRONMENT = "org.osgi.framework.executionenvironment";
  public static final String FRAMEWORK_BOOTDELEGATION = "org.osgi.framework.bootdelegation";
  public static final String FRAMEWORK_SYSTEMPACKAGES = "org.osgi.framework.system.packages";
  public static final String FRAMEWORK_SYSTEMPACKAGES_EXTRA = "org.osgi.framework.system.packages.extra";
  public static final String SUPPORTS_FRAMEWORK_EXTENSION = "org.osgi.supports.framework.extension";
  public static final String SUPPORTS_BOOTCLASSPATH_EXTENSION = "org.osgi.supports.bootclasspath.extension";
  public static final String SUPPORTS_FRAMEWORK_FRAGMENT = "org.osgi.supports.framework.fragment";
  public static final String SUPPORTS_FRAMEWORK_REQUIREBUNDLE = "org.osgi.supports.framework.requirebundle";
  public static final String FRAMEWORK_SECURITY = "org.osgi.framework.security";
  public static final String FRAMEWORK_SECURITY_OSGI = "osgi";
  public static final String FRAMEWORK_STORAGE = "org.osgi.framework.storage";
  public static final String FRAMEWORK_STORAGE_CLEAN = "org.osgi.framework.storage.clean";
  public static final String FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
  public static final String FRAMEWORK_LIBRARY_EXTENSIONS = "org.osgi.framework.library.extensions";
  public static final String FRAMEWORK_EXECPERMISSION = "org.osgi.framework.command.execpermission";
  public static final String FRAMEWORK_COMMAND_ABSPATH = "abspath";
  public static final String FRAMEWORK_TRUST_REPOSITORIES = "org.osgi.framework.trust.repositories";
  public static final String FRAMEWORK_WINDOWSYSTEM = "org.osgi.framework.windowsystem";
  public static final String FRAMEWORK_BEGINNING_STARTLEVEL = "org.osgi.framework.startlevel.beginning";
  public static final String FRAMEWORK_BUNDLE_PARENT = "org.osgi.framework.bundle.parent";
  public static final String FRAMEWORK_BUNDLE_PARENT_BOOT = "boot";
  public static final String FRAMEWORK_BUNDLE_PARENT_EXT = "ext";
  public static final String FRAMEWORK_BUNDLE_PARENT_APP = "app";
  public static final String FRAMEWORK_BUNDLE_PARENT_FRAMEWORK = "framework";
  public static final String OBJECTCLASS = "objectClass";
  public static final String SERVICE_ID = "service.id";
  public static final String SERVICE_PID = "service.pid";
  public static final String SERVICE_RANKING = "service.ranking";
  public static final String SERVICE_VENDOR = "service.vendor";
  public static final String SERVICE_DESCRIPTION = "service.description";
  public static final String FRAMEWORK_UUID = "org.osgi.framework.uuid";
  public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
  public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
  public static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
  public static final String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
  public static final String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
  public static final String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
  public static final String SERVICE_IMPORTED = "service.imported";
  public static final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
  public static final String SERVICE_INTENTS = "service.intents";
  public static final String PROVIDE_CAPABILITY = "Provide-Capability";
  public static final String REQUIRE_CAPABILITY = "Require-Capability";
  public static final String EFFECTIVE_DIRECTIVE = "effective";
  public static final String EFFECTIVE_RESOLVE = "resolve";
  public static final String EFFECTIVE_ACTIVE = "active";
  public static final String FILTER_DIRECTIVE = "filter";
  public static final String FRAMEWORK_SYSTEMCAPABILITIES = "org.osgi.framework.system.capabilities";
  public static final String FRAMEWORK_SYSTEMCAPABILITIES_EXTRA = "org.osgi.framework.system.capabilities.extra";
  public static final String FRAMEWORK_BSNVERSION = "org.osgi.framework.bsnversion";
  public static final String FRAMEWORK_BSNVERSION_MULTIPLE = "multiple";
  public static final String FRAMEWORK_BSNVERSION_SINGLE = "single";
  public static final String FRAMEWORK_BSNVERSION_MANAGED = "managed";
}

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

import java.util.Dictionary;
import java.util.Map;

public abstract interface Filter
{
  public abstract boolean match(ServiceReference<?> paramServiceReference);
  
  public abstract boolean match(Dictionary<String, ?> paramDictionary);
  
  public abstract String toString();
  
  public abstract boolean equals(Object paramObject);
  
  public abstract int hashCode();
  
  public abstract boolean matchCase(Dictionary<String, ?> paramDictionary);
  
  public abstract boolean matches(Map<String, ?> paramMap);
}

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

import java.util.EventObject;

public class FrameworkEvent
  extends EventObject
{
  static final long serialVersionUID = 207051004521261705L;
  private final Bundle bundle;
  private final Throwable throwable;
  private final int type;
  public static final int STARTED = 1;
  public static final int ERROR = 2;
  public static final int PACKAGES_REFRESHED = 4;
  public static final int STARTLEVEL_CHANGED = 8;
  public static final int WARNING = 16;
  public static final int INFO = 32;
  public static final int STOPPED = 64;
  public static final int STOPPED_UPDATE = 128;
  public static final int STOPPED_BOOTCLASSPATH_MODIFIED = 256;
  public static final int WAIT_TIMEDOUT = 512;
  
  /**
   * @deprecated
   */
  public FrameworkEvent(int type, Object source)
  {
    super(source);
    this.type = type;
    bundle = null;
    throwable = null;
  }
  
  public FrameworkEvent(int type, Bundle bundle, Throwable throwable)
  {
    super(bundle);
    this.type = type;
    this.bundle = bundle;
    this.throwable = throwable;
  }
  
  public Throwable getThrowable()
  {
    return throwable;
  }
  
  public Bundle getBundle()
  {
    return bundle;
  }
  
  public int getType()
  {
    return type;
  }
}

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

import java.util.EventListener;

public abstract interface FrameworkListener
  extends EventListener
{
  public abstract void frameworkEvent(FrameworkEvent paramFrameworkEvent);
}

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

import java.security.PrivilegedAction;

class FrameworkUtil$1
  implements PrivilegedAction<Object>
{
  private final Class val$classFromBundle;
  
  FrameworkUtil$1(Class paramClass) {}
  
  public Object run()
  {
    return val$classFromBundle.getClassLoader();
  }
}

/* Location:
 * Qualified Name:     org.osgi.framework.FrameworkUtil.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.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

final class FrameworkUtil$CaseInsensitiveMap
  extends AbstractMap<String, Object>
  implements Map<String, Object>
{
  private final Dictionary<String, ?> dictionary;
  private final String[] keys;
  
  FrameworkUtil$CaseInsensitiveMap(Dictionary<String, ?> dictionary)
  {
    if (dictionary == null)
    {
      this.dictionary = null;
      keys = new String[0];
      return;
    }
    this.dictionary = dictionary;
    List<String> keyList = new ArrayList(dictionary.size());
    for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();)
    {
      Object k = e.nextElement();
      if ((k instanceof String))
      {
        String key = (String)k;
        for (Iterator localIterator = keyList.iterator(); localIterator.hasNext();)
        {
          String i = (String)localIterator.next();
          if (key.equalsIgnoreCase(i)) {
            throw new IllegalArgumentException();
          }
        }
        keyList.add(key);
      }
    }
    keys = ((String[])keyList.toArray(new String[keyList.size()]));
  }
  
  public Object get(Object o)
  {
    String k = (String)o;
    String[] arrayOfString;
    int j = (arrayOfString = keys).length;
    for (int i = 0; i < j; i++)
    {
      String key = arrayOfString[i];
      if (key.equalsIgnoreCase(k)) {
        return dictionary.get(key);
      }
    }
    return null;
  }
  
  public Set<Map.Entry<String, Object>> entrySet()
  {
    throw new UnsupportedOperationException();
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.security.auth.x500.X500Principal;

final class FrameworkUtil$DNChainMatching
{
  private static final String MINUS_WILDCARD = "-";
  private static final String STAR_WILDCARD = "*";
  
  private static boolean rdnmatch(List<?> rdn, List<?> rdnPattern)
  {
    if (rdn.size() != rdnPattern.size()) {
      return false;
    }
    for (int i = 0; i < rdn.size(); i++)
    {
      String rdnNameValue = (String)rdn.get(i);
      String patNameValue = (String)rdnPattern.get(i);
      int rdnNameEnd = rdnNameValue.indexOf('=');
      int patNameEnd = patNameValue.indexOf('=');
      if ((rdnNameEnd != patNameEnd) || (!rdnNameValue.regionMatches(0, patNameValue, 0, rdnNameEnd))) {
        return false;
      }
      String patValue = patNameValue.substring(patNameEnd);
      String rdnValue = rdnNameValue.substring(rdnNameEnd);
      if ((!rdnValue.equals(patValue)) && (!patValue.equals("=*")) && (!patValue.equals("=#16012a"))) {
        return false;
      }
    }
    return true;
  }
  
  private static boolean dnmatch(List<?> dn, List<?> dnPattern)
  {
    int dnStart = 0;
    int patStart = 0;
    int patLen = dnPattern.size();
    if (patLen == 0) {
      return false;
    }
    if (dnPattern.get(0).equals("*"))
    {
      patStart = 1;
      patLen--;
    }
    if (dn.size() < patLen) {
      return false;
    }
    if (dn.size() > patLen)
    {
      if (!dnPattern.get(0).equals("*")) {
        return false;
      }
      dnStart = dn.size() - patLen;
    }
    for (int i = 0; i < patLen; i++) {
      if (!rdnmatch((List)dn.get(i + dnStart), (List)dnPattern.get(i + patStart))) {
        return false;
      }
    }
    return true;
  }
  
  private static List<Object> parseDNchainPattern(String dnChain)
  {
    if (dnChain == null) {
      throw new IllegalArgumentException("The DN chain must not be null.");
    }
    List<Object> 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);
    }
    for (int i = 0; i < parsed.size(); i++)
    {
      String dn = (String)parsed.get(i);
      if ((!dn.equals("*")) && (!dn.equals("-")))
      {
        List<Object> rdns = new ArrayList();
        if (dn.charAt(0) == '*')
        {
          if (dn.charAt(1) != ',') {
            throw new IllegalArgumentException("invalid wildcard prefix");
          }
          rdns.add("*");
          dn = new X500Principal(dn.substring(2)).getName("CANONICAL");
        }
        else
        {
          dn = new X500Principal(dn).getName("CANONICAL");
        }
        parseDN(dn, rdns);
        parsed.set(i, rdns);
      }
    }
    if (parsed.size() == 0) {
      throw new IllegalArgumentException("empty DN chain");
    }
    return parsed;
  }
  
  private static List<Object> parseDNchain(List<String> chain)
  {
    if (chain == null) {
      throw new IllegalArgumentException("DN chain must not be null.");
    }
    List<Object> result = new ArrayList(chain.size());
    for (Iterator localIterator = chain.iterator(); localIterator.hasNext();)
    {
      String dn = (String)localIterator.next();
      dn = new X500Principal(dn).getName("CANONICAL");
      
      List<Object> rdns = new ArrayList();
      parseDN(dn, rdns);
      result.add(rdns);
    }
    if (result.size() == 0) {
      throw new IllegalArgumentException("empty DN chain");
    }
    return result;
  }
  
  private static int skipSpaces(String dnChain, int startIndex)
  {
    while ((startIndex < dnChain.length()) && (dnChain.charAt(startIndex) == ' ')) {
      startIndex++;
    }
    return startIndex;
  }
  
  private static void parseDN(String dn, List<Object> rdn)
  {
    int startIndex = 0;
    char c = '\000';
    List<String> nameValues = new ArrayList();
    while (startIndex < dn.length())
    {
      for (int endIndex = startIndex; endIndex < dn.length(); endIndex++)
      {
        c = dn.charAt(endIndex);
        if ((c == ',') || (c == '+')) {
          break;
        }
        if (c == '\\') {
          endIndex++;
        }
      }
      if (endIndex > dn.length()) {
        throw new IllegalArgumentException("unterminated escape " + dn);
      }
      nameValues.add(dn.substring(startIndex, endIndex));
      if (c != '+')
      {
        rdn.add(nameValues);
        if (endIndex != dn.length()) {
          nameValues = new ArrayList();
        } else {
          nameValues = null;
        }
      }
      startIndex = endIndex + 1;
    }
    if (nameValues != null) {
      throw new IllegalArgumentException("improperly terminated DN " + dn);
    }
  }
  
  private static int skipWildCards(List<Object> dnChainPattern, int dnChainPatternIndex)
  {
    for (int i = dnChainPatternIndex; i < dnChainPattern.size(); i++)
    {
      Object dnPattern = dnChainPattern.get(i);
      if ((dnPattern instanceof String))
      {
        if ((!dnPattern.equals("*")) && (!dnPattern.equals("-"))) {
          throw new IllegalArgumentException("expected wildcard in DN pattern");
        }
      }
      else
      {
        if ((dnPattern instanceof List)) {
          break;
        }
        throw new IllegalArgumentException("expected String or List in DN Pattern");
      }
    }
    return i;
  }
  
  private static boolean dnChainMatch(List<Object> dnChain, int dnChainIndex, List<Object> dnChainPattern, int dnChainPatternIndex)
    throws IllegalArgumentException
  {
    if (dnChainIndex >= dnChain.size()) {
      return false;
    }
    if (dnChainPatternIndex >= dnChainPattern.size()) {
      return false;
    }
    Object dnPattern = dnChainPattern.get(dnChainPatternIndex);
    if ((dnPattern instanceof String))
    {
      if ((!dnPattern.equals("*")) && (!dnPattern.equals("-"))) {
        throw new IllegalArgumentException("expected wildcard in DN pattern");
      }
      if (dnPattern.equals("-")) {
        dnChainPatternIndex = skipWildCards(dnChainPattern, dnChainPatternIndex);
      } else {
        dnChainPatternIndex++;
      }
      if (dnChainPatternIndex >= dnChainPattern.size()) {
        return dnPattern.equals("-");
      }
      if (dnPattern.equals("*")) {
        return (dnChainMatch(dnChain, dnChainIndex, dnChainPattern, dnChainPatternIndex)) || (dnChainMatch(dnChain, dnChainIndex + 1, dnChainPattern, dnChainPatternIndex));
      }
      for (int i = dnChainIndex; i < dnChain.size(); i++) {
        if (dnChainMatch(dnChain, i, dnChainPattern, dnChainPatternIndex)) {
          return true;
        }
      }
    }
    else
    {
      if ((dnPattern instanceof List))
      {
        do
        {
          if (!dnmatch((List)dnChain.get(dnChainIndex), (List)dnPattern)) {
            return false;
          }
          dnChainIndex++;
          dnChainPatternIndex++;
          if ((dnChainIndex >= dnChain.size()) && (dnChainPatternIndex >= dnChainPattern.size())) {
            return true;
          }
          if (dnChainIndex >= dnChain.size())
          {
            dnChainPatternIndex = skipWildCards(dnChainPattern, dnChainPatternIndex);
            
            return dnChainPatternIndex >= dnChainPattern.size();
          }
          if (dnChainPatternIndex >= dnChainPattern.size()) {
            return false;
          }
          dnPattern = dnChainPattern.get(dnChainPatternIndex);
          if ((dnPattern instanceof String))
          {
            if ((!dnPattern.equals("*")) && (!dnPattern.equals("-"))) {
              throw new IllegalArgumentException("expected wildcard in DN pattern");
            }
            return dnChainMatch(dnChain, dnChainIndex, dnChainPattern, dnChainPatternIndex);
          }
        } while ((dnPattern instanceof List));
        throw new IllegalArgumentException("expected String or List in DN Pattern");
      }
      throw new IllegalArgumentException("expected String or List in DN Pattern");
    }
    return false;
  }
  
  static boolean match(String pattern, List<String> dnChain)
  {
    try
    {
      parsedDNChain = parseDNchain(dnChain);
    }
    catch (RuntimeException e)
    {
      List<Object> parsedDNChain;
      IllegalArgumentException iae = new IllegalArgumentException("Invalid DN chain: " + toString(dnChain));
      iae.initCause(e);
      throw iae;
    }
    List<Object> parsedDNChain;
    try
    {
      parsedDNPattern = parseDNchainPattern(pattern);
    }
    catch (RuntimeException e)
    {
      List<Object> parsedDNPattern;
      IllegalArgumentException iae = new IllegalArgumentException("Invalid match pattern: " + pattern);
      iae.initCause(e);
      throw iae;
    }
    List<Object> parsedDNPattern;
    return dnChainMatch(parsedDNChain, 0, parsedDNPattern, 0);
  }
  
  private static String toString(List<?> dnChain)
  {
    if (dnChain == null) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    for (Iterator<?> iChain = dnChain.iterator(); iChain.hasNext();)
    {
      sb.append(iChain.next());
      if (iChain.hasNext()) {
        sb.append("; ");
      }
    }
    return sb.toString();
  }
}

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

import java.util.ArrayList;
import java.util.List;

final class FrameworkUtil$FilterImpl$Parser
{
  private final String filterstring;
  private final char[] filterChars;
  private int pos;
  
  FrameworkUtil$FilterImpl$Parser(String filterstring)
  {
    this.filterstring = filterstring;
    filterChars = filterstring.toCharArray();
    pos = 0;
  }
  
  FrameworkUtil.FilterImpl parse()
    throws InvalidSyntaxException
  {
    try
    {
      filter = parse_filter();
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      FrameworkUtil.FilterImpl filter;
      throw new InvalidSyntaxException("Filter ended abruptly", filterstring, e);
    }
    FrameworkUtil.FilterImpl filter;
    if (pos != filterChars.length) {
      throw new InvalidSyntaxException("Extraneous trailing characters: " + filterstring.substring(pos), filterstring);
    }
    return filter;
  }
  
  private FrameworkUtil.FilterImpl parse_filter()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    if (filterChars[pos] != '(') {
      throw new InvalidSyntaxException("Missing '(': " + filterstring.substring(pos), filterstring);
    }
    pos += 1;
    
    FrameworkUtil.FilterImpl filter = parse_filtercomp();
    
    skipWhiteSpace();
    if (filterChars[pos] != ')') {
      throw new InvalidSyntaxException("Missing ')': " + filterstring.substring(pos), filterstring);
    }
    pos += 1;
    
    skipWhiteSpace();
    
    return filter;
  }
  
  private FrameworkUtil.FilterImpl parse_filtercomp()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    
    char c = filterChars[pos];
    switch (c)
    {
    case '&': 
      pos += 1;
      return parse_and();
    case '|': 
      pos += 1;
      return parse_or();
    case '!': 
      pos += 1;
      return parse_not();
    }
    return parse_item();
  }
  
  private FrameworkUtil.FilterImpl parse_and()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    List<FrameworkUtil.FilterImpl> operands = new ArrayList(10);
    while (filterChars[pos] == '(')
    {
      FrameworkUtil.FilterImpl child = parse_filter();
      operands.add(child);
    }
    return new FrameworkUtil.FilterImpl(7, null, operands.toArray(new FrameworkUtil.FilterImpl[operands.size()]));
  }
  
  private FrameworkUtil.FilterImpl parse_or()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    List<FrameworkUtil.FilterImpl> operands = new ArrayList(10);
    while (filterChars[pos] == '(')
    {
      FrameworkUtil.FilterImpl child = parse_filter();
      operands.add(child);
    }
    return new FrameworkUtil.FilterImpl(8, null, operands.toArray(new FrameworkUtil.FilterImpl[operands.size()]));
  }
  
  private FrameworkUtil.FilterImpl parse_not()
    throws InvalidSyntaxException
  {
    int lookahead = pos;
    skipWhiteSpace();
    if (filterChars[pos] != '(')
    {
      pos = (lookahead - 1);
      return parse_item();
    }
    FrameworkUtil.FilterImpl child = parse_filter();
    
    return new FrameworkUtil.FilterImpl(9, null, child);
  }
  
  private FrameworkUtil.FilterImpl parse_item()
    throws InvalidSyntaxException
  {
    String attr = parse_attr();
    
    skipWhiteSpace();
    switch (filterChars[pos])
    {
    case '~': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(2, attr, parse_value());
      }
      break;
    case '>': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(3, attr, parse_value());
      }
      break;
    case '<': 
      if (filterChars[(pos + 1)] == '=')
      {
        pos += 2;
        return new FrameworkUtil.FilterImpl(4, attr, parse_value());
      }
      break;
    case '=': 
      if (filterChars[(pos + 1)] == '*')
      {
        int oldpos = pos;
        pos += 2;
        skipWhiteSpace();
        if (filterChars[pos] == ')') {
          return new FrameworkUtil.FilterImpl(5, attr, null);
        }
        pos = oldpos;
      }
      pos += 1;
      Object string = parse_substring();
      if ((string instanceof String)) {
        return new FrameworkUtil.FilterImpl(1, attr, string);
      }
      return new FrameworkUtil.FilterImpl(6, attr, string);
    }
    throw new InvalidSyntaxException("Invalid operator: " + filterstring.substring(pos), filterstring);
  }
  
  private String parse_attr()
    throws InvalidSyntaxException
  {
    skipWhiteSpace();
    
    int begin = pos;
    int end = pos;
    
    char c = filterChars[pos];
    while ((c != '~') && (c != '<') && (c != '>') && (c != '=') && (c != '(') && (c != ')'))
    {
      pos += 1;
      if (!Character.isWhitespace(c)) {
        end = pos;
      }
      c = filterChars[pos];
    }
    int length = end - begin;
    if (length == 0) {
      throw new InvalidSyntaxException("Missing attr: " + filterstring.substring(pos), filterstring);
    }
    return new String(filterChars, begin, length);
  }
  
  private String parse_value()
    throws InvalidSyntaxException
  {
    StringBuffer sb = new StringBuffer(filterChars.length - pos);
    for (;;)
    {
      char c = filterChars[pos];
      switch (c)
      {
      case ')': 
        break;
      case '(': 
        throw new InvalidSyntaxException("Invalid value: " + filterstring.substring(pos), filterstring);
      case '\\': 
        pos += 1;
        c = filterChars[pos];
      default: 
        sb.append(c);
        pos += 1;
      }
    }
    if (sb.length() == 0) {
      throw new InvalidSyntaxException("Missing value: " + filterstring.substring(pos), filterstring);
    }
    return sb.toString();
  }
  
  private Object parse_substring()
    throws InvalidSyntaxException
  {
    StringBuffer sb = new StringBuffer(filterChars.length - pos);
    
    List<String> operands = new ArrayList(10);
    for (;;)
    {
      char c = filterChars[pos];
      switch (c)
      {
      case ')': 
        if (sb.length() <= 0) {
          break label222;
        }
        operands.add(sb.toString());
        
        break;
      case '(': 
        throw new InvalidSyntaxException("Invalid value: " + filterstring.substring(pos), filterstring);
      case '*': 
        if (sb.length() > 0) {
          operands.add(sb.toString());
        }
        sb.setLength(0);
        
        operands.add(null);
  
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