Package org.osgi.service.condpermadmin

Examples of org.osgi.service.condpermadmin.Condition


                // TODO: check whether this is correct!
                break;
            }
            try
            {
                Condition condition = null;
                boolean add = false;
                Class clazz = Class.forName(m_conditionInfos[i].getType());

                synchronized (m_conditions)
                {
                    if (m_conditions[i] == null)
                    {
                        m_conditions[i] = createCondition(m_module.getBundle(),
                            clazz, m_conditionInfos[i]);
                    }
                    condition = m_conditions[i];
                }

                Object current = m_conditionStack.get();
                if (current != null)
                {
                    if (current instanceof HashSet)
                    {
                        if (((HashSet) current).contains(clazz))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (current == clazz)
                        {
                            return false;
                        }
                    }
                }

                if (condition.isPostponed())
                {
                    if (check && !permissions.implies(permission, null))
                    {
                        return false;
                    }
                    else
                    {
                        check = false;
                    }
                    posts.add(new Object[] { condition, new Integer(i) });
                }
                else
                {

                    if (current == null)
                    {
                        m_conditionStack.set(clazz);
                    }
                    else
                    {
                        if (current instanceof HashSet)
                        {
                            if (((HashSet) current).contains(clazz))
                            {
                                return false;
                            }
                            ((HashSet) current).add(clazz);
                        }
                        else
                        {
                            if (current == clazz)
                            {
                                return false;
                            }
                            HashSet frame = new HashSet();
                            frame.add(current);
                            frame.add(clazz);
                            m_conditionStack.set(frame);
                            current = frame;
                        }
                    }
                    try
                    {
                        boolean mutable = condition.isMutable();
                        boolean result = condition.isSatisfied();

                        if (!mutable
                            && ((condition != Condition.TRUE) && (condition != Condition.FALSE)))
                        {
                            synchronized (m_conditions)
View Full Code Here


                    continue outer;
                }
                for (Iterator iter2 = conditions.iterator(); iter2.hasNext();)
                {
                    Object[] condEntry = (Object[]) iter2.next();
                    Condition cond = (Condition) condEntry[0];
                    Dictionary context = (Dictionary) contexts.get(cond
                        .getClass());
                    if (context == null)
                    {
                        context = new Hashtable();
                        contexts.put(cond.getClass(), context);
                    }
                    Object current = m_conditionStack.get();
                    if (current == null)
                    {
                        m_conditionStack.set(cond.getClass());
                    }
                    else
                    {
                        if (current instanceof HashSet)
                        {
                            ((HashSet) current).add(cond.getClass());
                        }
                        else
                        {
                            HashSet frame = new HashSet();
                            frame.add(current);
                            frame.add(cond.getClass());
                            m_conditionStack.set(frame);
                            current = frame;
                        }
                    }
                    boolean result;
                    boolean mutable = cond.isMutable();
                    try
                    {
                        result = cond.isSatisfied(new Condition[] { cond },
                            context);
                    }
                    finally
                    {
                        if (current == null)
                        {
                            m_conditionStack.set(null);
                        }
                        else
                        {
                            ((HashSet) current).remove(cond.getClass());
                            if (((HashSet) current).isEmpty())
                            {
                                m_conditionStack.set(null);
                            }
                        }
View Full Code Here

         * If a good combination is found, it will immediately bubble
         * up.
         */
        Hashtable condContextDict = new Hashtable(2);
        // The remainder we will process recursively.
        Condition conds[][] = (Condition[][]) remainingSets.remove(0);
        for (int i = 0; i < conds.length; i++)
          if (recursiveCheck(remainingSets, conds[i], null, condContextDict, cc))
            return; // found a pass return without SecurityException
        throw new SecurityException("Conditions not satisfied"); //$NON-NLS-1$
      }
View Full Code Here

        condDict.put(conditions[i].getClass(), condList);
      }
      condList.add(conditions[i]);
    }
    if (remainingSets.size() > 0) {
      Condition conds[][] = (Condition[][]) remainingSets.get(0);
      Vector newSets = (Vector) remainingSets.clone();
      newSets.remove(0);
      for (int i = 0; i < conds.length; i++)
        if (recursiveCheck(newSets, conds[i], condDict, condContextDict, cc))
          return true;
      return false;
    }
    Enumeration keys = condDict.keys();
    while (keys.hasMoreElements()) {
      Class key = (Class) keys.nextElement();
      Vector conds = (Vector) condDict.get(key);
      if (conds.size() == 0)
        continue; // This should never happen since we only add to the condDict if there is a condition
      Condition condArray[] = (Condition[]) conds.toArray(new Condition[conds.size()]);
      Dictionary context = (Dictionary) condContextDict.get(key);
      if (context == null) {
        context = new Hashtable(2);
        condContextDict.put(key, context);
      }
View Full Code Here

  void checkConditionalPermissionInfo(ConditionalPermissionInfoImpl cpi) {
    try {
      // first remove the cpi incase of an update
      removeCPI(cpi);
      Condition conds[] = cpi.getConditions(bundle);
      if (conds == null) {
        /* Couldn't process the conditions, so we can't use them */
        return;
      }
      boolean satisfied = true;
      for (int i = 0; i < conds.length; i++) {
        Condition cond = conds[i];
        if (cond.isMutable()) {
          satisfied = false;
        } else if (!cond.isSatisfied()) {// Note: the RFC says if !mutable, evaluated must be true
          /*
           * We can just dump here since we have an immutable and
           * unsatisfied condition.
           */
          return;
 
View Full Code Here

      fsm = (FrameworkSecurityManager) sm;
    ConditionalPermissionSet cpsArray[] = (ConditionalPermissionSet[]) satisfiableCPSs.toArray(new ConditionalPermissionSet[0]);
    cpsLoop: for (int i = 0; i < cpsArray.length; i++) {
      if (cpsArray[i].isNonEmpty()) {
        newEmpty = false;
        Condition conds[] = cpsArray[i].getNeededConditions();
        if (conds == null)
          continue;
        // check mutable !isPostponed conditions first;
        // note that !mutable conditions have already been evaluated
        for (int j = 0; j < conds.length; j++)
View Full Code Here

    if (neededConditions == null || neededConditions.length == 0)
      return neededConditions;
    boolean foundNonNullCondition = false;
    /* We need to check to see if any conditions became immutable */
    for (int i = 0; i < neededConditions.length; i++) {
      Condition cond = neededConditions[i];
      if (cond == null)
        continue;
      if (!cond.isMutable()) {
        if (cond.isSatisfied()) {
          neededConditions[i] = null;
        } else {
          /*
           * We now have an immutable unsatisfied condition, this set
           * is no longer valid.
View Full Code Here

   * @return Condition object for the requested condition.
   */
  static public Condition getCondition(final Bundle bundle, ConditionInfo info) {
    ConditionInfo bundleLocationInfo = new ConditionInfo(
        BundleLocationCondition.class.getName(), info.getArgs());
    Condition result = BundleLocationCondition.getCondition(bundle,
        bundleLocationInfo);
    return result == Condition.TRUE ? Condition.FALSE: Condition.TRUE;
  }
View Full Code Here

TOP

Related Classes of org.osgi.service.condpermadmin.Condition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.