本文整理汇总了Java中org.opensaml.saml1.core.AuthenticationStatement类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationStatement类的具体用法?Java AuthenticationStatement怎么用?Java AuthenticationStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationStatement类属于org.opensaml.saml1.core包,在下文中一共展示了AuthenticationStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareResponse
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
final Authentication authentication = getAssertionFrom(model).getPrimaryAuthentication();
final DateTime issuedAt = response.getIssueInstant();
final Service service = getAssertionFrom(model).getService();
final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();
// Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
final Assertion assertion = newSamlObject(Assertion.class);
assertion.setID(generateId());
assertion.setIssueInstant(issuedAt);
assertion.setIssuer(this.issuer);
assertion.setConditions(newConditions(issuedAt, service.getId()));
final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
assertion.getAuthenticationStatements().add(authnStatement);
final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
if (!attributes.isEmpty() || isRemembered) {
assertion.getAttributeStatements().add(
newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
}
response.setStatus(newStatus(StatusCode.SUCCESS, null));
response.getAssertions().add(assertion);
}
示例2: prepareResponse
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
final Authentication authentication = getAssertionFrom(model).getChainedAuthentications().get(0);
final DateTime issuedAt = response.getIssueInstant();
final Service service = getAssertionFrom(model).getService();
final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();
// Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
final Assertion assertion = newSamlObject(Assertion.class);
assertion.setID(generateId());
assertion.setIssueInstant(issuedAt);
assertion.setIssuer(this.issuer);
assertion.setConditions(newConditions(issuedAt, service.getId()));
final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
assertion.getAuthenticationStatements().add(authnStatement);
final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
if (!attributes.isEmpty() || isRemembered) {
assertion.getAttributeStatements().add(
newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
}
response.setStatus(newStatus(StatusCode.SUCCESS, null));
response.getAssertions().add(assertion);
}
示例3: testChildElementsMarshall
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/**
* Test an XML file with Children
* @throws MarshallingException
*/
public void testChildElementsMarshall() {
Assertion assertion = (Assertion) buildXMLObject(qname);
assertion.setConditions((Conditions) buildXMLObject(Conditions.DEFAULT_ELEMENT_NAME));
assertion.setAdvice((Advice) buildXMLObject(Advice.DEFAULT_ELEMENT_NAME));
QName authenticationQname = AuthenticationStatement.DEFAULT_ELEMENT_NAME;
QName authorizationQname = AuthorizationDecisionStatement.DEFAULT_ELEMENT_NAME;
QName attributeQname = AttributeStatement.DEFAULT_ELEMENT_NAME;
assertion.getStatements().add((Statement) buildXMLObject(authenticationQname));
assertion.getStatements().add((Statement) buildXMLObject(authorizationQname));
assertion.getStatements().add((Statement) buildXMLObject(attributeQname));
assertion.getStatements().add((Statement) buildXMLObject(authenticationQname));
assertion.getStatements().add((Statement) buildXMLObject(authorizationQname));
assertion.getStatements().add((Statement) buildXMLObject(attributeQname));
assertion.getStatements().add((Statement) buildXMLObject(authorizationQname));
assertion.getStatements().add((Statement) buildXMLObject(attributeQname));
assertEquals(expectedChildElementsDOM, assertion);
}
示例4: newAuthenticationStatement
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
private AuthenticationStatement newAuthenticationStatement(final Authentication authentication) {
final String authenticationMethod = (String) authentication.getAttributes().get(
SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);
final AuthenticationStatement authnStatement = newSamlObject(AuthenticationStatement.class);
authnStatement.setAuthenticationInstant(new DateTime(authentication.getAuthenticatedDate()));
authnStatement.setAuthenticationMethod(
authenticationMethod != null
? authenticationMethod
: SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_UNSPECIFIED);
authnStatement.setSubject(newSubject(authentication.getPrincipal().getId()));
return authnStatement;
}
示例5: validate
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
public void validate(AuthenticationStatement authenticationStatement) throws ValidationException {
super.validate(authenticationStatement);
validateAuthenticationMethod(authenticationStatement);
validateAuthenticationInstant(authenticationStatement);
}
示例6: marshallAttributes
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) samlElement;
if (authenticationStatement.getAuthenticationMethod() != null) {
domElement.setAttributeNS(null, AuthenticationStatement.AUTHENTICATIONMETHOD_ATTRIB_NAME,
authenticationStatement.getAuthenticationMethod());
}
if (authenticationStatement.getAuthenticationInstant() != null) {
String value = Configuration.getSAMLDateFormatter().print(
authenticationStatement.getAuthenticationInstant());
domElement.setAttributeNS(null, AuthenticationStatement.AUTHENTICATIONINSTANT_ATTRIB_NAME, value);
}
}
示例7: processChildElement
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
throws UnmarshallingException {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) parentSAMLObject;
if (childSAMLObject instanceof SubjectLocality) {
authenticationStatement.setSubjectLocality((SubjectLocality) childSAMLObject);
} else if (childSAMLObject instanceof AuthorityBinding) {
authenticationStatement.getAuthorityBindings().add((AuthorityBinding) childSAMLObject);
} else {
super.processChildElement(parentSAMLObject, childSAMLObject);
}
}
示例8: processAttribute
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) samlObject;
if (AuthenticationStatement.AUTHENTICATIONINSTANT_ATTRIB_NAME.equals(attribute.getLocalName())
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
DateTime value = new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC());
authenticationStatement.setAuthenticationInstant(value);
} else if (AuthenticationStatement.AUTHENTICATIONMETHOD_ATTRIB_NAME.equals(attribute.getLocalName())) {
authenticationStatement.setAuthenticationMethod(attribute.getValue());
} else {
super.processAttribute(samlObject, attribute);
}
}
示例9: AuthenticationStatementSchemaTest
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** Constructor */
public AuthenticationStatementSchemaTest() {
super();
targetQName = new QName(SAMLConstants.SAML1_NS, AuthenticationStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
validator = new AuthenticationStatementSchemaValidator();
}
示例10: populateRequiredData
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
super.populateRequiredData();
AuthenticationStatement authenticationStatement = (AuthenticationStatement) target;
authenticationStatement.setAuthenticationInstant(new DateTime());
authenticationStatement.setAuthenticationMethod("Hi there!");
}
示例11: AuthenticationStatementTest
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/**
* Constructor
*/
public AuthenticationStatementTest() {
super();
expectedAuthenticationMethod = "trustme";
//
// AuthenticationInstant="1970-01-02T01:01:02.123Z"
//
expectedAuthenticationInstant = new DateTime(1970, 1, 2, 1, 1, 2, 123, ISOChronology.getInstanceUTC());
singleElementFile = "/data/org/opensaml/saml1/impl/singleAuthenticationStatement.xml";
singleElementOptionalAttributesFile = "/data/org/opensaml/saml1/impl/singleAuthenticationStatementAttributes.xml";
childElementsFile = "/data/org/opensaml/saml1/impl/AuthenticationStatementWithChildren.xml";
qname = new QName(SAMLConstants.SAML1_NS, AuthenticationStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
}
示例12: testSingleElementUnmarshall
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) unmarshallElement(singleElementFile);
assertNull("AuthenticationMethod attribute present", authenticationStatement.getAuthenticationMethod());
assertNull("AuthenticationInstant attribute present", authenticationStatement.getAuthenticationInstant());
assertNull("<Subject> element present", authenticationStatement.getSubject());
assertNull("<SubjectLocailty> element present", authenticationStatement.getSubjectLocality());
assertEquals("Non zero count of <AuthorityBinding> elements", 0, authenticationStatement.getAuthorityBindings().size());
}
示例13: testSingleElementOptionalAttributesUnmarshall
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesUnmarshall() {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) unmarshallElement(singleElementOptionalAttributesFile);
assertEquals("AuthenticationMethod", expectedAuthenticationMethod, authenticationStatement
.getAuthenticationMethod());
assertEquals("AuthenticationInstant", expectedAuthenticationInstant, authenticationStatement.getAuthenticationInstant());
}
示例14: testChildElementsUnmarshall
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/**
* Test an XML file with children
*/
public void testChildElementsUnmarshall() {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) unmarshallElement(childElementsFile);
assertNotNull("<Subject> element not present", authenticationStatement.getSubject());
assertNotNull("<SubjectLocality> element not present", authenticationStatement.getSubjectLocality());
assertNotNull("<AuthorityBinding> elements not present", authenticationStatement.getAuthorityBindings());
assertEquals("count of <AuthorityBinding> elements", 2, authenticationStatement.getAuthorityBindings().size());
AuthorityBinding authorityBinding = authenticationStatement.getAuthorityBindings().get(0);
authenticationStatement.getAuthorityBindings().remove(authorityBinding);
assertEquals("count of <AuthorityBinding> elements", 1, authenticationStatement.getAuthorityBindings().size());
}
示例15: testSingleElementOptionalAttributesMarshall
import org.opensaml.saml1.core.AuthenticationStatement; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
AuthenticationStatement authenticationStatement = (AuthenticationStatement) buildXMLObject(qname);
authenticationStatement.setAuthenticationInstant(expectedAuthenticationInstant);
authenticationStatement.setAuthenticationMethod(expectedAuthenticationMethod);
assertEquals(expectedOptionalAttributesDOM, authenticationStatement);
}