Class SubjectUtils

java.lang.Object
ddf.security.service.impl.SubjectUtils
All Implemented Interfaces:
ddf.security.SubjectOperations

public final class SubjectUtils extends Object implements ddf.security.SubjectOperations
Utility class used to perform operations on Subjects.
  • Constructor Details

    • SubjectUtils

      public SubjectUtils()
  • Method Details

    • getName

      public String getName(org.apache.shiro.subject.Subject subject)
      Retrieves the user name from a given subject.
      Specified by:
      getName in interface ddf.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)
      Retrieves the user name from a given subject.
      Specified by:
      getName in interface ddf.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:
      getName in interface ddf.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

      public String getCommonName(X500Principal principal)
      Specified by:
      getCommonName in interface ddf.security.SubjectOperations
    • getEmailAddress

      public String getEmailAddress(X500Principal principal)
      Specified by:
      getEmailAddress in interface ddf.security.SubjectOperations
    • getCountry

      public String getCountry(X500Principal principal)
      Specified by:
      getCountry in interface ddf.security.SubjectOperations
    • filterDN

      public String filterDN(X500Principal principal, Predicate<org.bouncycastle.asn1.x500.RDN> predicate)
      Specified by:
      filterDN in interface ddf.security.SubjectOperations
    • getEmailAddress

      @Nullable public String getEmailAddress(org.apache.shiro.subject.Subject subject)
      Get a subject's email.
      Specified by:
      getEmailAddress in interface ddf.security.SubjectOperations
      Parameters:
      subject -
      Returns:
      email or null if not found.
    • getAttribute

      public List<String> getAttribute(@Nullable org.apache.shiro.subject.Subject subject, String key)
      Get any attribute from a subject by key.
      Specified by:
      getAttribute in interface ddf.security.SubjectOperations
      Parameters:
      subject -
      key -
      Returns:
      attribute values or an empty list if not found.
    • getSubjectAttributes

      public Map<String,SortedSet<String>> getSubjectAttributes(org.apache.shiro.subject.Subject subject)
      Retrieves the security attributes for the given subject.
      Specified by:
      getSubjectAttributes in interface ddf.security.SubjectOperations
      Parameters:
      subject - the Subject to check
      Returns:
      Map of attributes with the collected values for each
    • getType

      public String getType(org.apache.shiro.subject.Subject subject)
      Retrieves the type of the Security Assertion inside the given Subject.
      Specified by:
      getType in interface ddf.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:
      isGuest in interface ddf.security.SubjectOperations
    • getAssertionComparator

      public Comparator<ddf.security.assertion.SecurityAssertion> getAssertionComparator()
      Specified by:
      getAssertionComparator in interface ddf.security.SubjectOperations