Class SubjectImpl

java.lang.Object
edu.internet2.middleware.subject.provider.SubjectImpl
All Implemented Interfaces:
Subject, Serializable
Direct Known Subclasses:
GrouperSubject, JNDISubject, UnresolvableSubject

public class SubjectImpl extends Object implements Subject
Base Subject implementation. Subclass this to change behavior
See Also:
  • Constructor Details

    • SubjectImpl

      public SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1)
      Constructor called by SourceManager. Will create an empty map for attributes
      Parameters:
      id1 -
      name1 -
      description1 -
      typeName1 -
      sourceId1 -
    • SubjectImpl

      public SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1, Map<String,Set<String>> attributes1)
      Constructor called by SourceManager.
      Parameters:
      id1 -
      name1 -
      description1 -
      typeName1 -
      sourceId1 -
      attributes1 -
    • SubjectImpl

      public SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1, String nameAttribute1, String descriptionAttribute1)
      Constructor called by SourceManager. Will create an empty map for attributes
      Parameters:
      id1 -
      name1 -
      description1 -
      typeName1 -
      sourceId1 -
      nameAttribute1 -
      descriptionAttribute1 -
    • SubjectImpl

      public SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1, Map<String,Set<String>> attributes1, String nameAttribute1, String descriptionAttribute1)
      Constructor called by SourceManager.
      Parameters:
      id1 -
      name1 -
      description1 -
      typeName1 -
      sourceId1 -
      attributes1 -
      nameAttribute1 -
      descriptionAttribute1 -
  • Method Details

    • toAttributeMap

      public static Map<String,Set<String>> toAttributeMap(String... strings)
      turn some strings into a map, every other is a name or value of attribute
      Parameters:
      strings -
      Returns:
      the map (never null)
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • toStringStatic

      public static String toStringStatic(Subject subject)
      toString
      Parameters:
      subject -
      Returns:
      string
    • getSourceId

      public String getSourceId()
      sourceId
      Specified by:
      getSourceId in interface Subject
      Returns:
      the sourceId
    • setSourceId

      public void setSourceId(String sourceId1)
      sourceId
      Parameters:
      sourceId1 - the sourceId to set
    • cloneSubject

      public static Subject cloneSubject(Subject subject)
      Parameters:
      subject -
      Returns:
      the cloned subject
    • runScriptStatic

      public static String runScriptStatic(String script, Map<String,Object> translationMap)
    • getId

      public String getId()
      Gets this Subject's ID.
      Specified by:
      getId in interface Subject
      Returns:
      string
    • getType

      public SubjectType getType()
      Gets this Subject's type.
      Specified by:
      getType in interface Subject
      Returns:
      subject type
    • getName

      public String getName()
      Gets this Subject's name.
      Specified by:
      getName in interface Subject
      Returns:
      name or null if not there
    • getDescription

      public String getDescription()
      Gets this Subject's description.
      Specified by:
      getDescription in interface Subject
      Returns:
      description or null if not there
    • getAttributeValue

      public String getAttributeValue(String name1)
      Description copied from interface: Subject
      Returns the value of a single-valued attribute. If multivalued, this returns the first value. This does not return values for internal attributes. Note, the keys are case-insensitive
      Specified by:
      getAttributeValue in interface Subject
      Returns:
      value or null if not found
      See Also:
    • getAttributeValue

      public String getAttributeValue(String name1, boolean excludeInternalAttributes)
      Description copied from interface: Subject
      Returns the value of a single-valued attribute. If multivalued, this returns the first value. Note, the keys are case-insensitive
      Specified by:
      getAttributeValue in interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      value or null if not found
      See Also:
    • getAttributeValues

      public Set<String> getAttributeValues(String name1)
      Description copied from interface: Subject
      Returns the values of a multi-valued attribute, or a set of size one for a single valued attribute. Note the returned set should not be changed. This does not return values for internal attributes. Note, the keys are case-insensitive
      Specified by:
      getAttributeValues in interface Subject
      Returns:
      set or empty set or null if not there
      See Also:
    • getAttributeValues

      public Set<String> getAttributeValues(String name1, boolean excludeInternalAttributes)
      Description copied from interface: Subject
      Returns the values of a multi-valued attribute, or a set of size one for a single valued attribute. Note the returned set should not be changed. Note, the keys are case-insensitive
      Specified by:
      getAttributeValues in interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      set or empty set or null if not there
      See Also:
    • getTranslationMap

      public Map<String,Object> getTranslationMap()
      Description copied from interface: Subject
      we want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation
      Specified by:
      getTranslationMap in interface Subject
      Returns:
    • setTranslationMap

      public void setTranslationMap(Map<String,Object> translationMap)
      Description copied from interface: Subject
      we want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation
      Specified by:
      setTranslationMap in interface Subject
    • attributesInittedClear

      public void attributesInittedClear()
      clear the state for attributes initted, i.e. recalculated them
    • getAttributes

      public Map<String,Set<String>> getAttributes()
      Description copied from interface: Subject
      Gets a map attribute names and values. The map's key contains the attribute name and the map's value contains a Set of attribute value(s). This does not return internal attributes. Note, the keys are case-insensitive
      Specified by:
      getAttributes in interface Subject
      Returns:
      map or empty map or null if not there
      See Also:
    • getAttributes

      public Map<String,Set<String>> getAttributes(boolean excludeInternalAttributes)
      Description copied from interface: Subject
      Gets a map attribute names and values. The map's key contains the attribute name and the map's value contains a Set of attribute value(s). The returned Map can be augmented or changed. Note, the keys are case-insensitive
      Specified by:
      getAttributes in interface Subject
      Parameters:
      excludeInternalAttributes - if true, internal attributes are not returned
      Returns:
      map or empty map or null if not there
      See Also:
    • getSource

      public Source getSource()
      Returns the Source of this Subject.
      Specified by:
      getSource in interface Subject
      Returns:
      source
    • setAttributes

      public void setAttributes(Map<String,Set<String>> attributes1)
      Parameters:
      attributes1 -
    • getTypeName

      public String getTypeName()
      Description copied from interface: Subject
      get the type name
      Specified by:
      getTypeName in interface Subject
      Returns:
      the type name
      See Also:
    • setId

      public void setId(String id1)
      Parameters:
      id1 - the id to set
    • setTypeName

      public void setTypeName(String typeName1)
      Parameters:
      typeName1 - the typeName to set
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • equalsStatic

      public static boolean equalsStatic(Subject subject, Object obj)
      Parameters:
      subject -
      obj -
      Returns:
      true if equal
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • hashcodeStatic

      public static int hashcodeStatic(Subject subject)
      Parameters:
      subject -
      Returns:
      hash code
    • getAttributeValueOrCommaSeparated

      public String getAttributeValueOrCommaSeparated(String attributeName)
      Description copied from interface: Subject
       Returns the attribute value if single-valued, or
       if multi-valued, returns the values comma separated (with a space too).
       So if the values are: a b c; this would return the string: "a, b, c"
       Implementors can use the static helper in SubjectImpl.
       This does not return values for internal attributes.
       Note, the keys are case-insensitive
       
      Specified by:
      getAttributeValueOrCommaSeparated in interface Subject
      Returns:
      value or values or null if not there
      See Also:
    • getAttributeValueOrCommaSeparated

      public String getAttributeValueOrCommaSeparated(String attributeName, boolean excludeInternalAttributes)
      Description copied from interface: Subject
       Returns the attribute value if single-valued, or
       if multi-valued, returns the values comma separated (with a space too).
       So if the values are: a b c; this would return the string: "a, b, c"
       Implementors can use the static helper in SubjectImpl.
       Note, the keys are case-insensitive
       
      Specified by:
      getAttributeValueOrCommaSeparated in interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      value or values or null if not there
      See Also:
    • attributeValueOrCommaSeparated

      public static String attributeValueOrCommaSeparated(Subject subject, String attributeName)
      Parameters:
      subject - shouldnt be null
      attributeName -
      Returns:
      the string
      See Also:
    • attributeValueOrCommaSeparated

      public static String attributeValueOrCommaSeparated(Subject subject, String attributeName, boolean excludeInternalAttributes)
      Parameters:
      subject - shouldnt be null
      attributeName -
      excludeInternalAttributes -
      Returns:
      the string
      See Also:
    • getAttributeValueSingleValued

      public String getAttributeValueSingleValued(String attributeName)
      Description copied from interface: Subject
      Returns the attribute value if single-valued, or if multi-valued, throws an exception. Implementors can use the static helper in SubjectImpl. This does not return values for internal attributes. Note, the keys are case-insensitive
      Specified by:
      getAttributeValueSingleValued in interface Subject
      Returns:
      value or null if not there
      See Also:
    • getAttributeValueSingleValued

      public String getAttributeValueSingleValued(String attributeName, boolean excludeInternalAttributes)
      Description copied from interface: Subject
      Returns the attribute value if single-valued, or if multi-valued, throws an exception. Implementors can use the static helper in SubjectImpl. Note, the keys are case-insensitive
      Specified by:
      getAttributeValueSingleValued in interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      value or null if not there
      See Also:
    • getNameOverride

      public String getNameOverride()
      Returns:
      the nameOverride
    • setName

      public void setName(String nameOverride)
      Parameters:
      nameOverride - the nameOverride to set
    • getDescriptionOverride

      public String getDescriptionOverride()
      Returns:
      the descriptionOverride
    • setDescription

      public void setDescription(String descriptionOverride)
      Parameters:
      descriptionOverride - the descriptionOverride to set
    • isResolvedFromSource

      public boolean isResolvedFromSource()
      Specified by:
      isResolvedFromSource in interface Subject
      Returns:
      true if resolved from source (rather than cache)
    • setResolvedFromSource

      public void setResolvedFromSource(boolean isResolvedFromSource)
      true if resolved from source (rather than cache)
      Specified by:
      setResolvedFromSource in interface Subject
      Parameters:
      isResolvedFromSource -