本文整理汇总了Java中org.opensaml.saml2.core.Assertion.setSignature方法的典型用法代码示例。如果您正苦于以下问题:Java Assertion.setSignature方法的具体用法?Java Assertion.setSignature怎么用?Java Assertion.setSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.Assertion
的用法示例。
在下文中一共展示了Assertion.setSignature方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChildElement
import org.opensaml.saml2.core.Assertion; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
Assertion assertion = (Assertion) parentObject;
if (childObject instanceof Issuer) {
assertion.setIssuer((Issuer) childObject);
} else if (childObject instanceof Signature) {
assertion.setSignature((Signature) childObject);
} else if (childObject instanceof Subject) {
assertion.setSubject((Subject) childObject);
} else if (childObject instanceof Conditions) {
assertion.setConditions((Conditions) childObject);
} else if (childObject instanceof Advice) {
assertion.setAdvice((Advice) childObject);
} else if (childObject instanceof Statement) {
assertion.getStatements().add((Statement) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例2: setUpTest
import org.opensaml.saml2.core.Assertion; //导入方法依赖的package包/类
@Before
public final void setUpTest() throws Exception {
credential = credentialRepository.getCredential(getProperty("wsc.certificate"), getProperty("wsc.certificate.password"));
assertion = (Assertion)SAMLUtil.unmarshallElement(getClass().getResourceAsStream("assertion.xml"));
epr = SAMLUtil.buildXMLObject(EndpointReference.class);
Address address = SAMLUtil.buildXMLObject(Address.class);
address.setValue(getProperty("sts"));
epr.setAddress(address);
Metadata md = SAMLUtil.buildXMLObject(Metadata.class);
epr.setMetadata(md);
SecurityContext ctx = SAMLUtil.buildXMLObject(SecurityContext.class);
md.getUnknownXMLObjects().add(ctx);
assertion.getSubject().getSubjectConfirmations().get(0).getSubjectConfirmationData().setNotOnOrAfter(new DateTime().plusMinutes(5));
assertion.getConditions().setNotOnOrAfter(new DateTime().plusMinutes(5));
assertion.getConditions().getAudienceRestrictions().get(0).getAudiences().get(0).setAudienceURI("tri-test1.trifork.com");
assertion.setSignature(null);
new OIOAssertion(assertion).sign(credential);
Token token = new Token();
token.setUsage("urn:liberty:security:tokenusage:2006-08:SecurityToken");
ctx.getTokens().add(token);
token.setAssertion(assertion);
stsCredential = credentialRepository.getCredential(getProperty("sts.certificate"), getProperty("sts.certificate.password"));
client = new TrustClient(epr, credential, stsCredential.getPublicKey());
client.setAppliesTo(getProperty("endpoint"));
client.setUseReferenceForDelegateToken(false);
client.setUseActAs(true);
}
示例3: setUp
import org.opensaml.saml2.core.Assertion; //导入方法依赖的package包/类
@Before
public void setUp() throws UnmarshallingException, CertificateEncodingException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException {
credential = TestHelper.getCredential();
assertion = (Assertion)SAMLUtil.unmarshallElement(getClass().getResourceAsStream("assertion.xml"));
epr = SAMLUtil.buildXMLObject(EndpointReference.class);
Address address = SAMLUtil.buildXMLObject(Address.class);
address.setValue(ADDRESS);
epr.setAddress(address);
Metadata md = SAMLUtil.buildXMLObject(Metadata.class);
epr.setMetadata(md);
SecurityContext ctx = SAMLUtil.buildXMLObject(SecurityContext.class);
md.getUnknownXMLObjects().add(ctx);
assertion.getSubject().getSubjectConfirmations().get(0).getSubjectConfirmationData().setNotOnOrAfter(new DateTime().plusMinutes(5));
assertion.getConditions().setNotOnOrAfter(new DateTime().plusMinutes(5));
assertion.getConditions().getAudienceRestrictions().get(0).getAudiences().get(0).setAudienceURI("tri-test1.trifork.com");
assertion.setSignature(null);
new OIOAssertion(assertion).sign(credential);
Token token = new Token();
token.setUsage("urn:liberty:security:tokenusage:2006-08:SecurityToken");
ctx.getTokens().add(token);
token.setAssertion(assertion);
stsCredential = TestHelper.getCredential();
client = new TrustClient(epr, credential, stsCredential.getPublicKey());
soapClient = context.mock(SOAPClient.class);
client.setSOAPClient(soapClient);
}
示例4: testVerifySignature
import org.opensaml.saml2.core.Assertion; //导入方法依赖的package包/类
@Test
public void testVerifySignature() throws Exception {
Assertion a = (Assertion) SAMLUtil.unmarshallElementFromString("<saml:Assertion Version=\"2.0\" xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"></saml:Assertion>");
Credential cred = TestHelper.getCredential();
assertFalse(new OIOSamlObject(a).verifySignature(cred.getPublicKey()));
Signature signature = SAMLUtil.createSignature("test");
signature.setSigningCredential(cred);
signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1);
signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
a.setSignature(signature);
Configuration.getMarshallerFactory().getMarshaller(a).marshall(a);
Signer.signObject(signature);
assertTrue(new OIOSamlObject(a).verifySignature(cred.getPublicKey()));
Credential cred2 = TestHelper.getCredential();
assertFalse(new OIOSamlObject(a).verifySignature(cred2.getPublicKey()));
a.setSubject(SAMLUtil.createSubject("test", "test", new DateTime()));
Configuration.getMarshallerFactory().getMarshaller(a).marshall(a);
assertFalse(new OIOSamlObject(a).verifySignature(cred.getPublicKey()));
}