Package org.apache.wicket.authroles.authorization.strategies.role

Examples of org.apache.wicket.authroles.authorization.strategies.role.Roles


    {
      throw new IllegalArgumentException("argument componentClass must be of type " +
        Component.class.getName());
    }

    final Roles roles = rolesAuthorizedToInstantiate(componentClass);
    if (roles != null)
    {
      return hasAny(roles);
    }
    return true;
View Full Code Here


    if (rolesToAdd == null)
    {
      throw new IllegalArgumentException("Argument rolesToAdd cannot be null");
    }

    Roles roles = rolesForAction.get(action);
    if (roles == null)
    {
      roles = new Roles();
      rolesForAction.put(action, roles);
    }
    roles.addAll(rolesToAdd);
  }
View Full Code Here

    if (rolesToRemove == null)
    {
      throw new IllegalArgumentException("Argument rolesToRemove cannot be null");
    }

    Roles roles = rolesForAction.get(action);
    if (roles != null)
    {
      roles.removeAll(rolesToRemove);
    }
    else
    {
      roles = new Roles();
      rolesForAction.put(action, roles);
    }

    // If we removed the last authorized role, we authorize the empty role
    // so that removing authorization can't suddenly open something up to
    // everyone.
    if (roles.size() == 0)
    {
      roles.add(MetaDataRoleAuthorizationStrategy.NO_ROLE);
    }
  }
View Full Code Here

    if (rolesToAdd == null)
    {
      throw new IllegalArgumentException("Argument rolesToadd cannot be null");
    }

    Roles roles = rolesForComponentClass.get(componentClass);
    if (roles == null)
    {
      roles = new Roles();
      rolesForComponentClass.put(componentClass, roles);
    }
    roles.addAll(rolesToAdd);
  }
View Full Code Here

    if (rolesToRemove == null)
    {
      throw new IllegalArgumentException("Argument rolesToRemove cannot be null");
    }

    Roles roles = rolesForComponentClass.get(componentClass);
    if (roles != null)
    {
      roles.removeAll(rolesToRemove);
    }
    else
    {
      roles = new Roles();
      rolesForComponentClass.put(componentClass, roles);
    }

    // If we removed the last authorized role, we authorize the empty role
    // so that removing authorization can't suddenly open something up to
    // everyone.
    if (roles.size() == 0)
    {
      roles.add(MetaDataRoleAuthorizationStrategy.NO_ROLE);
    }
  }
View Full Code Here

    /**
     * Construct.
     */
    public UserRolesAuthorizer(String roles)
    {
      this.roles = new Roles(roles);
    }
View Full Code Here

  @Test
  public void testAdd1() throws Exception
  {
    ActionPermissions permissions = new ActionPermissions();
    Action mambo = new Action("mambo");
    permissions.authorize(mambo, new Roles("jonathan"));
    permissions.authorize(mambo, new Roles("johan"));
    permissions.authorize(mambo, new Roles("maurice"));
    permissions.authorize(mambo, new Roles("eelco"));
    assertEquals(4, permissions.rolesFor(mambo).size());
    permissions.unauthorize(mambo, new Roles("maurice"));
    assertEquals(3, permissions.rolesFor(mambo).size());
    permissions.authorizeAll(mambo);
    assertEquals(null, permissions.rolesFor(mambo));
  }
View Full Code Here

  public void testRemove1() throws Exception
  {
    ActionPermissions permissions = new ActionPermissions();
    Action mambo = new Action("mambo");
    assertEquals(null, permissions.rolesFor(mambo));
    permissions.unauthorize(mambo, new Roles("maurice"));
    assertEquals(new Roles(MetaDataRoleAuthorizationStrategy.NO_ROLE),
      permissions.rolesFor(mambo));
  }
View Full Code Here

   */
  @Test
  public void testAdd1() throws Exception
  {
    InstantiationPermissions permissions = new InstantiationPermissions();
    permissions.authorize(Page.class, new Roles("jonathan"));
    permissions.authorize(Page.class, new Roles("johan"));
    permissions.authorize(Page.class, new Roles("maurice"));
    permissions.authorize(Page.class, new Roles("eelco"));
    assertEquals(4, permissions.getRolesForComponentClass().get(Page.class).size());
    permissions.unauthorize(Page.class, new Roles("maurice"));
    assertEquals(3, permissions.getRolesForComponentClass().get(Page.class).size());
    permissions.authorizeAll(Page.class);
    assertEquals(null, permissions.getRolesForComponentClass().get(Page.class));
  }
View Full Code Here

  @Test
  public void testRemove1() throws Exception
  {
    InstantiationPermissions permissions = new InstantiationPermissions();
    assertEquals(null, permissions.getRolesForComponentClass().get(Page.class));
    permissions.unauthorize(Page.class, new Roles("eelco"));
    assertEquals(new Roles(MetaDataRoleAuthorizationStrategy.NO_ROLE),
      permissions.getRolesForComponentClass().get(Page.class));
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.authroles.authorization.strategies.role.Roles

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.