本文整理汇总了Java中org.opensaml.saml.common.SAMLObject类的典型用法代码示例。如果您正苦于以下问题:Java SAMLObject类的具体用法?Java SAMLObject怎么用?Java SAMLObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SAMLObject类属于org.opensaml.saml.common包,在下文中一共展示了SAMLObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeSamlResponse
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Encode response and pass it onto the outbound transport.
* Uses {@link CasHttpSoap11Encoder} to handle encoding.
*
* @param httpResponse the http response
* @param httpRequest the http request
* @param samlMessage the saml response
* @throws Exception the exception in case encoding fails.
*/
public void encodeSamlResponse(final HttpServletResponse httpResponse,
final HttpServletRequest httpRequest,
final Response samlMessage) throws Exception {
SamlUtils.logSamlObject(this.configBean, samlMessage);
final HTTPSOAP11Encoder encoder = new CasHttpSoap11Encoder();
final MessageContext<SAMLObject> context = new MessageContext();
context.setMessage(samlMessage);
encoder.setHttpServletResponse(httpResponse);
encoder.setMessageContext(context);
encoder.initialize();
encoder.prepareContext();
encoder.encode();
}
示例2: encryptAssertion
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Encrypt assertion.
*
* @param assertion the assertion
* @param request the request
* @param response the response
* @param service the service
* @param adaptor the adaptor
* @return the saml object
* @throws SamlException the saml exception
*/
protected SAMLObject encryptAssertion(final Assertion assertion,
final HttpServletRequest request, final HttpServletResponse response,
final SamlRegisteredService service,
final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {
try {
if (service.isEncryptAssertions()) {
LOGGER.info("SAML service [{}] requires assertions to be encrypted", adaptor.getEntityId());
final EncryptedAssertion encryptedAssertion =
this.samlObjectEncrypter.encode(assertion, service, adaptor, response, request);
return encryptedAssertion;
}
LOGGER.info("SAML registered service [{}] does not require assertions to be encrypted", adaptor.getEntityId());
return assertion;
} catch (final Exception e) {
throw new SamlException("Unable to marshall assertion for encryption", e);
}
}
示例3: encode
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Encode a given saml object by invoking a number of outbound security handlers on the context.
*
* @param <T> the type parameter
* @param samlObject the saml object
* @param service the service
* @param adaptor the adaptor
* @param response the response
* @param request the request
* @param binding the binding
* @return the t
* @throws SamlException the saml exception
*/
public <T extends SAMLObject> T encode(final T samlObject,
final SamlRegisteredService service,
final SamlRegisteredServiceServiceProviderMetadataFacade adaptor,
final HttpServletResponse response,
final HttpServletRequest request,
final String binding) throws SamlException {
try {
LOGGER.debug("Attempting to encode [{}] for [{}]", samlObject.getClass().getName(), adaptor.getEntityId());
final MessageContext<T> outboundContext = new MessageContext<>();
prepareOutboundContext(samlObject, adaptor, outboundContext, binding);
prepareSecurityParametersContext(adaptor, outboundContext);
prepareEndpointURLSchemeSecurityHandler(outboundContext);
prepareSamlOutboundDestinationHandler(outboundContext);
prepareSamlOutboundProtocolMessageSigningHandler(outboundContext);
return samlObject;
} catch (final Exception e) {
throw new SamlException(e.getMessage(), e);
}
}
示例4: doEncode
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
@Override
protected void doEncode() throws MessageEncodingException {
final MessageContext messageContext = this.getMessageContext();
final SAMLObject outboundMessage = (SAMLObject)messageContext.getMessage();
final String endpointURL = this.getEndpointURL(messageContext).toString();
if (!this.forceSignRedirectBindingAuthnRequest) {
this.removeSignature(outboundMessage);
}
final String encodedMessage = this.deflateAndBase64Encode(outboundMessage);
final String redirectURL = this.buildRedirectURL(messageContext, endpointURL, encodedMessage);
responseAdapter.init();
responseAdapter.setRedirectUrl(redirectURL);
}
示例5: deflateAndBase64Encode
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* DEFLATE (RFC1951) compresses the given SAML message.
*
* @param message SAML message
*
* @return DEFLATE compressed message
*
* @throws MessageEncodingException thrown if there is a problem compressing the message
*/
protected String deflateAndBase64Encode(SAMLObject message) throws MessageEncodingException {
log.debug("Deflating and Base64 encoding SAML message");
try {
String messageStr = SerializeSupport.nodeToString(marshallMessage(message));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
return Base64Support.encode(bytesOut.toByteArray(), Base64Support.UNCHUNKED);
} catch (IOException e) {
throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
}
}
示例6: postEncode
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
protected void postEncode(final MessageContext<SAMLObject> messageContext, final String endpointURL) throws MessageEncodingException {
log.debug("Invoking Velocity template to create POST body");
try {
final VelocityContext e = new VelocityContext();
this.populateVelocityContext(e, messageContext, endpointURL);
responseAdapter.setContentType("text/html");
responseAdapter.init();
final OutputStreamWriter out = responseAdapter.getOutputStreamWriter();
this.getVelocityEngine().mergeTemplate(this.getVelocityTemplateId(), "UTF-8", e, out);
out.flush();
} catch (Exception var6) {
throw new MessageEncodingException("Error creating output document", var6);
}
}
示例7: doDecode
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
@Override
protected void doDecode() throws MessageDecodingException {
final MessageContext messageContext = new MessageContext();
if(!"POST".equalsIgnoreCase(this.context.getRequestMethod())) {
throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
} else {
final String relayState = this.context.getRequestParameter("RelayState");
logger.debug("Decoded SAML relay state of: {}", relayState);
SAMLBindingSupport.setRelayState(messageContext, relayState);
final InputStream base64DecodedMessage = this.getBase64DecodedMessage();
final SAMLObject inboundMessage = (SAMLObject)this.unmarshallMessage(base64DecodedMessage);
messageContext.setMessage(inboundMessage);
logger.debug("Decoded SAML message");
this.populateBindingContext(messageContext);
this.setMessageContext(messageContext);
}
}
示例8: validate
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Validates the SAML protocol response and the SAML SSO response.
* The method decrypt encrypted assertions if any.
*
* @param context the context
*/
@Override
public Credentials validate(final SAML2MessageContext context) {
final SAMLObject message = context.getMessage();
if (!(message instanceof Response)) {
throw new SAMLException("Response instance is an unsupported type");
}
final Response response = (Response) message;
final SignatureTrustEngine engine = this.signatureTrustEngineProvider.build();
validateSamlProtocolResponse(response, context, engine);
if (decrypter != null) {
decryptEncryptedAssertions(response, decrypter);
}
validateSamlSSOResponse(response, context, engine, decrypter);
return buildSAML2Credentials(context);
}
示例9: doExecute
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
@Override
protected void doExecute(@Nonnull final ProfileRequestContext<SAMLObject, SAMLObject> profileRequestContext) {
logger.debug("Entering GenerateNewToken doExecute");
try {
LinotpConnection connection = new LinotpConnection(host, serviceUsername, servicePassword, checkCert);
connection.requestAdminSession();
List<LinotpTokenInfo> tokenList = connection.getTokenInfoList(username);
if (createEmailToken && tokenList.size() == 0) {
List<LinotpUser> userList = connection.getUserList("userid", username);
if (userList.size() == 1) {
connection.initEmailToken(username, userList.get(0).getEmail());
tokenList = connection.getTokenInfoList(username);
}
}
tokenCtx.setTokenList(tokenList);
connection.generateToken(tokenCtx);
} catch (Exception e) {
logger.debug("Failed to create new token", e);
}
}
示例10: doExecute
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
@Nonnull
@Override
protected Event doExecute(
final @Nonnull RequestContext springRequestContext,
final @Nonnull ProfileRequestContext<SAMLObject, SAMLObject> profileRequestContext) {
final MessageContext<SAMLObject> msgContext = new MessageContext<>();
try {
msgContext.setMessage(buildSamlResponse(springRequestContext, profileRequestContext));
} catch (IllegalStateException e) {
return ProtocolError.IllegalState.event(this);
}
final SAMLBindingContext bindingContext = new SAMLBindingContext();
bindingContext.setBindingUri(SAMLConstants.SAML1_SOAP11_BINDING_URI);
msgContext.addSubcontext(bindingContext);
profileRequestContext.setOutboundMessageContext(msgContext);
// Return null to signal that other actions must follow this one before proceeding to next state
return null;
}
示例11: buildSamlResponse
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
@Nonnull
@Override
protected Response buildSamlResponse(
final @Nonnull RequestContext springRequestContext,
final @Nonnull ProfileRequestContext<SAMLObject, SAMLObject> profileRequestContext) {
final String code = (String) springRequestContext.getFlashScope().get("code");
final String detailCode = (String) springRequestContext.getFlashScope().get("detailCode");
final Response response = newSAMLObject(Response.class, Response.DEFAULT_ELEMENT_NAME);
final Status status = newSAMLObject(Status.class, Status.DEFAULT_ELEMENT_NAME);
final StatusCode statusCode = newSAMLObject(StatusCode.class, StatusCode.DEFAULT_ELEMENT_NAME);
statusCode.setValue(new QName(NAMESPACE, code));
status.setStatusCode(statusCode);
final StatusMessage message = newSAMLObject(StatusMessage.class, StatusMessage.DEFAULT_ELEMENT_NAME);
message.setMessage(detailCode);
status.setStatusMessage(message);
response.setStatus(status);
return response;
}
示例12: newSamlObject
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Create a new SAML object.
*
* @param <T> the generic type
* @param objectType the object type
* @return the t
*/
public final <T extends SAMLObject> T newSamlObject(final Class<T> objectType) {
final QName qName = getSamlObjectQName(objectType);
final SAMLObjectBuilder<T> builder = (SAMLObjectBuilder<T>)
XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName);
if (builder == null) {
throw new IllegalStateException("No SAMLObjectBuilder registered for class " + objectType.getName());
}
return objectType.cast(builder.buildObject(qName));
}
示例13: encodeSamlResponse
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Encode response and pass it onto the outbound transport.
* Uses {@link CasHttpSoap11Encoder} to handle encoding.
*
* @param httpResponse the http response
* @param httpRequest the http request
* @param samlMessage the saml response
* @throws Exception the exception in case encoding fails.
*/
public void encodeSamlResponse(final HttpServletResponse httpResponse,
final HttpServletRequest httpRequest,
final Response samlMessage) throws Exception {
final HTTPSOAP11Encoder encoder = new CasHttpSoap11Encoder();
final MessageContext<SAMLObject> context = new MessageContext();
context.setMessage(samlMessage);
encoder.setHttpServletResponse(httpResponse);
encoder.setMessageContext(context);
encoder.initialize();
encoder.prepareContext();
encoder.encode();
}
示例14: encodeSamlResponse
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Encode response and pass it onto the outbound transport.
* Uses {@link CasHTTPSOAP11Encoder} to handle encoding.
*
* @param httpResponse the http response
* @param httpRequest the http request
* @param samlMessage the saml response
* @throws Exception the exception in case encoding fails.
*/
public void encodeSamlResponse(final HttpServletResponse httpResponse,
final HttpServletRequest httpRequest,
final Response samlMessage) throws Exception {
final HTTPSOAP11Encoder encoder = new CasHTTPSOAP11Encoder();
final MessageContext<SAMLObject> context = new MessageContext();
context.setMessage(samlMessage);
encoder.setHttpServletResponse(httpResponse);
encoder.setMessageContext(context);
encoder.initialize();
encoder.prepareContext();
encoder.encode();
}
示例15: newSamlObject
import org.opensaml.saml.common.SAMLObject; //导入依赖的package包/类
/**
* Create a new SAML object.
*
* @param <T> the generic type
* @param objectType the object type
* @return the t
*/
public <T extends SAMLObject> T newSamlObject(final Class<T> objectType) {
final QName qName = getSamlObjectQName(objectType);
final SAMLObjectBuilder<T> builder = (SAMLObjectBuilder<T>)
XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName);
if (builder == null) {
throw new IllegalStateException("No SAML object builder is registered for class " + objectType.getName());
}
return objectType.cast(builder.buildObject(qName));
}