org.n52.security.common.subject
Class SubjectPrincipalAnalyzer

java.lang.Object
  extended by org.n52.security.common.subject.SubjectPrincipalAnalyzer

public class SubjectPrincipalAnalyzer
extends Object


Constructor Summary
SubjectPrincipalAnalyzer(Subject subject)
           
 
Method Summary
<T extends Principal>
T
findPrincipal(Class<T> principalClass, String name)
          Gets fist principal of given class with given name.
 List<Attribute> getAttributes()
          Creates a list of Attributes within the subject.
 AttributeValue getComplexAttributeValue(String attributeName)
          Retrieves the AttributeValue of the first AttributePrincipal with a given name.
 Map<String,AttributeValue> getComplexAttributeValues(Subject subject)
          Creates a map of all attributes with (the last) values as AttributeValue.
<T extends Principal>
T
getPrincipal(Class<T> principalClass)
          Gets first principal of given class.
<T extends Principal>
Set<T>
getPrincipals(Class<T> principalClass)
           
 Set<String> getRoles()
          Retrieves all RolePrincipal names form the subject.
 String[] getRolesAsArray()
          Retrieves all RolePrincipal names form the subject.
 Map<String,String> getSimpleAttributeValues()
          Creates a map of all attributes with (the last) values as string.
 String getSingleAttributeValue(String attributeName)
          Retrieves the value of the first AttributePrincipal with a given name.
 Subject getSubject()
           
 String getUsername()
          Retrieves the username of the subject.
 boolean isInRole(String role)
          Responsible for checking if a user has a given role.
 void removePrincipal(Principal principal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubjectPrincipalAnalyzer

public SubjectPrincipalAnalyzer(Subject subject)
Method Detail

getSingleAttributeValue

public String getSingleAttributeValue(String attributeName)
Retrieves the value of the first AttributePrincipal with a given name.

Parameters:
subject - subject containing the attribute information
attributeName - the name of the attribute that contains the information.
Returns:
the String value of the first AttributePrincipal of the subject where NamePrincipal.getName() equals attributeName, null if no such exists.

getComplexAttributeValue

public AttributeValue getComplexAttributeValue(String attributeName)
Retrieves the AttributeValue of the first AttributePrincipal with a given name.

Parameters:
subject - subject containing the attribute information
attributeName - the name of the attribute that contains the information.
Returns:
the String value of the first AttributePrincipal of the subject where NamePrincipal.getName() equals attributeName, null if no such exists.

getSimpleAttributeValues

public Map<String,String> getSimpleAttributeValues()
Creates a map of all attributes with (the last) values as string.

Returns:
Map

getComplexAttributeValues

public Map<String,AttributeValue> getComplexAttributeValues(Subject subject)
Creates a map of all attributes with (the last) values as AttributeValue.

Returns:
MapAttributeValue>

getAttributes

public List<Attribute> getAttributes()
Creates a list of Attributes within the subject.

Parameters:
subject -
Returns:

getRolesAsArray

public String[] getRolesAsArray()
Retrieves all RolePrincipal names form the subject.

Parameters:
subject - the current subject.
Returns:

getRoles

public Set<String> getRoles()
Retrieves all RolePrincipal names form the subject.

Parameters:
subject - the current subject.
Returns:

isInRole

public boolean isInRole(String role)
Responsible for checking if a user has a given role.

Parameters:
subject - the current subject.
role - a role name.
Returns:

getUsername

public String getUsername()
Retrieves the username of the subject.

Parameters:
subject - containing the username information.
Returns:
the name of the first UsernameIDPrincipal found, null otherwise.

findPrincipal

public <T extends Principal> T findPrincipal(Class<T> principalClass,
                                             String name)
Gets fist principal of given class with given name.


getPrincipal

public <T extends Principal> T getPrincipal(Class<T> principalClass)
Gets first principal of given class.


getPrincipals

public <T extends Principal> Set<T> getPrincipals(Class<T> principalClass)

removePrincipal

public void removePrincipal(Principal principal)

getSubject

public Subject getSubject()


Copyright © 2004–2013 52north.org. All rights reserved.