本文整理汇总了Java中org.opensaml.common.SAMLObject类的典型用法代码示例。如果您正苦于以下问题:Java SAMLObject类的具体用法?Java SAMLObject怎么用?Java SAMLObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SAMLObject类属于org.opensaml.common包,在下文中一共展示了SAMLObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSOAPMessage
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
@Override
protected Envelope buildSOAPMessage(final SAMLObject samlMessage) {
final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
final SOAPObjectBuilder<Envelope> envBuilder =
(SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
final Envelope envelope = envBuilder.buildObject(
SOAPConstants.SOAP11_NS, Envelope.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
final SOAPObjectBuilder<Body> bodyBuilder =
(SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
final Body body = bodyBuilder.buildObject(
SOAPConstants.SOAP11_NS, Body.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例2: buildSOAPMessage
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
log.debug("Building SOAP message");
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
log.debug("Adding SAML message to the SOAP message's body");
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例3: populateMessageIdIssueInstantIssuer
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Extracts the message ID, issue instant, and issuer from the incoming SAML message and populates the message
* context with it.
*
* @param messageContext current message context
*
* @throws MessageDecodingException thrown if there is a problem populating the message context
*/
protected void populateMessageIdIssueInstantIssuer(SAMLMessageContext messageContext)
throws MessageDecodingException {
SAMLObject samlMsg = messageContext.getInboundSAMLMessage();
if (samlMsg == null) {
return;
}
if (samlMsg instanceof RequestAbstractType) {
log.debug("Extracting ID, issuer and issue instant from request");
extractRequestInfo(messageContext, (RequestAbstractType) samlMsg);
} else if (samlMsg instanceof Response) {
log.debug("Extracting ID, issuer and issue instant from response");
extractResponseInfo(messageContext, (Response) samlMsg);
} else {
throw new MessageDecodingException("SAML 1.x message was not a request or a response");
}
}
示例4: getIntendedDestinationEndpointURI
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* <p>This SAML 1-specific implementation extracts the value of the ResponseAbstractType
* protocol message Recipient attribute.</p>
*
* */
protected String getIntendedDestinationEndpointURI(SAMLMessageContext samlMsgCtx) throws MessageDecodingException {
SAMLObject samlMessage = samlMsgCtx.getInboundSAMLMessage();
String messageDestination = null;
if (samlMessage instanceof ResponseAbstractType) {
ResponseAbstractType response = (ResponseAbstractType) samlMessage;
messageDestination = DatatypeHelper.safeTrimOrNullString(response.getRecipient());
} else if (samlMessage instanceof RequestAbstractType) {
// don't treat as an error, just return null
return null;
} else {
log.error("Invalid SAML message type encountered: {}", samlMessage.getElementQName().toString());
throw new MessageDecodingException("Invalid SAML message type encountered");
}
return messageDestination;
}
示例5: evaluate
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/** {@inheritDoc} */
public void evaluate(MessageContext messageContext) throws SecurityPolicyException {
if (!(messageContext instanceof SAMLMessageContext)) {
log.debug("Invalid message context type, this policy rule only supports SAMLMessageContext");
return;
}
SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;
SAMLObject samlMsg = samlMsgCtx.getInboundSAMLMessage();
if (!(samlMsg instanceof SignableSAMLObject)) {
log.debug("Extracted SAML message was not a SignableSAMLObject, can not process signature");
return;
}
SignableSAMLObject signableObject = (SignableSAMLObject) samlMsg;
if (!signableObject.isSigned()) {
log.info("SAML protocol message was not signed, skipping XML signature processing");
return;
}
Signature signature = signableObject.getSignature();
performPreValidation(signature);
doEvaluate(signature, signableObject, samlMsgCtx);
}
示例6: isMessageSigned
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Determine whether the inbound message is signed.
*
* @param messageContext the message context being evaluated
* @return true if the inbound message is signed, otherwise false
*/
protected boolean isMessageSigned(SAMLMessageContext messageContext) {
// TODO this really should be determined by the decoders and supplied to the rule
// in some fashion, to handle binding-specific signature mechanisms. See JIRA issue JOWS-4.
//
// For now evaluate here inline for XML Signature and HTTP-Redirect and HTTP-Post-SimpleSign.
SAMLObject samlMessage = messageContext.getInboundSAMLMessage();
if (samlMessage instanceof SignableSAMLObject) {
SignableSAMLObject signableMessage = (SignableSAMLObject) samlMessage;
if (signableMessage.isSigned()) {
return true;
}
}
// This handles HTTP-Redirect and HTTP-POST-SimpleSign bindings.
HTTPInTransport inTransport = (HTTPInTransport) messageContext.getInboundMessageTransport();
String sigParam = inTransport.getParameterValue("Signature");
return !DatatypeHelper.isEmpty(sigParam);
}
示例7: getAcsEndpoint
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Gets the source location used to for the artifacts created by this encoder.
*
* @param requestContext current request context
*
* @return source location used to for the artifacts created by this encoder
*/
protected Endpoint getAcsEndpoint(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) {
BasicEndpointSelector selector = new BasicEndpointSelector();
selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
selector.getSupportedIssuerBindings().add(SAMLConstants.SAML2_SOAP11_BINDING_URI);
selector.setMetadataProvider(requestContext.getMetadataProvider());
selector.setEntityMetadata(requestContext.getLocalEntityMetadata());
selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata());
Endpoint acsEndpoint = selector.selectEndpoint();
if (acsEndpoint == null) {
log.error("No artifact resolution service endpoint defined for the entity "
+ requestContext.getOutboundMessageIssuer());
return null;
}
return acsEndpoint;
}
示例8: deflateAndBase64Encode
import org.opensaml.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 = XMLHelper.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 Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
} catch (IOException e) {
throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
}
}
示例9: buildSOAPMessage
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
if (log.isDebugEnabled()) {
log.debug("Building SOAP message");
}
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
if (log.isDebugEnabled()) {
log.debug("Adding SAML message to the SOAP message's body");
}
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例10: prepareMessageContext
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Perform final binding-specific processing of message context and prepare it for encoding
* to the transport.
*
* <p>
* This should include constructing and populating all binding-specific structure and data that needs to be
* reflected by the message context's properties.
* </p>
*
* <p>
* This method is called prior to {@link #processOutboundHandlerChain(MessageContext)}.
* </p>
*
* @param messageContext the message context to process
* @throws MessageEncodingException thrown if there is a problem preparing the message context
* for encoding
*/
protected void prepareMessageContext(MessageContext messageContext) throws MessageEncodingException {
SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;
SAMLObject samlMessage = samlMsgCtx.getOutboundSAMLMessage();
if (samlMessage == null) {
throw new MessageEncodingException("No outbound SAML message contained in message context");
}
signMessage(samlMsgCtx);
log.debug("Building SOAP envelope");
Envelope envelope = envBuilder.buildObject();
Body body = bodyBuilder.buildObject();
envelope.setBody(body);
body.getUnknownXMLObjects().add(samlMessage);
messageContext.setOutboundMessage(envelope);
}
示例11: getIntendedDestinationEndpointURI
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* <p>This SAML 2-specific implementation extracts the value of the protocol message Destination attribute.</p>
*
* */
protected String getIntendedDestinationEndpointURI(SAMLMessageContext samlMsgCtx) throws MessageDecodingException {
SAMLObject samlMessage = samlMsgCtx.getInboundSAMLMessage();
String messageDestination = null;
if (samlMessage instanceof RequestAbstractType) {
RequestAbstractType request = (RequestAbstractType) samlMessage;
messageDestination = DatatypeHelper.safeTrimOrNullString(request.getDestination());
} else if (samlMessage instanceof StatusResponseType) {
StatusResponseType response = (StatusResponseType) samlMessage;
messageDestination = DatatypeHelper.safeTrimOrNullString(response.getDestination());
} else {
log.error("Invalid SAML message type encountered: {}", samlMessage.getElementQName().toString());
throw new MessageDecodingException("Invalid SAML message type encountered");
}
return messageDestination;
}
示例12: decryptData
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/**
* Decrypt the specified instance of EncryptedElementType, and return it as an instance
* of the specified QName.
*
*
* @param encElement the EncryptedElementType to decrypt
* @return the decrypted SAMLObject
* @throws DecryptionException thrown when decryption generates an error
*/
private SAMLObject decryptData(EncryptedElementType encElement) throws DecryptionException {
if (encElement.getEncryptedData() == null) {
throw new DecryptionException("Element had no EncryptedData child");
}
XMLObject xmlObject = null;
try {
xmlObject = decryptData(encElement.getEncryptedData(), isRootInNewDocument());
} catch (DecryptionException e) {
log.error("SAML Decrypter encountered an error decrypting element content", e);
throw e;
}
if (! (xmlObject instanceof SAMLObject)) {
throw new DecryptionException("Decrypted XMLObject was not an instance of SAMLObject");
}
return (SAMLObject) xmlObject;
}
示例13: processChildElement
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
throws UnmarshallingException {
ArtifactResponse artifactResponse = (ArtifactResponse) parentSAMLObject;
if (childSAMLObject instanceof Issuer) {
artifactResponse.setIssuer((Issuer) childSAMLObject);
} else if (childSAMLObject instanceof Signature) {
artifactResponse.setSignature((Signature) childSAMLObject);
} else if (childSAMLObject instanceof Extensions) {
artifactResponse.setExtensions((Extensions) childSAMLObject);
} else if (childSAMLObject instanceof Status) {
artifactResponse.setStatus((Status) childSAMLObject);
} else {
artifactResponse.setMessage((SAMLObject) childSAMLObject);
}
}
示例14: buildRedirectURL
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
public String buildRedirectURL(Credential signingCredential, String relayState) throws MessageEncodingException {
SAMLMessageContext<?, RequestAbstractType, ?> messageContext = new BasicSAMLMessageContext<SAMLObject, RequestAbstractType, SAMLObject>();
// Build the parameters for the request
messageContext.setOutboundSAMLMessage(request);
messageContext.setRelayState(relayState);
// Sign the parameters
messageContext.setOutboundSAMLMessageSigningCredential(signingCredential);
String messageStr = XMLHelper.nodeToString(marshallMessage(request));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
try {
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
} catch (IOException e) {
throw new RuntimeException("Unable to deflate message", e);
}
String encoded = Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
return super.buildRedirectURL(messageContext, request.getDestination(), encoded);
}
示例15: deflateAndBase64Encode
import org.opensaml.common.SAMLObject; //导入依赖的package包/类
@Override
public String deflateAndBase64Encode(SAMLObject obj) throws MessageEncodingException {
String messageStr = XMLHelper.nodeToString(marshallMessage(obj));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
try {
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
} catch (IOException e) {
throw new RuntimeException("Unable to deflate message", e);
}
return Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
}