Package org.apache.jetspeed.om.registry

Examples of org.apache.jetspeed.om.registry.SecurityAccess


            assertTrue("Getting expect security entry", securityEntry.getName().equals("basic_testcase"));

            // Get the action
            Vector securityAccesses = securityEntry.getAccesses();
            assertNotNull("Got SecurityAccesses", securityAccesses);
            SecurityAccess securityAccess = (SecurityAccess) securityAccesses.firstElement();
            assertNotNull("Got SecurityAccess", securityAccess);
            assertEquals("Verify action", "view", securityAccess.getAction());

            // Get allows
            Vector securityAllows = securityAccess.getAllows();
            assertNotNull("Got SecurityAllows", securityAllows);
            SecurityAllow securityAllow = (SecurityAllow) securityAllows.firstElement();
            assertNotNull("Got SecurityAllow", securityAllow);
            assertEquals("Verify role", "clerk", securityAllow.getRole());
            assertNull("Verify user" , securityAllow.getUser());
View Full Code Here


            sde.save(conn);
           
            Iterator accesses = se.getAccesses().iterator();
            while (accesses.hasNext())
            {
                SecurityAccess access = (SecurityAccess)accesses.next();
                SecurityAccessDbEntry sade = new SecurityAccessDbEntry();               
                sade.setAction(access.getAction());
                sade.setEntryId(sde.getId());
                sade.save(conn);
               
                Iterator allows = access.getAllAllows().iterator();
                while (allows.hasNext())
                {
                    SecurityAllow allow = (SecurityAllow)allows.next();
                    SecurityAllowDbEntry sa = new SecurityAllowDbEntry();
                    if (allow.isOwner())
View Full Code Here

       
        Iterator accesses = sde.getSecurityAccessDbEntrys().iterator();
        while (accesses.hasNext())
        {
            SecurityAccessDbEntry sade = (SecurityAccessDbEntry)accesses.next();
            SecurityAccess access = new BaseSecurityAccess(sade.getId());
            access.setAction(sade.getAction());
                           
            Iterator allows = sade.getSecurityAllowDbEntrys().iterator();
            while (allows.hasNext())
            {
                SecurityAllowDbEntry sa = (SecurityAllowDbEntry)allows.next();
                if (sa.getAllowType().equals(ALLOW_OWNER))
                {
                    SecurityAllow allow = new BaseSecurityAllowOwner(sa.getId());                   
                    allow.setOwner(true);
                    access.getOwnerAllows().add(allow);
                }
                else if (sa.getAllowType().equals(ALLOW_BOTH))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setRole(sa.getAllowValue());
                    allow.setGroup(sa.getAllowGroup());
                    access.getAllows().add(allow);               
                }
                else if (sa.getAllowType().equals(ALLOW_ROLE))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setRole(sa.getAllowValue());
                    access.getAllows().add(allow);
                }
                else if (sa.getAllowType().equals(ALLOW_GROUP))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setGroup(sa.getAllowValue());
                    access.getAllows().add(allow);
                }
                else
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());                   
                    allow.setUser(sa.getAllowValue());
                    access.getAllows().add(allow);
                }                   
            }
            se.getAccesses().add(access);
        }
        return se;
View Full Code Here

   */
  public boolean revokeGroupRoleAccess(String action, String group, String role)
  {
    if (allowsSpecificGroupRole(action, group, role))
    {
      SecurityAccess access = getAccess(action);
      List allows = access.getAllows();
      if (allows == null || allows.isEmpty())
      {
        revokeAccess(action);
                buildAccessMap();               
        return false;
      }

      for (int i = 0; i < allows.size(); i++)
      {
        BaseSecurityAllow allow = (BaseSecurityAllow) allows.get(i);
        if (allow.getGroup() != null &&
          allow.getGroup().equals(group) &&
          allow.getRole() != null &&
          allow.getRole().equals(role))
        {
          allows.remove(i);
          if (allows.isEmpty() && access.getOwnerAllows().isEmpty())
          {
            revokeAccess(action);
          }
                    buildAccessMap();                       
          return true;
View Full Code Here

    */
    public boolean revokeUserAccess(String action, String user)
    {
        if (allowsSpecificUser(action, user))
        {
            SecurityAccess access = getAccess(action);
            List allows = access.getAllows();
            if (allows == null || allows.isEmpty())
            {
                revokeAccess(action);
                buildAccessMap();               
                return false;
            }

            for (int i = 0; i < allows.size(); i++)
            {
                BaseSecurityAllow allow = (BaseSecurityAllow) allows.get(i);
                if (allow.getUser() != null && allow.getUser().equals(user))
                {
                    allows.remove(i);
                    if (allows.isEmpty() && access.getOwnerAllows().isEmpty())
                    {
                        revokeAccess(action);
                    }
                    buildAccessMap();
                    return true;
View Full Code Here

   

    private void buildAccessMap()
    {
        Map actionMap = null;
        SecurityAccess accessElement = null;

        synchronized (accessMapSync)
        {
            if (accessMap == null)
            {
                accessMap = new HashMap();
            }

            accessMap.clear();
        }
        // Build allow map
        for (Iterator accessIterator = getAccesses().iterator(); accessIterator.hasNext();)
        {
            accessElement = (SecurityAccess) accessIterator.next();

            // Get action map of the action.  Create one if none exists
            String action = accessElement.getAction();

            if (action == null)
            {
                action = ALL_ACTIONS;
            }
View Full Code Here

     * Checks whether a role is specifically allowed to access the request action
     * This method ignores the "*" action and is here to play a maintenance role.
     */
    public boolean allowsSpecificRole( String action, String role)
    {
        SecurityAccess access = (SecurityAccess) getAccess(action);
        if (access != null)           
        {
            List allows = access.getAllows();
            if (allows != null)
            {           
                Iterator allAllows = allows.iterator();
                while (allAllows.hasNext())
                {
View Full Code Here

   * Checks whether a group is specifically allowed to access the request action
   * This method ignores the "*" action and is here to play a maintenance role.
   */
  public boolean allowsSpecificGroup(String action, String group)
  {
    SecurityAccess access = (SecurityAccess) getAccess(action);
    if (access != null)
    {
            List allows = access.getAllows();
            if (allows != null)
            {
                Iterator allAllows = allows.iterator();
                while (allAllows.hasNext())
                {
View Full Code Here

   * Checks whether a group role is specifically allowed to access the request action
   * This method ignores the "*" action and is here to play a maintenance role.
   */
  public boolean allowsSpecificGroupRole(String action, String group, String role)
  {
    SecurityAccess access = (SecurityAccess) getAccess(action);
    if (access != null)
    {           
            List allows = access.getAllows();       
            if (allows != null)
            {
          Iterator allAllows = allows.iterator();
          while (allAllows.hasNext())
          {
View Full Code Here

     */
    public boolean grantRoleAccess(String action, String role)
    {
        if (!allowsSpecificRole(action, role))
        {
            SecurityAccess access = getAccess(action);
            if (access == null)
            {
                access = new BaseSecurityAccess();
                access.setAction(action);
                this.getAccesses().add(access);               
            }           
            List allows = access.getAllows();
            if (allows == null)
            {
                allows = new Vector();
            }

View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.registry.SecurityAccess

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.