Package org.osgi.service.permissionadmin

Examples of org.osgi.service.permissionadmin.PermissionInfo


  /**
   *
   */
  public PermissionInfoStorage(FrameworkContext ctx) {
    debug = ctx.debug;
    initialDefault = new PermissionInfo[] { new PermissionInfo(DEFAULTPERM) };
    defaultPermissions = initialDefault;

    permDir = Util.getFileStorage(ctx, "perms");
    if (permDir == null) {
      System.err.println("Property org.osgi.framework.dir not set," +
View Full Code Here


          return;
        } else if ("".equals(line)) {
          // Correct end with double NL
          break;
        }
        piv.add(new PermissionInfo(line));
        c = in.read();
      }
      if (c == -1) {
        throw new IOException("Premature EOF when parsing permission file: " + fh.getName());
      }
View Full Code Here

        } while(c != ec);
        String info = new String(eca, start_pos, pos - start_pos);
        if (c == ']') {
          cal.add(new ConditionInfo(info));
        } else {
          pal.add(new PermissionInfo(info));
        }
      }
      if (!seenPermInfo) {
        throw new IllegalArgumentException("Permissions must contain atleast one element");
      }
View Full Code Here

      pi = permissionAdmin.getDefaultPermissions();
    } else {
      loc = (String) opts.get("-l");
      pi = permissionAdmin.getPermissions(loc);
    }
    PermissionInfo pia;
    try {
      pia = new PermissionInfo((String)opts.get("type"),
                               (String)opts.get("name"),
                               (String)opts.get("actions"));
    } catch (IllegalArgumentException e) {
      out.println("ERROR! " + e.getMessage());
      out.println("PermissionInfo type = " + opts.get("type"));
View Full Code Here

        if (cpi.endsWith(endChar)) {
          try {
            if (endChar == "]") {
              cis.addElement(new ConditionInfo(buf.toString()));
            } else {
              pis.addElement(new PermissionInfo(buf.toString()));
            }
          } catch (IllegalArgumentException e) {
            out.println("ERROR! Failed to instanciate: " + buf.toString()
                + " " + e.getMessage());
            return 1;
View Full Code Here

                char c = encoded[pos++];
                if (c != ')') {
                        throw new IllegalArgumentException(
                                        "expecting close parenthesis");
                }
                permissions.add(new PermissionInfo(parsedType,parsedName, parsedActions));
                return pos;
        }
        catch (ArrayIndexOutOfBoundsException e) {
                throw new IllegalArgumentException("parsing terminated abruptly");
        }
View Full Code Here

    public PermissionInfo[] getImplicit(Bundle bundle)
    {
        return new PermissionInfo[] {
            IMPLICIT[0],
            new PermissionInfo(AdminPermission.class.getName(), "(id="
                + bundle.getBundleId() + ")", AdminPermission.METADATA),
            new PermissionInfo(AdminPermission.class.getName(), "(id="
                + bundle.getBundleId() + ")", AdminPermission.RESOURCE),
            new PermissionInfo(AdminPermission.class.getName(), "(id="
                + bundle.getBundleId() + ")", AdminPermission.CONTEXT) };
    }
View Full Code Here

                            {
                                name += postfix;
                            }
                        }
                    }
                    Permission source = createPermission(new PermissionInfo(
                        FilePermission.class.getName(), name,
                        m_permissionInfos[i].getActions()), targetClass);
                    if (source.implies(target))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        Object current = m_stack.get();

        if (current == null)
        {
            m_stack.set(targetClass);
        }
        else
        {
            if (current instanceof HashSet)
            {
                if (((HashSet) current).contains(targetClass))
                {
                    return false;
                }
                ((HashSet) current).add(targetClass);
            }
            else
            {
                if (current == targetClass)
                {
                    return false;
                }
                HashSet frame = new HashSet();
                frame.add(current);
                frame.add(targetClass);
                m_stack.set(frame);
                current = frame;
            }
        }

        try
        {
            SoftReference collectionEntry = null;

            PermissionCollection collection = null;

            synchronized (m_cache)
            {
                collectionEntry = (SoftReference) m_cache.get(targetClass);
            }

            if (collectionEntry != null)
            {
                collection = (PermissionCollection) collectionEntry.get();
            }

            if (collection == null)
            {
                collection = target.newPermissionCollection();

                if (collection == null)
                {
                    collection = new DefaultPermissionCollection();
                }

                for (int i = 0; i < m_permissionInfos.length; i++)
                {
                    PermissionInfo permissionInfo = m_permissionInfos[i];
                    String infoType = permissionInfo.getType();
                    String permissionType = targetClass.getName();

                    if (infoType.equals(permissionType))
                    {
                        Permission permission = createPermission(
View Full Code Here

                            if (trim.startsWith("#") || trim.startsWith("//")
                                || (trim.length() == 0))
                            {
                                continue;
                            }
                            perms.add(new PermissionInfo(line));
                        }

                        permissions = (PermissionInfo[]) perms
                            .toArray(new PermissionInfo[perms.size()]);
                    }
View Full Code Here

        String[] serviceLocation = permAdminService.getLocations();
        String[] mBeanLocations = mBean.listLocations();
        assertArrayEquals(serviceLocation, mBeanLocations);

        PermissionInfo defPerm = new PermissionInfo("AllPermission", "*", "*");
        permAdminService.setDefaultPermissions(new PermissionInfo[]{defPerm});
        PermissionInfo[] permissions = permAdminService.getDefaultPermissions();
        assertNotNull(permissions);

        String[] encoded = toEncodedPerm(permissions);
        String[] mBeanDefPermissions = mBean.listDefaultPermissions();
        assertArrayEquals(encoded, mBeanDefPermissions);
       
        Bundle a = getBundle("org.apache.aries.jmx.test.bundlea");
        assertNotNull(a);
       
        String location = a.getLocation();
       
        PermissionInfo bundleaPerm = new PermissionInfo("ServicePermission", "ServiceA", "GET");
        mBean.setPermissions(location, new String[]{bundleaPerm.getEncoded()});
       
        String[] serviceBundleaPerm = toEncodedPerm(permAdminService.getPermissions(location));
        String[] mBeanBundleaPerm = mBean.getPermissions(location);
        assertNotNull(mBeanBundleaPerm);
        assertArrayEquals(serviceBundleaPerm, mBeanBundleaPerm);
       
        PermissionInfo defaultPerm = new PermissionInfo("AllPermission", "*", "GET");
        mBean.setDefaultPermissions(new String[]{defaultPerm.getEncoded()});
       
        String[] serviceDefaultPerm = toEncodedPerm(permAdminService.getDefaultPermissions());
        String[] mBeanDefaultPerm = mBean.listDefaultPermissions();
        assertNotNull(mBeanDefaultPerm);
        assertArrayEquals(serviceDefaultPerm, mBeanDefaultPerm);
View Full Code Here

TOP

Related Classes of org.osgi.service.permissionadmin.PermissionInfo

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.