Package com.sun.enterprise.security.provider.PolicyParser

Examples of com.sun.enterprise.security.provider.PolicyParser.GrantEntry


  // load unchecked grants in parser
  if (uncheckedPermissions != null) {
      Enumeration pEnum = uncheckedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    parser.add(grant);
      }
  }

  // load role based grants in parser
  if (rolePermissionsTable != null) {
      Iterator roleIt = rolePermissionsTable.keySet().iterator();
      while (roleIt.hasNext()) {
    boolean withPrincipals = false;
    String roleName = (String) roleIt.next();
    Permissions rolePerms = getRolePermissions(roleName);
    Subject rolePrincipals = (Subject) roleToSubjectMap.get(roleName);
    if (rolePrincipals != null) {
        Iterator pit = rolePrincipals.getPrincipals().iterator();
        while (pit.hasNext()){
      Principal prin = (Principal) pit.next();

      if (prin != null) {
          withPrincipals = true;
          PrincipalEntry prinEntry =
        new PrincipalEntry(prin.getClass().getName(),
               escapeName(prin.getName()));
          GrantEntry grant = new GrantEntry();
          grant.principals.add(prinEntry);
          Enumeration pEnum = rolePerms.elements();
          while (pEnum.hasMoreElements()) {
        Permission perm = (Permission) pEnum.nextElement();
        PermissionEntry permEntry =
            new PermissionEntry(perm.getClass().getName(),
              perm.getName(),
              perm.getActions());
        grant.add(permEntry);
          }
          parser.add(grant);
      }
      else {
                            String msg = localStrings.getLocalString("pc.non_principal_mapped_to_role",
                                         "non principal mapped to role "+roleName,new Object[]{prin,roleName});
          logger.log(Level.WARNING,msg);
      }
        }
    }
    /**
     * JACC MR8 add grant for the any authenticated user role '**'
     */
    if (!withPrincipals && ("**".equals(roleName))) {
      withPrincipals = true;
      PrincipalEntry prinEntry = new PrincipalEntry(
          PrincipalEntry.WILDCARD_CLASS,PrincipalEntry.WILDCARD_NAME);
      GrantEntry grant = new GrantEntry();
      grant.principals.add(prinEntry);
      Enumeration pEnum = rolePerms.elements();
      while (pEnum.hasMoreElements()) {
        Permission perm = (Permission) pEnum.nextElement();
        PermissionEntry permEntry =
            new PermissionEntry(perm.getClass().getName(),
                perm.getName(),
                perm.getActions());
        grant.add(permEntry);
      }
      parser.add(grant);
      if(logger.isLoggable (Level.FINE)){
        logger.fine("JACC Policy Provider: added role grant for any authenticated user");
      }
    }
    if (!withPrincipals) {
                    String msg = localStrings.getLocalString("pc.no_principals_mapped_to_role",
                                  "no principals mapped to role "+roleName, new Object []{ roleName});
        logger.log(Level.WARNING,msg);
    }
      }
  }

  writeOnCommit = createPolicyFile(true,parser,writeOnCommit);

  // load excluded perms in excluded parser
  if (excludedPermissions != null) {

      PolicyParser excludedParser = new PolicyParser(false);

      Enumeration pEnum = excludedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    excludedParser.add(grant);
      }

      writeOnCommit = createPolicyFile(false,excludedParser,writeOnCommit);
