Package ddf.security.service.impl
Class SubjectUtils
java.lang.Object
ddf.security.service.impl.SubjectUtils
- All Implemented Interfaces:
ddf.security.SubjectOperations
Utility class used to perform operations on Subjects.
-
Field Summary
Fields inherited from interface ddf.security.SubjectOperations
COUNTRY_CLAIM_URI, EMAIL_ADDRESS_CLAIM_ALTERNATE, EMAIL_ADDRESS_CLAIM_URI, GIVEN_NAME_CLAIM_URI, GUEST_DISPLAY_NAME, LOCALITY_CODE_CLAIM_URI, MOBILE_PHONE_CLAIM_URI, NAME_CLAIM_URI, NAME_IDENTIFIER_CLAIM_ALTERNATE, NAME_IDENTIFIER_CLAIM_URI, POSTAL_CODE_CLAIM_URI, ROLE_CLAIM_URI, STREET_ADDRESS_CLAIM_URI, SURNAME_CLAIM_URI -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilterDN(X500Principal principal, Predicate<org.bouncycastle.asn1.x500.RDN> predicate) Comparator<ddf.security.assertion.SecurityAssertion> getAttribute(org.apache.shiro.subject.Subject subject, String key) Get any attribute from a subject by key.getCommonName(X500Principal principal) getCountry(X500Principal principal) getEmailAddress(X500Principal principal) getEmailAddress(org.apache.shiro.subject.Subject subject) Get a subject's email.getName(org.apache.shiro.subject.Subject subject) Retrieves the user name from a given subject.Retrieves the user name from a given subject.Retrieves the user name from a given subject.getSubjectAttributes(org.apache.shiro.subject.Subject subject) Retrieves the security attributes for the given subject.getType(org.apache.shiro.subject.Subject subject) Retrieves the type of the Security Assertion inside the given Subject.booleanisGuest(org.apache.shiro.subject.Subject subject)
-
Constructor Details
-
SubjectUtils
public SubjectUtils()
-
-
Method Details
-
getName
Retrieves the user name from a given subject.- Specified by:
getNamein interfaceddf.security.SubjectOperations- Parameters:
subject- Subject to get the user name from.- Returns:
- String representation of the user name if available or null if no user name could be found.
-
getName
Retrieves the user name from a given subject.- Specified by:
getNamein interfaceddf.security.SubjectOperations- Parameters:
subject- Subject to get the user name from.- Returns:
- String representation of the user name if available or null if no user name could be found.
-
getName
public String getName(org.apache.shiro.subject.Subject subject, String defaultName, boolean returnDisplayName) Retrieves the user name from a given subject.- Specified by:
getNamein interfaceddf.security.SubjectOperations- Parameters:
subject- Subject to get the user name from.defaultName- Name to send back if no user name was found.returnDisplayName- return formatted user name for displaying- Returns:
- String representation of the user name if available or defaultName if no user name could be found or incoming subject was null.
-
getCommonName
- Specified by:
getCommonNamein interfaceddf.security.SubjectOperations
-
getEmailAddress
- Specified by:
getEmailAddressin interfaceddf.security.SubjectOperations
-
getCountry
- Specified by:
getCountryin interfaceddf.security.SubjectOperations
-
filterDN
public String filterDN(X500Principal principal, Predicate<org.bouncycastle.asn1.x500.RDN> predicate) - Specified by:
filterDNin interfaceddf.security.SubjectOperations
-
getEmailAddress
Get a subject's email.- Specified by:
getEmailAddressin interfaceddf.security.SubjectOperations- Parameters:
subject-- Returns:
- email or null if not found.
-
getAttribute
Get any attribute from a subject by key.- Specified by:
getAttributein interfaceddf.security.SubjectOperations- Parameters:
subject-key-- Returns:
- attribute values or an empty list if not found.
-
getSubjectAttributes
Retrieves the security attributes for the given subject.- Specified by:
getSubjectAttributesin interfaceddf.security.SubjectOperations- Parameters:
subject- the Subject to check- Returns:
- Map of attributes with the collected values for each
-
getType
Retrieves the type of the Security Assertion inside the given Subject.- Specified by:
getTypein interfaceddf.security.SubjectOperations- Parameters:
subject- Subject to get the user name from.- Returns:
- String representation of the user name if available or defaultName if no user name could be found or incoming subject was null.
-
isGuest
public boolean isGuest(org.apache.shiro.subject.Subject subject) - Specified by:
isGuestin interfaceddf.security.SubjectOperations
-
getAssertionComparator
- Specified by:
getAssertionComparatorin interfaceddf.security.SubjectOperations
-