本文整理汇总了Java中org.opensaml.util.URLBuilder类的典型用法代码示例。如果您正苦于以下问题:Java URLBuilder类的具体用法?Java URLBuilder怎么用?Java URLBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URLBuilder类属于org.opensaml.util包,在下文中一共展示了URLBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getEncode
import org.opensaml.util.URLBuilder; //导入依赖的package包/类
/**
* Performs HTTP GET based encoding.
*
* @param artifactContext current request context
* @param outTransport outbound HTTP transport
*
* @throws MessageEncodingException thrown if there is a problem GET encoding the artifact
*/
protected void getEncode(SAMLMessageContext artifactContext, HTTPOutTransport outTransport)
throws MessageEncodingException {
log.debug("Performing HTTP GET SAML 2 artifact encoding");
URLBuilder urlBuilder = getEndpointURL(artifactContext);
List<Pair<String, String>> params = urlBuilder.getQueryParams();
AbstractSAMLArtifact artifact = buildArtifact(artifactContext);
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");
}
params.add(new Pair<String, String>("SAMLart", artifact.base64Encode()));
if (checkRelayState(artifactContext.getRelayState())) {
params.add(new Pair<String, String>("RelayState", artifactContext.getRelayState()));
}
outTransport.sendRedirect(urlBuilder.buildURL());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:HTTPArtifactEncoder.java
示例2: getEncode
import org.opensaml.util.URLBuilder; //导入依赖的package包/类
/**
* Performs HTTP GET based encoding.
*
* @param artifactContext current request context
* @param outTransport outbound HTTP transport
*
* @throws MessageEncodingException thrown if there is a problem GET encoding the artifact
*/
protected void getEncode(SAMLMessageContext artifactContext, HTTPOutTransport outTransport)
throws MessageEncodingException {
log.debug("Performing HTTP GET SAML 2 artifact encoding");
URLBuilder urlBuilder = new URLBuilder(getEndpointURL(artifactContext));
List<Pair<String, String>> params = urlBuilder.getQueryParams();
params.add(new Pair<String, String>("SAMLart", buildArtifact(artifactContext).base64Encode()));
if (checkRelayState(artifactContext.getRelayState())) {
params.add(new Pair<String, String>("RelayState", artifactContext.getRelayState()));
}
outTransport.sendRedirect(urlBuilder.buildURL());
}
开发者ID:apigee,项目名称:java-opensaml2,代码行数:25,代码来源:HTTPArtifactEncoder.java
示例3: getContextRelativeUrl
import org.opensaml.util.URLBuilder; //导入依赖的package包/类
public static URLBuilder getContextRelativeUrl(final HTTPInTransportWithCookie inTr, String path) {
final URL curUrl = (URL)inTr.getAttribute("URL");
final String contextPath = (String)inTr.getAttribute("CONTEXT_PATH");
if (curUrl == null) {
log.error("URL attribute not specified in the inbound transport attributes");
throw new IllegalArgumentException("URL attribute not specified in the inbound transport attributes");
}
final URLBuilder urlBuilder = new URLBuilder();
urlBuilder.setScheme(curUrl.getProtocol());
urlBuilder.setHost(curUrl.getHost());
final StringBuilder pathBuilder = new StringBuilder();
if (contextPath != null && !contextPath.isEmpty()) {
pathBuilder.append(contextPath);
}
if (!path.startsWith("/")) {
pathBuilder.append("/");
}
pathBuilder.append(DatatypeHelper.safeTrim(path));
urlBuilder.setPath(pathBuilder.toString());
return urlBuilder;
}
开发者ID:brainysmith,项目名称:idp-play-bridge,代码行数:25,代码来源:HttpHelper.java
示例4: 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();
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:HTTPRedirectDeflateEncoder.java
示例5: 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();
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:32,代码来源:OIOLogoutResponse.java
示例6: 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();
}
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:12,代码来源:SAMLRequestSender.java
示例7: 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());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:59,代码来源:HTTPArtifactEncoder.java
示例8: 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());
}
开发者ID:apigee,项目名称:java-opensaml2,代码行数:55,代码来源:HTTPArtifactEncoder.java
示例9: buildInTransport
import org.opensaml.util.URLBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
protected InTransport buildInTransport() {
//
// Encode the "outbound" message context, with simple signature
//
MockHttpServletResponse response = new MockHttpServletResponse();
HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
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");
BasicSAMLMessageContext outboundMessgeContext = new BasicSAMLMessageContext();
outboundMessgeContext.setOutboundMessageTransport(outTransport);
outboundMessgeContext.setOutboundSAMLMessage(buildInboundSAMLMessage());
outboundMessgeContext.setRelayState(expectedRelayValue);
outboundMessgeContext.setPeerEntityEndpoint(samlEndpoint);
outboundMessgeContext.setOutboundSAMLMessageSigningCredential(signingX509Cred);
HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
try {
encoder.encode(outboundMessgeContext);
} catch (MessageEncodingException e) {
fail("Could not encode outbound message context");
}
// Now populate the new "inbound" message context with the "outbound" encoded info
MockHttpServletRequest request = new MockHttpServletRequest();
HTTPInTransport inTransport = new HttpServletRequestAdapter(request);
request.setMethod("GET");
// The Spring mock object doesn't convert between the query params and the getParameter apparently,
// so have to set them both ways.
URLBuilder urlBuilder = new URLBuilder(response.getRedirectedUrl());
request.setQueryString(urlBuilder.buildQueryString());
for (Pair<String, String> param : urlBuilder.getQueryParams()) {
request.setParameter(param.getFirst(), param.getSecond());
}
return inTransport;
}
开发者ID:apigee,项目名称:java-opensaml2,代码行数:45,代码来源:SAML2HTTPRedirectDeflateSignatureSecurityPolicyRuleTest.java
注:本文中的org.opensaml.util.URLBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论