org.eclipse.osgi.services_3.3.100.v20120522-1822

tion
{
  static final long serialVersionUID = -7222111885230120581L;
  private final Hashtable permissions;
  private boolean all_allowed;
  
  public UserAdminPermissionCollection()
  {
    permissions = new Hashtable();
    all_allowed = false;
  }
  
  public void add(Permission permission)
  {
    if (!(permission instanceof UserAdminPermission)) {
      throw new IllegalArgumentException("Invalid permission: " + permission);
    }
    if (isReadOnly()) {
      throw new SecurityException("Attempt to add a Permission to a readonly PermissionCollection");
    }
    UserAdminPermission uap = (UserAdminPermission)permission;
    String name = uap.getName();
    synchronized (this)
    {
      UserAdminPermission existing = (UserAdminPermission)permissions.get(name);
      if (existing != null)
      {
        int oldMask = existing.getActionsMask();
        int newMask = uap.getActionsMask();
        if (oldMask != newMask) {
          permissions.put(name, new UserAdminPermission(name, oldMask | newMask));
        }
      }
      else
      {
        permissions.put(name, uap);
      }
      if ((!all_allowed) && 
        (name.equals("*"))) {
        all_allowed = true;
      }
    }
  }
  
  public boolean implies(Permission permission)
  {
    if (!(permission instanceof UserAdminPermission)) {
      return false;
    }
    UserAdminPermission requested = (UserAdminPermission)permission;
    String name = requested.getName();
    int desired = requested.getActionsMask();
    
    int effective = 0;
    UserAdminPermission x;
    synchronized (this)
    {
      if ((all_allowed) && (desired != 0))
      {
        UserAdminPermission x = (UserAdminPermission)permissions.get("*");
        if (x != null)
        {
          effective |= x.getActionsMask();
          if ((effective & desired) == desired) {
            return true;
          }
        }
      }
      x = (UserAdminPermission)permissions.get(name);
    }
    if (x != null)
    {
      effective |= x.getActionsMask();
      if ((effective & desired) == desired) {
        return true;
      }
    }
    int offset = name.length() - 1;
    int last;
    while ((last = name.lastIndexOf(".", offset)) != -1)
    {
      name = name.substring(0, last + 1) + "*";
      synchronized (this)
      {
        x = (UserAdminPermission)permissions.get(name);
      }
      if (x != null)
      {
        effective |= x.getActionsMask();
        if ((effective & desired) == desired) {
          return true;
        }
      }
      offset = last - 1;
    }
    return false;
  }
  
  public Enumeration elements()
  {
    return permissions.elements();
  }
}

