Package ch.entwine.weblounge.common.security

Examples of ch.entwine.weblounge.common.security.Role


  public Role[] getClosure() {
    HashSet<Role> roles = new HashSet<Role>();
    Stack<Role> stack = new Stack<Role>();
    stack.push(this);
    while (!stack.empty()) {
      Role r = stack.pop();
      roles.add(r);
      for (Role extendedRole : r.getExtendedRoles()) {
        if (!stack.contains(extendedRole))
          stack.push(extendedRole);
      }
    }
    return roles.toArray(new Role[ancestors.size()]);
View Full Code Here


   *
   * @see ch.entwine.weblounge.common.security.Authority#isAuthorizedBy(ch.entwine.weblounge.common.security.Authority)
   */
  public boolean isAuthorizedBy(Authority authority) {
    if (authority != null && authority instanceof Role) {
      Role r = (Role) authority;
      return this.equals(r) || this.isExtensionOf(r);
    } else if (authority != null && authority.getAuthorityType().equals(Role.class.getName())) {
      String roleId = authority.getAuthorityId();
      Role r = new RoleImpl(roleId);
      return equals(r) || isExtensionOf(r);
    }
    return false;
  }
View Full Code Here

   *
   * @see java.lang.Object#equals(java.lang.Object)
   */
  public boolean equals(Object obj) {
    if (obj != null && obj instanceof Role) {
      Role r = (Role) obj;
      return r.getIdentifier().equals(identifier) && r.getContext().equals(context);
    }
    return false;
  }
View Full Code Here

    }

    // Roles
    Set<Object> roles = getPublicCredentials(Role.class);
    for (Object r : roles) {
      Role role = (Role) r;
      b.append("<role context=\"");
      b.append(role.getContext());
      b.append("\"><![CDATA[");
      b.append(role.getName());
      b.append("]]></password>");
    }

    // challenge - response
    if (challenge != null) {
View Full Code Here

    if (user == null)
      throw new IllegalArgumentException("User cannot be null");
    if (role == null)
      throw new IllegalArgumentException("Role cannot be null");
    for (Object o : user.getPublicCredentials(Role.class)) {
      Role masterRole = (Role) o;
      for (Role r : masterRole.getClosure()) {
        if (role.equals(r))
          return true;
      }
    }
    return false;
View Full Code Here

    if (user == null)
      throw new IllegalArgumentException("User cannot be null");
    if (roleId == null)
      throw new IllegalArgumentException("Role identifier cannot be null");
    for (Object o : user.getPublicCredentials(Role.class)) {
      Role masterRole = (Role) o;
      for (Role r : masterRole.getClosure()) {
        String ctx = r.getContext();
        String id = r.getIdentifier();
        if (ctx.equals(Security.SYSTEM_CONTEXT) && id.equals(roleId))
          return true;
      }
View Full Code Here

   * @see javax.servlet.jsp.tagext.Tag#doStartTag()
   */
  @Override
  public int doStartTag() throws JspException {
    if (context != null && id != null) {
      Role role;
      try {
        role = new RoleImpl(context + ":" + id);
      } catch (IllegalArgumentException e) {
        throw new JspTagException(e);
      }
View Full Code Here

      user.addPublicCredentials(SystemRole.GUEST);

      // Collect the set of roles (granted authorities) for this users
      Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
      for (Object o : user.getPublicCredentials(Role.class)) {
        Role masterRole = (Role) o;
        for (Role r : masterRole.getClosure()) {
          authorities.add(new SimpleGrantedAuthority(r.getContext() + ":" + r.getIdentifier()));

          // Every role may or may not be a system role or - in case of non-
          // system roles, may or may not be including one or more of those
          // roles. Let's ask for a translation and then add those roles
View Full Code Here

    if (siteProviders != null)
      providers.addAll(siteProviders);
    providers.addAll(systemDirectories);

    for (DirectoryProvider directory : providers) {
      Role localRole = directory.getLocalRole(role);
      if (localRole != null) {
        return localRole;
      }
    }
View Full Code Here

   * Test for void allow(Permission, Authority)
   */
  @Test
  public final void testPermitPermissionAuthority() {
    Permission publish = SystemPermission.PUBLISH;
    Role editor = SystemRole.EDITOR;

    // Create the security context
    SecurityContextImpl context = new SecurityContextImpl();
    context.init(path, config);

View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.security.Role

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.