Package org.opensaml.saml.common.messaging.context

# Class SAMLSubjectNameIdentifierContext

java.lang.Object
org.opensaml.messaging.context.BaseContext
org.opensaml.saml.common.messaging.context.SAMLSubjectNameIdentifierContext

All Implemented Interfaces:
  `Iterable<BaseContext>`

public final class SAMLSubjectNameIdentifierContext extends BaseContext
A context implementation which represents a SAML 1 `NameIdentifier` or a SAML 2 `NameID`.

The methods `getSubjectNameIdentifier()`, `getSAML1SubjectNameIdentifier()` and `getSAML2SubjectNameID()` will attempt to dynamically resolve the appropriate data from the SAML message held in the parent message context if the data has not been set statically by the corresponding setter method. This evaluation will be attempted only if:

- this context instance is an immediate child of a `MessageContext` as returned by `BaseContext.getParent()`
- that message context holds a SAML 1 or 2 protocol message as an instance of `SAMLObject`
- that SAML message is a type that may carry a subject: `SubjectQuery`, `SubjectQuery` or `AuthnRequest`.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.opensaml.messaging.context.BaseContext

`BaseContext.ContextSetNoRemoveIteratorDecorator, BaseContext.DeprecatedContextClassNameLookAside`

## Field Summary

Fields
Modifier and Type
Field
Description
`private org.slf4j.Logger`
`log`
Logger.
`private SAMLObject`
`nameID`
The SAML name identifier represented by this context.

## Constructor Summary

Constructors
Constructor
Description
`SAMLSubjectNameIdentifierContext()`

## Method Summary

Modifier and Type
Method
Description
`NameIdentifier`
`getSAML1SubjectNameIdentifier()`
Gets the SAML 1 `NameIdentifier` represented by this context.
`NameID`
`getSAML2SubjectNameID()`
Gets the SAML 2 `NameID` represented by this context.
`SAMLObject`
`getSubjectNameIdentifier()`
Gets the subject name identifier represented by the context, which is guaranteed to be either a SAML 1 `NameIdentifier` or a SAML 2 `NameID`.
`protected SAMLObject`
`resolveNameIdentifier()`
Dynamically resolve the name identifier from the SAML protocol message held in `MessageContext.getMessage()`, if it exists.
`protected SAMLObject`
`resolveSAMLMessage()`
Resolve the SAML message from the message context.
`void`
`setSubjectNameIdentifier(SAMLObject newNameID)`
Sets the name identifier, which must be either a SAML 1 `NameIdentifier` or a SAML 2 `NameID` or null.

### Methods inherited from class org.opensaml.messaging.context.BaseContext

`addSubcontext, addSubcontext, clearSubcontexts, containsSubcontext, createSubcontext, ensureSubcontext, ensureSubcontext, getParent, getSubcontext, getSubcontext, getSubcontext, getSubcontext, iterator, removeFromParent, removeSubcontext, removeSubcontext, setParent`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Field Details

### log

@Nonnull private org.slf4j.Logger log
Logger.

### nameID

@Nullable private SAMLObject nameID
The SAML name identifier represented by this context.

## Constructor Details

### SAMLSubjectNameIdentifierContext

public SAMLSubjectNameIdentifierContext()

## Method Details

### getSubjectNameIdentifier

@Nullable public SAMLObject getSubjectNameIdentifier()
Gets the subject name identifier represented by the context, which is guaranteed to be either a SAML 1 `NameIdentifier` or a SAML 2 `NameID`.

The value will be dynamically resolved if the immediate parent context of this context is a `MessageContext` holding a `SAMLObject` representing a SAML protocol message, and that protocol message contains a SAML 1 or SAML 2 subject.

Returns:
  the name identifier instance, may be null

### getSAML1SubjectNameIdentifier

@Nullable public NameIdentifier getSAML1SubjectNameIdentifier()
Gets the SAML 1 `NameIdentifier` represented by this context.

Dynamic resolution is attempted per `getSubjectNameIdentifier()`.

Returns:
  the name identifier instance or null

### getSAML2SubjectNameID

@Nullable public NameID getSAML2SubjectNameID()
Gets the SAML 2 `NameID` represented by this context.

Dynamic resolution is attempted per `getSubjectNameIdentifier()`.

Returns:
  the name identifier instance or null

### setSubjectNameIdentifier

public void setSubjectNameIdentifier(@Nullable SAMLObject newNameID)
Sets the name identifier, which must be either a SAML 1 `NameIdentifier` or a SAML 2 `NameID` or null.

Parameters:
  `newNameID` - the name identifier instance

### resolveNameIdentifier

@Nullable protected SAMLObject resolveNameIdentifier()
Dynamically resolve the name identifier from the SAML protocol message held in `MessageContext.getMessage()`, if it exists.

Returns:
  the name identifier, or null if it can not be resolved

### resolveSAMLMessage

@Nullable protected SAMLObject resolveSAMLMessage()
Resolve the SAML message from the message context.

Returns:
  the SAML message, or null if it can not be resolved