View Full Code Here


  }

  if (parser != null) {
      Enumeration grants = parser.grantElements();
      while (grants.hasMoreElements()) {
    GrantEntry grant = (GrantEntry) grants.nextElement();
    if (grant.codeBase != null || grant.signedBy != null ||
        grant.principals.size() != 0) {
                        String msg=localStrings.getLocalString("pc.excluded_grant_context_ignored",
                                   "ignore excluded grant context", new Object []{grant});
        logger.log(Level.WARNING,msg);
View Full Code Here

  // load unchecked grants in parser
  if (uncheckedPermissions != null) {
      Enumeration pEnum = uncheckedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    parser.add(grant);
      }
  }

  // load role based grants in parser
  if (rolePermissionsTable != null) {
      Iterator roleIt = rolePermissionsTable.keySet().iterator();
      while (roleIt.hasNext()) {
    boolean withPrincipals = false;
    String roleName = (String) roleIt.next();
    Permissions rolePerms = getRolePermissions(roleName);
    Subject rolePrincipals = (Subject) roleToSubjectMap.get(roleName);
    if (rolePrincipals != null) {
        Iterator pit = rolePrincipals.getPrincipals().iterator();
        while (pit.hasNext()){
      Principal prin = (Principal) pit.next();

      if (prin != null) {
          withPrincipals = true;
          PrincipalEntry prinEntry =
        new PrincipalEntry(prin.getClass().getName(),
               escapeName(prin.getName()));
          GrantEntry grant = new GrantEntry();
          grant.principals.add(prinEntry);
          Enumeration pEnum = rolePerms.elements();
          while (pEnum.hasMoreElements()) {
        Permission perm = (Permission) pEnum.nextElement();
        PermissionEntry permEntry =
            new PermissionEntry(perm.getClass().getName(),
              perm.getName(),
              perm.getActions());
        grant.add(permEntry);
          }
          parser.add(grant);
      }
      else {
                            String msg = localStrings.getLocalString("pc.non_principal_mapped_to_role",
                                         "non principal mapped to role "+roleName,new Object[]{prin,roleName});
          logger.log(Level.WARNING,msg);
      }
        }
    }
    if (!withPrincipals) {
                    String msg = localStrings.getLocalString("pc.no_principals_mapped_to_role",
                                  "no principals mapped to role "+roleName, new Object []{ roleName});
        logger.log(Level.WARNING,msg);
    }
      }
  }

  writeOnCommit = createPolicyFile(true,parser,writeOnCommit);

  // load excluded perms in excluded parser
  if (excludedPermissions != null) {

      PolicyParser excludedParser = new PolicyParser(false);

      Enumeration pEnum = excludedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    excludedParser.add(grant);
      }

      writeOnCommit = createPolicyFile(false,excludedParser,writeOnCommit);
View Full Code Here

  }

  if (parser != null) {
      Enumeration grants = parser.grantElements();
      while (grants.hasMoreElements()) {
    GrantEntry grant = (GrantEntry) grants.nextElement();
    if (grant.codeBase != null || grant.signedBy != null ||
        grant.principals.size() != 0) {
                        String msg=localStrings.getLocalString("pc.excluded_grant_context_ignored",
                                   "ignore excluded grant context", new Object []{grant});
        logger.log(Level.WARNING,msg);
View Full Code Here

  // load unchecked grants in parser
  if (uncheckedPermissions != null) {
      Enumeration pEnum = uncheckedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    parser.add(grant);
      }
  }

  // load role based grants in parser
  if (rolePermissionsTable != null) {
      Iterator roleIt = rolePermissionsTable.keySet().iterator();
      while (roleIt.hasNext()) {
    boolean withPrincipals = false;
    String roleName = (String) roleIt.next();
    Permissions rolePerms = getRolePermissions(roleName);
    Subject rolePrincipals = (Subject) roleToSubjectMap.get(roleName);
    if (rolePrincipals != null) {
        Iterator pit = rolePrincipals.getPrincipals().iterator();
        while (pit.hasNext()){
      Principal prin = (Principal) pit.next();
      assert prin instanceof java.security.Principal;
      if (prin instanceof java.security.Principal) {
          withPrincipals = true;
          PrincipalEntry prinEntry =
        new PrincipalEntry(prin.getClass().getName(),
               escapeName(prin.getName()));
          GrantEntry grant = new GrantEntry();
          grant.principals.add(prinEntry);
          Enumeration pEnum = rolePerms.elements();
          while (pEnum.hasMoreElements()) {
        Permission perm = (Permission) pEnum.nextElement();
        PermissionEntry permEntry =
            new PermissionEntry(perm.getClass().getName(),
              perm.getName(),
              perm.getActions());
        grant.add(permEntry);
          }
          parser.add(grant);
      }
      else {
                            String msg = localStrings.getLocalString("pc.non_principal_mapped_to_role",
                                         "non principal mapped to role "+roleName,new Object[]{prin,roleName});
          logger.log(Level.WARNING,msg);
      }
        }
    }
    if (!withPrincipals) {
                    String msg = localStrings.getLocalString("pc.no_principals_mapped_to_role",
                                  "no principals mapped to role "+roleName, new Object []{ roleName});
        logger.log(Level.WARNING,msg);
    }
      }
  }

  writeOnCommit = createPolicyFile(true,parser,writeOnCommit);

  // load excluded perms in excluded parser
  if (excludedPermissions != null) {

      PolicyParser excludedParser = new PolicyParser(false);

      Enumeration pEnum = excludedPermissions.elements();
      if (pEnum.hasMoreElements()) {
    GrantEntry grant = new GrantEntry();
    while (pEnum.hasMoreElements()) {
        Permission p = (Permission) pEnum.nextElement();
        PermissionEntry entry =
      new PermissionEntry(p.getClass().getName(),
              p.getName(),p.getActions());
        grant.add(entry);
    }
    excludedParser.add(grant);
      }

      writeOnCommit = createPolicyFile(false,excludedParser,writeOnCommit);
View Full Code Here

  }

  if (parser != null) {
      Enumeration grants = parser.grantElements();
      while (grants.hasMoreElements()) {
    GrantEntry grant = (GrantEntry) grants.nextElement();
    if (grant.codeBase != null || grant.signedBy != null ||
        grant.principals.size() != 0) {
                        String msg=localStrings.getLocalString("pc.excluded_grant_context_ignored",
                                   "ignore excluded grant context", new Object []{grant});
        logger.log(Level.WARNING,msg);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.security.provider.PolicyParser.GrantEntry

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.