use of com.sun.identity.saml.assertion.SubjectConfirmation in project OpenAM by OpenRock.
the class LibSecurityTokenProvider method createAttributeStatement.
private AttributeStatement createAttributeStatement(NameIdentifier senderIdentity, List attributes, boolean isBearer) {
AttributeStatement attributeStatement = null;
try {
Subject subject = null;
SubjectConfirmation subConfirmation = null;
if (isBearer) {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_BEARER);
} else {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_HOLDEROFKEY);
subConfirmation.setKeyInfo(createKeyInfo());
}
subject = new Subject(senderIdentity, subConfirmation);
return new AttributeStatement(subject, attributes);
} catch (Exception e) {
if (debug.messageEnabled()) {
debug.message("createAttributeStatement: ", e);
}
}
return null;
}
use of com.sun.identity.saml.assertion.SubjectConfirmation in project OpenAM by OpenRock.
the class LibSecurityTokenProvider method createProxySubject.
/**
* Creates a <code>ProxySubject</code> object.
*/
private ProxySubject createProxySubject(NameIdentifier senderIdentity, boolean isBear) throws SecurityTokenException, SAMLException {
SubjectConfirmation subConfirmation = null;
if (isBear) {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_BEARER);
} else {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_HOLDEROFKEY);
subConfirmation.setKeyInfo(createKeyInfo());
}
return new ProxySubject(senderIdentity, subConfirmation);
}
use of com.sun.identity.saml.assertion.SubjectConfirmation in project OpenAM by OpenRock.
the class LibSecurityTokenProvider method createAuthenticationStatement.
/**
* Creates Authentication Statement for the name identifier.
*/
private AuthenticationStatement createAuthenticationStatement(NameIdentifier senderIdentity, boolean isBearer) throws SecurityTokenException {
AuthenticationStatement authStatement = null;
try {
String authMethod = SAMLServiceManager.getAuthMethodURI(authType);
Date authInstant = DateUtils.stringToDate(authTime);
Subject subject = null;
SubjectConfirmation subConfirmation = null;
if (isBearer) {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_BEARER);
} else {
subConfirmation = new SubjectConfirmation(SAMLConstants.CONFIRMATION_METHOD_HOLDEROFKEY);
subConfirmation.setKeyInfo(createKeyInfo());
}
subject = new Subject(senderIdentity, subConfirmation);
authStatement = new AuthenticationStatement(authMethod, authInstant, subject);
} catch (Exception e) {
debug.error("createAuthenticationStatement: ", e);
throw new SecurityTokenException(e.getMessage());
}
return authStatement;
}
use of com.sun.identity.saml.assertion.SubjectConfirmation in project OpenAM by OpenRock.
the class SecurityAssertion method isBearer.
/**
* Determines if the <code>SecurityAssertion</code> contains SAML Bearer
* confirmation method.
*
* @return true if the <code>SecurityAssertion</code> contains SAML Bearer
* confirmation.
*/
public boolean isBearer() {
if (_statements == null || _statements.isEmpty()) {
return false;
}
Iterator iter = _statements.iterator();
while (iter.hasNext()) {
Object statement = iter.next();
if (!(statement instanceof SubjectStatement)) {
continue;
}
Subject subject = ((SubjectStatement) statement).getSubject();
if (subject == null) {
continue;
}
SubjectConfirmation sc = subject.getSubjectConfirmation();
if (sc == null) {
continue;
}
Set confirmationMethods = sc.getConfirmationMethod();
if (confirmationMethods == null || confirmationMethods.isEmpty()) {
continue;
}
if (confirmationMethods.contains(SAMLConstants.CONFIRMATION_METHOD_BEARER)) {
return true;
}
}
return false;
}
use of com.sun.identity.saml.assertion.SubjectConfirmation in project OpenAM by OpenRock.
the class SecurityAssertion method getBearerSubject.
/**
* Determines if the <code>SecurityAssertion</code> contains SAML Bearer
* confirmation method. If it is, return its Subject. Otherwise, return
* null.
*
* @return Subject if the <code>SecurityAssertion</code> contains SAML
* Bearer confirmation.
*/
public Subject getBearerSubject() {
if (_statements == null || _statements.isEmpty()) {
return null;
}
Iterator iter = _statements.iterator();
while (iter.hasNext()) {
Object statement = iter.next();
if (!(statement instanceof SubjectStatement)) {
continue;
}
Subject subject = ((SubjectStatement) statement).getSubject();
if (subject == null) {
continue;
}
SubjectConfirmation sc = subject.getSubjectConfirmation();
if (sc == null) {
continue;
}
Set confirmationMethods = sc.getConfirmationMethod();
if (confirmationMethods == null || confirmationMethods.isEmpty()) {
continue;
}
if (confirmationMethods.contains(SAMLConstants.CONFIRMATION_METHOD_BEARER)) {
return subject;
}
}
return null;
}
Aggregations