本文整理汇总了Java中org.opensaml.saml2.core.Response.setIssueInstant方法的典型用法代码示例。如果您正苦于以下问题:Java Response.setIssueInstant方法的具体用法?Java Response.setIssueInstant怎么用?Java Response.setIssueInstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.Response
的用法示例。
在下文中一共展示了Response.setIssueInstant方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
public Response buildResponse(SAMLSSOAuthnReqDTO authReqDTO, Assertion assertion)
throws IdentityException {
if (log.isDebugEnabled()) {
log.debug("Building SAML Response for the consumer '"
+ authReqDTO.getAssertionConsumerURL() + "'");
}
Response response = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
response.setIssuer(SAMLSSOUtil.getIssuer());
response.setID(SAMLSSOUtil.createID());
response.setInResponseTo(authReqDTO.getId());
response.setDestination(authReqDTO.getAssertionConsumerURL());
response.setStatus(buildStatus(SAMLSSOConstants.StatusCodes.SUCCESS_CODE, null));
response.setVersion(SAMLVersion.VERSION_20);
DateTime issueInstant = new DateTime();
response.setIssueInstant(issueInstant);
response.getAssertions().add(assertion);
if (authReqDTO.isDoSignResponse()) {
SAMLSSOUtil.setSignature(response, authReqDTO.getSigningAlgorithmUri(), authReqDTO.getDigestAlgorithmUri
(), new SignKeyDataHolder(authReqDTO.getUser().getAuthenticatedSubjectIdentifier()));
}
return response;
}
示例2: buildResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Build the SAML Response Object
*
* @param pRequestContext
* @param pTimeoutMS
* @param pRecipient
* @param pAudienceURI
* @param pAssertionAttributes
* @param pSignResponse
* @param pSignAssertion
* @param pDigitalCertificateName
* @return SAML Response Object
*/
private Response buildResponse(ActionRequestContext pRequestContext
, Integer pTimeoutMS
, String pRecipient
, String pAudienceURI
, Map<String, String> pAssertionAttributes
, boolean pSignResponse
, boolean pSignAssertion
, String pDigitalCertificateName
) {
Response lResponse = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
lResponse.setIssuer(buildIssuer(pRequestContext.getFoxRequest().getHttpRequest().getRequestURL().toString()));
lResponse.setID(RESPONSE_ID_PREFIX + RandomString.getString(40));
// lResponse.setInResponseTo(authReqDTO.getId());
// lResponse.setDestination(authReqDTO.getAssertionConsumerURL());
lResponse.setStatus(buildStatus(StatusCode.SUCCESS_URI));
lResponse.setVersion(SAMLVersion.VERSION_20);
DateTime issueInstant = new DateTime();
lResponse.setIssueInstant(issueInstant);
DateTime lNotOnOrAfter = new DateTime(issueInstant.getMillis() + pTimeoutMS);
Assertion assertion = buildSAMLAssertion(pRequestContext, lNotOnOrAfter, pRecipient, pAudienceURI, pAssertionAttributes, pSignAssertion, pDigitalCertificateName);
lResponse.getAssertions().add(assertion);
// Sign the SAML Response object
if (pSignResponse) {
signSAMLObject(lResponse, pRequestContext, pDigitalCertificateName);
}
return lResponse;
}
示例3: buildSAMLResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Build SAML response using IdP configuration & user name
*
* @param ssoIdPConfigs
* @param userName
* @return SAML Response object
* @throws IdentityException
*/
public Response buildSAMLResponse(SAMLSSOServiceProviderDO ssoIdPConfigs, String userName)
throws IdentityException {
if (log.isDebugEnabled()) {
log.debug("Building SAML Response for the consumer '" +
ssoIdPConfigs.getAssertionConsumerUrl() + "'");
}
Response response = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
response.setIssuer(SAMLSSOUtil.getIssuer());
response.setID(SAMLSSOUtil.createID());
response.setDestination(ssoIdPConfigs.getAssertionConsumerUrl());
response.setStatus(buildStatus(SAMLSSOConstants.StatusCodes.SUCCESS_CODE, null));
response.setVersion(SAMLVersion.VERSION_20);
DateTime issueInstant = new DateTime();
DateTime notOnOrAfter =
new DateTime(issueInstant.getMillis() +
SAMLSSOUtil.getSAMLResponseValidityPeriod() * 60 *
1000);
response.setIssueInstant(issueInstant);
Assertion assertion = buildSAMLAssertion(ssoIdPConfigs, notOnOrAfter, userName);
if (ssoIdPConfigs.isDoEnableEncryptedAssertion()) {
String domainName = MultitenantUtils.getTenantDomain(userName);
String alias = ssoIdPConfigs.getCertAlias();
if (alias != null) {
EncryptedAssertion encryptedAssertion =
SAMLSSOUtil.setEncryptedAssertion(assertion,
EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256,
alias,
domainName);
response.getEncryptedAssertions().add(encryptedAssertion);
}
} else {
response.getAssertions().add(assertion);
}
if (ssoIdPConfigs.isDoSignResponse()) {
SAMLSSOUtil.setSignature(response, ssoIdPConfigs.getSigningAlgorithmUri(), ssoIdPConfigs
.getDigestAlgorithmUri(), new SignKeyDataHolder(userName));
}
return response;
}
示例4: createResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private Response createResponse(final DateTime issueDate, Issuer issuer, Status status, Assertion assertion) {
ResponseBuilder responseBuilder = new ResponseBuilder();
Response response = responseBuilder.buildObject();
response.setID(UUID.randomUUID().toString());
response.setIssueInstant(issueDate);
response.setVersion(SAMLVersion.VERSION_20);
response.setIssuer(issuer);
response.setStatus(status);
response.getAssertions().add(assertion);
return response;
}
示例5: buildMockResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private Response buildMockResponse() throws Exception {
Response samlMessage = new ResponseBuilder().buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
Issuer issuer = new IssuerBuilder().buildObject();
issuer.setValue("MockedIssuer");
samlMessage.setIssuer(issuer);
Status status = new StatusBuilder().buildObject();
StatusCode statusCode = new StatusCodeBuilder().buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
status.setStatusCode(statusCode);
samlMessage.setStatus(status);
Assertion assertion = new AssertionBuilder().buildObject();
Subject subject = new SubjectBuilder().buildObject();
NameID nameID = new NameIDBuilder().buildObject();
nameID.setValue("SOME-UNIQUE-ID");
nameID.setFormat(NameIDType.PERSISTENT);
subject.setNameID(nameID);
assertion.setSubject(subject);
AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
authnStatement.setSessionIndex("Some Session String");
assertion.getAuthnStatements().add(authnStatement);
AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
assertion.getAttributeStatements().add(attributeStatement);
samlMessage.getAssertions().add(assertion);
return samlMessage;
}
示例6: createResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private static Response createResponse() throws Exception {
Response response = create(Response.DEFAULT_ELEMENT_NAME);
response.setID(GENERATOR.generateIdentifier());
if (SamlResponseData.REPLACE_WITH_AUTHN_REQUEST.equals(samlResponseData
.getInResponseTo())) {
response.setInResponseTo(authnRequest.getID());
} else
response.setInResponseTo(samlResponseData.getInResponseTo());
if (SamlResponseData.REPLACE_WITH_AUTHN_REQUEST.equals(samlResponseData
.getDestination()))
response.setDestination(authnRequest
.getAssertionConsumerServiceURL());
else
response.setDestination(samlResponseData.getDestination());
if (samlResponseData.getIssueInstant() != null) {
response.setIssueInstant(startTime.plusMinutes(samlResponseData
.getIssueInstant()));
}
response.setIssuer(createIssuer(samlResponseData.getIssuer()));
response.setStatus(createStatus());
response.getAssertions().add(createAssertion());
return response;
}
示例7: testResponseEncoding
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Tests encoding a SAML message to an servlet response.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
.getBuilder(Status.DEFAULT_ELEMENT_NAME);
Status responseStatus = statusBuilder.buildObject();
responseStatus.setStatusCode(statusCode);
SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
.getBuilder(Response.DEFAULT_ELEMENT_NAME);
Response samlMessage = responseBuilder.buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
samlMessage.setStatus(responseStatus);
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation("http://example.org");
samlEndpoint.setResponseLocation("http://example.org/response");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(outTransport);
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setOutboundSAMLMessage(samlMessage);
messageContext.setRelayState("relay");
HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
"/templates/saml2-post-binding.vm");
encoder.encode(messageContext);
assertEquals("Unexpected content type", "text/html", response.getContentType());
assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
assertEquals(762244719, response.getContentAsString().hashCode());
}
示例8: testResponseEncoding
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Tests encoding a SAML message to an servlet response.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
.getBuilder(Status.DEFAULT_ELEMENT_NAME);
Status responseStatus = statusBuilder.buildObject();
responseStatus.setStatusCode(statusCode);
SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
.getBuilder(Response.DEFAULT_ELEMENT_NAME);
Response samlMessage = responseBuilder.buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
samlMessage.setStatus(responseStatus);
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation("http://example.org");
samlEndpoint.setResponseLocation("http://example.org/response");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(outTransport);
messageContext.setOutboundSAMLMessage(samlMessage);
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setRelayState("relay");
HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
encoder.encode(messageContext);
assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
assertEquals(406515062, response.getRedirectedUrl().hashCode());
}
示例9: testResponseEncodingWithSimpleSign
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Tests encoding a SAML message to an servlet response with simple sign.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testResponseEncodingWithSimpleSign() throws Exception {
SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
.getBuilder(Status.DEFAULT_ELEMENT_NAME);
Status responseStatus = statusBuilder.buildObject();
responseStatus.setStatusCode(statusCode);
SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
.getBuilder(Response.DEFAULT_ELEMENT_NAME);
Response samlMessage = responseBuilder.buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
samlMessage.setStatus(responseStatus);
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation("http://example.org");
samlEndpoint.setResponseLocation("http://example.org/response");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(outTransport);
messageContext.setOutboundSAMLMessage(samlMessage);
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setRelayState("relay");
KeyPair kp = SecurityTestHelper.generateKeyPair("RSA", 1024, null);
messageContext.setOutboundSAMLMessageSigningCredential(
SecurityHelper.getSimpleCredential(kp.getPublic(), kp.getPrivate()));
HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
encoder.encode(messageContext);
String queryString = new URL(response.getRedirectedUrl()).getQuery();
assertNotNull("Signature parameter was not found",
HTTPTransportUtils.getRawQueryStringParameter(queryString, "Signature"));
assertNotNull("SigAlg parameter was not found",
HTTPTransportUtils.getRawQueryStringParameter(queryString, "SigAlg"));
// Note: to test that actual signature is cryptographically correct, really need a known good test vector.
// Need to verify that we're signing over the right data in the right byte[] encoded form.
}
示例10: testResponseEncoding
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Tests encoding a SAML message to an servlet response.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
.getBuilder(Status.DEFAULT_ELEMENT_NAME);
Status responseStatus = statusBuilder.buildObject();
responseStatus.setStatusCode(statusCode);
SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
.getBuilder(Response.DEFAULT_ELEMENT_NAME);
Response samlMessage = responseBuilder.buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
samlMessage.setStatus(responseStatus);
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation("http://example.org");
samlEndpoint.setResponseLocation("http://example.org/response");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(outTransport);
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setOutboundSAMLMessage(samlMessage);
messageContext.setRelayState("relay");
HTTPSOAP11Encoder encoder = new HTTPSOAP11Encoder();
encoder.encode(messageContext);
assertEquals("Unexpected content type", "text/xml", response.getContentType());
assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
assertEquals("http://www.oasis-open.org/committees/security", response.getHeader("SOAPAction"));
assertEquals(1568886506, response.getContentAsString().hashCode());
}
示例11: testResponseEncoding
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
* Tests encoding a SAML message to an servlet response.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
.getBuilder(Status.DEFAULT_ELEMENT_NAME);
Status responseStatus = statusBuilder.buildObject();
responseStatus.setStatusCode(statusCode);
SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
.getBuilder(Response.DEFAULT_ELEMENT_NAME);
Response samlMessage = responseBuilder.buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
samlMessage.setStatus(responseStatus);
SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Endpoint samlEndpoint = endpointBuilder.buildObject();
samlEndpoint.setLocation("http://example.org");
samlEndpoint.setResponseLocation("http://example.org/response");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(outTransport);
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setOutboundSAMLMessage(samlMessage);
messageContext.setRelayState("relay");
HTTPPostSimpleSignEncoder encoder = new HTTPPostSimpleSignEncoder(velocityEngine,
"/templates/saml2-post-simplesign-binding.vm");
encoder.encode(messageContext);
assertEquals("Unexpected content type", "text/html", response.getContentType());
assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
assertEquals(-1652577171, response.getContentAsString().hashCode());
}
示例12: buildArtifactResponse
import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private ArtifactResponse buildArtifactResponse() throws IllegalAccessException, NoSuchAlgorithmException, KeyStoreException,
java.security.cert.CertificateException, CertificateException, IOException, SecurityException, EncryptionException, NoSuchProviderException,
SignatureException, MarshallingException, MetadataProviderException {
SecureRandomIdentifierGenerator idGenerator = new SecureRandomIdentifierGenerator();
ArtifactResponse artifactResponse = buildXMLObjectDefaultName(ArtifactResponse.class);
Issuer issuer = buildXMLObjectDefaultName(Issuer.class);
issuer.setValue(MockIDPProperties.getIdpEntityId());
artifactResponse.setIssuer(issuer);
artifactResponse.setIssueInstant(new DateTime());
artifactResponse.setDestination(MockIDPSPMetadata.getSpConsumerUrl());
artifactResponse.setID(idGenerator.generateIdentifier());
Status status = buildXMLObjectDefaultName(Status.class);
StatusCode statusCode = buildXMLObjectDefaultName(StatusCode.class);
statusCode.setValue(StatusCode.SUCCESS_URI);
status.setStatusCode(statusCode);
artifactResponse.setStatus(status);
Response response = buildXMLObjectDefaultName(Response.class);
response.setDestination(MockIDPSPMetadata.getSpConsumerUrl());
response.setIssueInstant(new DateTime());
response.setID(idGenerator.generateIdentifier());
response.setInResponseTo(MockIDPAuthnReq.authnReqId);
Issuer issuer2 = buildXMLObjectDefaultName(Issuer.class);
issuer2.setValue(MockIDPProperties.getIdpEntityId());
response.setIssuer(issuer2);
Status status2 = buildXMLObjectDefaultName(Status.class);
StatusCode statusCode2 = buildXMLObjectDefaultName(StatusCode.class);
statusCode2.setValue(StatusCode.SUCCESS_URI);
status2.setStatusCode(statusCode2);
response.setStatus(status2);
artifactResponse.setMessage(response);
response.getEncryptedAssertions().add(encryptAssertion(buildAssertion()));
return artifactResponse;
}