All Downloads are FREE. Search and download functionalities are using the official Maven repository.

enterprises.orbital.impl.evexmlapi.crp.ApiSecurityMember Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package enterprises.orbital.impl.evexmlapi.crp;

import java.util.HashSet;
import java.util.Set;

import enterprises.orbital.evexmlapi.crp.IMemberSecurity;
import enterprises.orbital.evexmlapi.crp.ISecurityRole;
import enterprises.orbital.evexmlapi.crp.ISecurityTitle;

public class ApiSecurityMember implements IMemberSecurity {
  private long                      characterID;
  private String                    name;
  private final Set  roles                 = new HashSet();
  private final Set  grantableRoles        = new HashSet();
  private final Set  rolesAtHQ             = new HashSet();
  private final Set  grantableRolesAtHQ    = new HashSet();
  private final Set  rolesAtBase           = new HashSet();
  private final Set  grantableRolesAtBase  = new HashSet();
  private final Set  rolesAtOther          = new HashSet();
  private final Set  grantableRolesAtOther = new HashSet();
  private final Set titles                = new HashSet();

  @Override
  public long getCharacterID() {
    return characterID;
  }

  public void setCharacterID(long characterID) {
    this.characterID = characterID;
  }

  @Override
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public void addSecurityRoleBag(SecurityRoleOrTitleBag securityRoleBag) {
    String bagName = securityRoleBag.getName();
    if (bagName.equals("roles"))
      addSecurityRoles(roles, securityRoleBag);
    else if (bagName.equals("grantableRoles"))
      addSecurityRoles(grantableRoles, securityRoleBag);
    else if (bagName.equals("rolesAtHQ"))
      addSecurityRoles(rolesAtHQ, securityRoleBag);
    else if (bagName.equals("grantableRolesAtHQ"))
      addSecurityRoles(grantableRolesAtHQ, securityRoleBag);
    else if (bagName.equals("rolesAtBase"))
      addSecurityRoles(rolesAtBase, securityRoleBag);
    else if (bagName.equals("grantableRolesAtBase"))
      addSecurityRoles(grantableRolesAtBase, securityRoleBag);
    else if (bagName.equals("rolesAtOther"))
      addSecurityRoles(rolesAtOther, securityRoleBag);
    else if (bagName.equals("grantableRolesAtOther"))
      addSecurityRoles(grantableRolesAtOther, securityRoleBag);
    else if (bagName.equals("titles"))
      for (SecurityRoleOrTitle securityRoleOrTitle : securityRoleBag.getSecurityRoles())
        titles.add(securityRoleOrTitle.getTitle());
    else
      throw new RuntimeException("Unknown roleOrTitleBag name");
  }

  private void addSecurityRoles(Set roleSet, SecurityRoleOrTitleBag securityRoleBag) {
    for (SecurityRoleOrTitle securityRoleOrTitle : securityRoleBag.getSecurityRoles())
      roleSet.add(securityRoleOrTitle.getRole());
  }

  @Override
  public Set getRoles() {
    return roles;
  }

  @Override
  public Set getGrantableRoles() {
    return grantableRoles;
  }

  @Override
  public Set getRolesAtHQ() {
    return rolesAtHQ;
  }

  @Override
  public Set getGrantableRolesAtHQ() {
    return grantableRolesAtHQ;
  }

  @Override
  public Set getRolesAtBase() {
    return rolesAtBase;
  }

  @Override
  public Set getGrantableRolesAtBase() {
    return grantableRolesAtBase;
  }

  @Override
  public Set getRolesAtOther() {
    return rolesAtOther;
  }

  @Override
  public Set getGrantableRolesAtOther() {
    return grantableRolesAtOther;
  }

  @Override
  public Set getTitles() {
    return titles;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy