Package java.security

Examples of java.security.Permission


      PermissionCollection storage = LDAPRealm.loadPermissions(ctx, dn);
      PermissionCollection altered = new Permissions();
     
      boolean found = false;
      for (Enumeration enu=storage.elements(); enu.hasMoreElements(); ) {
        Permission p = (Permission)enu.nextElement();
        if (perm.equals(p)) {
          found = true;
        } else {
          altered.add(p);
        }
View Full Code Here


            stmt = conn.prepareStatement("insert into permission values(?,?,?,?)");
            int n = _permissions.size();
            for(int i=0; i<n; i++) {
              stmt.clearParameters();
              stmt.setInt(1, _id);
              Permission perm = (Permission)_permissions.get(i);
              stmt.setString(2, perm.getClass().getName());
              stmt.setString(3, perm.getName());
              stmt.setString(4, perm.getActions());
              stmt.execute();
            }
          } finally {
            close(stmt);
          }
View Full Code Here

            while(set.next()) {
              String type = set.getString(2);
              String name = set.getString(3);
              String actions = set.getString(4);
              try {
                Permission perm = PolicyPreferences.createPermission(
                  new String[] { type, name, actions });
                addInitialPermission(perm);
              } catch (Throwable t) {
                _realm.log().error(t);
                throw new OperationFailedException("Invalid permission: "+t.toString());
View Full Code Here

    {
  PermissionCollection perms = super.getPermissions(codesource);

  URL url = codesource.getLocation();

  Permission p;
  URLConnection urlConnection;

  try {
      urlConnection = url.openConnection();
      p = urlConnection.getPermission();
  } catch (java.io.IOException ioe) {
      p = null;
      urlConnection = null;
  }

  if (p instanceof FilePermission) {
      // if the permission has a separator char on the end,
      // it means the codebase is a directory, and we need
      // to add an additional permission to read recursively
      String path = p.getName();
      if (path.endsWith(File.separator)) {
    path += "-";
    p = new FilePermission(path, SecurityConstants.FILE_READ_ACTION);
      }
  } else if ((p == null) && (url.getProtocol().equals("file"))) {
      String path = url.getFile().replace('/', File.separatorChar);
            path = ParseUtil.decode(path);
      if (path.endsWith(File.separator))
    path += "-";
      p =  new FilePermission(path, SecurityConstants.FILE_READ_ACTION);
  } else {
      URL locUrl = url;
      if (urlConnection instanceof JarURLConnection) {
    locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
      }
      String host = locUrl.getHost();
      if (host != null && (host.length() > 0))
    p = new SocketPermission(host,
           SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
  }
  // make sure the person that created this class loader
  // would have this permission

  if (p != null) {
      final SecurityManager sm = System.getSecurityManager();
      if (sm != null) {
    final Permission fp = p;
    AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() throws SecurityException {
      sm.checkPermission(fp);
      return null;
        }
View Full Code Here

    public Permission getPermission() throws IOException {
  int port = url.getPort();
  port = port < 0 ? 80 : port;
  String host = url.getHost() + ":" + port;
  Permission permission = new SocketPermission(host, "connect");
  return permission;
    }
View Full Code Here

     * @see javax.management.MBeanServerFactory#createMBeanServer
     */
    public static synchronized MBeanServer getPlatformMBeanServer() {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            Permission perm = new MBeanServerPermission("createMBeanServer");
            sm.checkPermission(perm);
        }

        if (platformMBeanServer == null) {
            platformMBeanServer =
View Full Code Here

    protected void copyPermissions(final PermissionCollection src,
                                   final PermissionCollection dest)
    {
        for (Enumeration elem = src.elements(); elem.hasMoreElements();)
        {
            final Permission permission = (Permission) elem.nextElement();
            dest.add(permission);
        }
    }
View Full Code Here

                FileEntity ent = (FileEntity)_entities.get(new Integer(id));
                if (ent != null) {
                  try {
                    String[] s = new String[n-1];
                    System.arraycopy(args, 1, s, 0, n-1);
                    Permission perm = PolicyPreferences.createPermission(s);
                    if (perm != null) {
                      ent.addPermission(perm);
                    }
                  } catch (Throwable t) {
                    _zone.log().error(t);
View Full Code Here

  protected void addPermission(Permissions permissions, String values)
  {
    String[] args = parseValues(values);
    if (args.length > 0) {
      Permission perm = null;
      try {
        perm = createPermission(args);
      } catch (Throwable t) {
        throw new ConfigurationError("Couldn't set permission '"+args[0]+"', reason: "+t);
      }
View Full Code Here

 
 
  public static final Permission createPermission(String[] args)
    throws Throwable
  {
    Permission perm = null;
    String name = args[0];
    int n = args.length;
    if (name.equals("file")) {
      if (n >= 3) {
        perm = new java.io.FilePermission(args[1], args[2]);
View Full Code Here

TOP

Related Classes of java.security.Permission

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.