/* Location:
 * Qualified Name:     org.osgi.service.useradmin.UserAdminPermissionCollection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.service.wireadmin;

public class BasicEnvelope
  implements Envelope
{
  private final Object value;
  private final Object identification;
  private final String scope;
  
  public BasicEnvelope(Object value, Object identification, String scope)
  {
    this.value = value;
    this.identification = identification;
    this.scope = scope;
  }
  
  public Object getValue()
  {
    return value;
  }
  
  public Object getIdentification()
  {
    return identification;
  }
  
  public String getScope()
  {
    return scope;
  }
}

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

public abstract interface Consumer
{
  public abstract void updated(Wire paramWire, Object paramObject);
  
  public abstract void producersConnected(Wire[] paramArrayOfWire);
}

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

public abstract interface Envelope
{
  public abstract Object getValue();
  
  public abstract Object getIdentification();
  
  public abstract String getScope();
}

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

public abstract interface Producer
{
  public abstract Object polled(Wire paramWire);
  
  public abstract void consumersConnected(Wire[] paramArrayOfWire);
}

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

import java.util.Dictionary;

public abstract interface Wire
{
  public abstract boolean isValid();
  
  public abstract boolean isConnected();
  
  public abstract Class[] getFlavors();
  
  public abstract void update(Object paramObject);
  
  public abstract Object poll();
  
  public abstract Object getLastValue();
  
  public abstract Dictionary getProperties();
  
  public abstract String[] getScope();
  
  public abstract boolean hasScope(String paramString);
}

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

import java.util.Dictionary;
import org.osgi.framework.InvalidSyntaxException;

public abstract interface WireAdmin
{
  public abstract Wire createWire(String paramString1, String paramString2, Dictionary paramDictionary);
  
  public abstract void deleteWire(Wire paramWire);
  
  public abstract void updateWire(Wire paramWire, Dictionary paramDictionary);
  
  public abstract Wire[] getWires(String paramString)
    throws InvalidSyntaxException;
}

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

import org.osgi.framework.ServiceReference;

public class WireAdminEvent
{
  private final ServiceReference reference;
  private final Wire wire;
  private final int type;
  private final Throwable throwable;
  public static final int PRODUCER_EXCEPTION = 1;
  public static final int CONSUMER_EXCEPTION = 2;
  public static final int WIRE_CREATED = 4;
  public static final int WIRE_UPDATED = 8;
  public static final int WIRE_DELETED = 16;
  public static final int WIRE_CONNECTED = 32;
  public static final int WIRE_DISCONNECTED = 64;
  public static final int WIRE_TRACE = 128;
  
  public WireAdminEvent(ServiceReference reference, int type, Wire wire, Throwable exception)
  {
    this.reference = reference;
    this.wire = wire;
    this.type = type;
    throwable = exception;
  }
  
  public ServiceReference getServiceReference()
  {
    return reference;
  }
  
  public Wire getWire()
  {
    return wire;
  }
  
  public int getType()
  {
    return type;
  }
  
  public Throwable getThrowable()
  {
    return throwable;
  }
}

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

public abstract interface WireAdminListener
{
  public abstract void wireAdminEvent(WireAdminEvent paramWireAdminEvent);
}

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

public abstract interface WireConstants
{
  public static final String WIREADMIN_PID = "wireadmin.pid";
  public static final String WIREADMIN_PRODUCER_COMPOSITE = "wireadmin.producer.composite";
  public static final String WIREADMIN_CONSUMER_COMPOSITE = "wireadmin.consumer.composite";
  public static final String WIREADMIN_PRODUCER_SCOPE = "wireadmin.producer.scope";
  public static final String WIREADMIN_CONSUMER_SCOPE = "wireadmin.consumer.scope";
  public static final String[] WIREADMIN_SCOPE_ALL = { "*" };
  public static final String WIREADMIN_PRODUCER_PID = "wireadmin.producer.pid";
  public static final String WIREADMIN_CONSUMER_PID = "wireadmin.consumer.pid";
  public static final String WIREADMIN_FILTER = "wireadmin.filter";
  public static final String WIREVALUE_CURRENT = "wirevalue.current";
  public static final String WIREVALUE_PREVIOUS = "wirevalue.previous";
  public static final String WIREVALUE_DELTA_ABSOLUTE = "wirevalue.delta.absolute";
  public static final String WIREVALUE_DELTA_RELATIVE = "wirevalue.delta.relative";
  public static final String WIREVALUE_ELAPSED = "wirevalue.elapsed";
  public static final String WIREADMIN_PRODUCER_FILTERS = "wireadmin.producer.filters";
  public static final String WIREADMIN_CONSUMER_FLAVORS = "wireadmin.consumer.flavors";
  public static final String WIREADMIN_PRODUCER_FLAVORS = "wireadmin.producer.flavors";
  public static final String WIREADMIN_EVENTS = "wireadmin.events";
}

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

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 WirePermission
  extends BasicPermission
{
  static final long serialVersionUID = -5583709391516569321L;
  public static final String PRODUCE = "produce";
  public static final String CONSUME = "consume";
  private static final int ACTION_PRODUCE = 1;
  private static final int ACTION_CONSUME = 2;
  private static final int ACTION_ALL = 3;
  private static final int ACTION_NONE = 0;
  private transient int action_mask;
  private volatile String actions = null;
  
  public WirePermission(String name, String actions)
  {
    this(name, parseActions(actions));
  }
  
  WirePermission(String name, int mask)
  {
    super(name);
    setTransients(mask);
  }
  
  private synchronized void setTransients(int mask)
  {
    if ((mask == 0) || ((mask & 0x3) != 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) {
      return mask;
    }
    while (i != -1)
    {
      char c;
      while ((i != -1) && (((c = a[i]) == ' ') || (c == '\r') || (c == '\n') || (c == '\f') || (c == '\t'))) {
        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)] == 'd') || (a[(i - 3)] == 'D')) && ((a[(i - 2)] == 'u') || (a[(i - 2)] == 'U')) && ((a[(i - 1)] == 'c') || (a[(i - 1)] == 'C')) && ((a[i] == 'e') || (a[i] == 'E')))
      {
        int matchlen = 7;
        mask |= 0x1;
      }
      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)] == 's') || (a[(i - 3)] == 'S')) && ((a[(i - 2)] == 'u') || (a[(i - 2)] == 'U')) && ((a[(i - 1)] == 'm') || (a[(i - 1)] == 'M')) && ((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;
  }
  
  public boolean implies(Permission p)
  {
    if ((p instanceof WirePermission))
    {
      WirePermission requested = (WirePermission)p;
      int requestedMask = requested.getActionsMask();
      return ((getActionsMask() & requestedMask) == requestedMask) && (super.implies(p));
    }
    return false;
  }
  
  public String getActions()
  {
    String result = actions;
    if (result == null)
    {
      StringBuffer sb = new StringBuffer();
      boolean comma = false;
      int mask = getActionsMask();
      if ((mask & 0x1) == 1)
      {
        sb.append("produce");
        comma = true;
      }
      if ((mask & 0x2) == 2)
      {
        if (comma) {
          sb.append(',');
        }
        sb.append("consume");
      }
      actions = (result = sb.toString());
    }
    return result;
  }
  
  public PermissionCollection newPermissionCollection()
  {
    return new WirePermissionCollection();
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof WirePermission)) {
      return false;
    }
    WirePermission wp = (WirePermission)obj;
    return (getActionsMask() == wp.getActionsMask()) && (getName().equals(wp.getName()));
  }
  
  public int hashCode()
  {
    int h = 527 + getName().hashCode();
    h = 31 * h + getActions().hashCode();
    return h;
  }
  
  public String toString()
  {
    StringBuffer sb = new StringBuffer();
    sb.append('(');
    sb.append(getClass().getName());
    sb.append(" \"");
    sb.append(getName());
    String a = getActions();
    if (a.length() > 0)
    {
      sb.append("\" \"");
      sb.append(a);
    }
    sb.append("\")");
    return sb.toString();
  }
  
  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.service.wireadmin.WirePermission
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.service.wireadmin;

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

final class WirePermissionCollection
  extends PermissionCollection
{
  static final long serialVersionUID = 2617521094909826016L;
  private final Hashtable permissions;
  private boolean all_allowed;
  
  public WirePermissionCollection()
  {
    permissions = new Hashtable();
    all_allowed = false;
  }
  
  public void add(Permission permission)
  {
    if (!(permission instanceof WirePermission)) {
      throw new IllegalArgumentException("invalid permission: " + permission);
    }
    if (isReadOnly()) {
      throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
    }
    WirePermission wp = (WirePermission)permission;
    String name = wp.getName();
    synchronized (this)
    {
      WirePermission existing = (WirePermission)permissions.get(name);
      if (existing != null)
      {
        int oldMask = existing.getActionsMask();
        int newMask = wp.getActionsMask();
        if (oldMask != newMask) {
          permissions.put(name, new WirePermission(name, oldMask | newMask));
        }
      }
      else
      {
        permissions.put(name, wp);
      }
      if ((!all_allowed) && 
        (name.equals("*"))) {
        all_allowed = true;
      }
    }
  }
  
  public boolean implies(Permission permission)
  {
    if (!(permission instanceof WirePermission)) {
      return false;
    }
    WirePermission requested = (WirePermission)permission;
    
    int desired = requested.getActionsMask();
    int effective = 0;
    String name = requested.getName();
    WirePermission x;
    synchronized (this)
    {
      if (all_allowed)
      {
        WirePermission x = (WirePermission)permissions.get("*");
        if (x != null)
        {
          effective |= x.getActionsMask();
          if ((effective & desired) == desired) {
            return true;
          }
        }
      }
      x = (WirePermission)permissions.get(name);
    }
    if (x != null)
    {
      effective |= x.getActionsMask();
      if ((effective & desired) == desired) {
        return true;
      }
    }
    int offset = name.length() - 1;
    int last;
    while ((last = name.lastIndexOf(".", offset)) != -1)
    {
      name = name.substring(0, last + 1) + "*";
      synchronized (this)
      {
        x = (WirePermission)permissions.get(name);
      }
      if (x != null)
      {
        effective |= x.getActionsMask();
        if ((effective & desired) == desired) {
          return true;
        }
      }
      offset = last - 1;
    }
    return false;
  }
  
  public Enumeration elements()
  {
    return permissions.elements();
  }
}

/* Location:
 * Qualified Name:     org.osgi.service.wireadmin.WirePermissionCollection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2 3

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-2017. Infinite Loop Ltd