本文整理汇总了Java中org.opensaml.util.URLBuilder.buildURL方法的典型用法代码示例。如果您正苦于以下问题:Java URLBuilder.buildURL方法的具体用法?Java URLBuilder.buildURL怎么用?Java URLBuilder.buildURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.util.URLBuilder
的用法示例。
在下文中一共展示了URLBuilder.buildURL方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRedirectURL
import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
* Builds the URL to redirect the client to.
*
* @param messagesContext current message context
* @param endpointURL endpoint URL to send encoded message to
* @param message Deflated and Base64 encoded message
*
* @return URL to redirect client to
*
* @throws MessageEncodingException thrown if the SAML message is neither a RequestAbstractType or Response
*/
protected String buildRedirectURL(SAMLMessageContext messagesContext, String endpointURL, String message)
throws MessageEncodingException {
log.debug("Building URL to redirect client to");
URLBuilder urlBuilder = new URLBuilder(endpointURL);
List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
queryParams.clear();
if (messagesContext.getOutboundSAMLMessage() instanceof RequestAbstractType) {
queryParams.add(new Pair<String, String>("SAMLRequest", message));
} else if (messagesContext.getOutboundSAMLMessage() instanceof StatusResponseType) {
queryParams.add(new Pair<String, String>("SAMLResponse", message));
} else {
throw new MessageEncodingException(
"SAML message is neither a SAML RequestAbstractType or StatusResponseType");
}
String relayState = messagesContext.getRelayState();
if (checkRelayState(relayState)) {
queryParams.add(new Pair<String, String>("RelayState", relayState));
}
Credential signingCredential = messagesContext.getOuboundSAMLMessageSigningCredential();
if (signingCredential != null) {
// TODO pull SecurityConfiguration from SAMLMessageContext? needs to be added
String sigAlgURI = getSignatureAlgorithmURI(signingCredential, null);
Pair<String, String> sigAlg = new Pair<String, String>("SigAlg", sigAlgURI);
queryParams.add(sigAlg);
String sigMaterial = urlBuilder.buildQueryString();
queryParams.add(new Pair<String, String>("Signature", generateSignature(signingCredential, sigAlgURI,
sigMaterial)));
}
return urlBuilder.buildURL();
}
示例2: buildRedirectURL
import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
* @see org.opensaml.saml2.binding.encoding.HTTPRedirectDeflateEncoder#buildRedirectURL(org.opensaml.common.binding.SAMLMessageContext,
* java.lang.String, java.lang.String)
*/
private String buildRedirectURL(String message, String relayState, Credential signingCredential) throws MessageEncodingException {
if (log.isDebugEnabled())
log.debug("Building URL to redirect client to: " + response.getDestination());
URLBuilder urlBuilder = new URLBuilder(response.getDestination());
List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
queryParams.clear();
queryParams.add(new Pair<String, String>(Constants.SAML_SAMLRESPONSE, message));
// Quick patch made because Microsoft ADFS cannot handle an empty relaystate param
// Beware that ADFS sends an errormessage, but is not logging the user out, so the errormessage SHOULD tell the end users to close their browsers
if(relayState != null) {
queryParams.add(new Pair<String, String>(Constants.SAML_RELAYSTATE, relayState));
}
Encoder enc = new Encoder();
if (signingCredential != null) {
queryParams.add(new Pair<String, String>(Constants.SAML_SIGALG, enc.getSignatureAlgorithmURI(signingCredential, null)));
String sigMaterial = urlBuilder.buildQueryString();
queryParams.add(new Pair<String, String>(Constants.SAML_SIGNATURE,
enc.generateSignature(signingCredential, enc.getSignatureAlgorithmURI(signingCredential, null), sigMaterial)));
}
return urlBuilder.buildURL();
}
示例3: buildRedirectURL
import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
public String buildRedirectURL(String endpointURL, String relayState, String message) {
URLBuilder urlBuilder = new URLBuilder(endpointURL);
List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
queryParams.clear();
queryParams.add(new Pair<String, String>("mgvhostparam", "0"));
queryParams.add(new Pair<String, String>("SAMLRequest", message));
if (checkRelayState(relayState)) {
queryParams.add(new Pair<String, String>("RelayState", relayState));
}
return urlBuilder.buildURL();
}
示例4: doEncode
import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void doEncode(MessageContext messageContext) throws MessageEncodingException {
if (!(messageContext instanceof SAMLMessageContext)) {
log.error("Invalid message context type, this encoder only support SAMLMessageContext");
throw new MessageEncodingException(
"Invalid message context type, this encoder only support SAMLMessageContext");
}
if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) {
log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport");
throw new MessageEncodingException(
"Invalid outbound message transport type, this encoder only support HTTPOutTransport");
}
SAMLMessageContext<SAMLObject, Response, NameIdentifier> artifactContext = (SAMLMessageContext) messageContext;
HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport();
URLBuilder urlBuilder = getEndpointURL(artifactContext);
List<Pair<String, String>> params = urlBuilder.getQueryParams();
params.add(new Pair<String, String>("TARGET", artifactContext.getRelayState()));
SAML1ArtifactBuilder artifactBuilder;
if (artifactContext.getOutboundMessageArtifactType() != null) {
artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(
artifactContext.getOutboundMessageArtifactType());
} else {
artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(defaultArtifactType);
artifactContext.setOutboundMessageArtifactType(defaultArtifactType);
}
AbstractSAML1Artifact artifact;
String artifactString;
for (Assertion assertion : artifactContext.getOutboundSAMLMessage().getAssertions()) {
artifact = artifactBuilder.buildArtifact(artifactContext, assertion);
if(artifact == null){
log.error("Unable to build artifact for message to relying party");
throw new MessageEncodingException("Unable to builder artifact for message to relying party");
}
try {
artifactMap.put(artifact.base64Encode(), messageContext.getInboundMessageIssuer(), messageContext
.getOutboundMessageIssuer(), assertion);
} catch (MarshallingException e) {
log.error("Unable to marshall assertion to be represented as an artifact", e);
throw new MessageEncodingException("Unable to marshall assertion to be represented as an artifact", e);
}
artifactString = artifact.base64Encode();
params.add(new Pair<String, String>("SAMLart", artifactString));
}
String redirectUrl = urlBuilder.buildURL();
log.debug("Sending redirect to URL {} to relying party {}", redirectUrl, artifactContext
.getInboundMessageIssuer());
outTransport.sendRedirect(urlBuilder.buildURL());
}
示例5: doEncode
import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void doEncode(MessageContext messageContext) throws MessageEncodingException {
if (!(messageContext instanceof SAMLMessageContext)) {
log.error("Invalid message context type, this encoder only support SAMLMessageContext");
throw new MessageEncodingException(
"Invalid message context type, this encoder only support SAMLMessageContext");
}
if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) {
log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport");
throw new MessageEncodingException(
"Invalid outbound message transport type, this encoder only support HTTPOutTransport");
}
SAMLMessageContext<SAMLObject, Response, NameIdentifier> artifactContext = (SAMLMessageContext) messageContext;
HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport();
URLBuilder urlBuilder = new URLBuilder(getEndpointURL(artifactContext));
List<Pair<String, String>> params = urlBuilder.getQueryParams();
params.add(new Pair<String, String>("TARGET", HTTPTransportUtils.urlEncode(artifactContext.getRelayState())));
SAML1ArtifactBuilder artifactBuilder;
if (artifactContext.getOutboundMessageArtifactType() != null) {
artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(
artifactContext.getOutboundMessageArtifactType());
} else {
artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(defaultArtifactType);
artifactContext.setOutboundMessageArtifactType(defaultArtifactType);
}
AbstractSAML1Artifact artifact;
String artifactString;
for (Assertion assertion : artifactContext.getOutboundSAMLMessage().getAssertions()) {
artifact = artifactBuilder.buildArtifact(artifactContext, assertion);
try {
artifactMap.put(artifact.base64Encode(), messageContext.getInboundMessageIssuer(), messageContext
.getOutboundMessageIssuer(), assertion);
} catch (MarshallingException e) {
log.error("Unable to marshall assertion to be represented as an artifact", e);
throw new MessageEncodingException("Unable to marshall assertion to be represented as an artifact", e);
}
artifactString = artifact.base64Encode();
params.add(new Pair<String, String>("SAMLart", artifactString));
}
String redirectUrl = urlBuilder.buildURL();
log.debug("Sending redirect to URL {} to relying party {}", redirectUrl, artifactContext
.getInboundMessageIssuer());
outTransport.sendRedirect(urlBuilder.buildURL());
}