本文整理汇总了Java中org.opensaml.saml1.core.Request类的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Request类属于org.opensaml.saml1.core包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractRequestInfo
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/**
* Extract information from a SAML RequestAbstractType message.
*
* @param messageContext current message context
* @param abstractRequest the SAML message to process
*/
protected void extractRequestInfo(SAMLMessageContext messageContext, RequestAbstractType abstractRequest) {
messageContext.setInboundSAMLMessageId(abstractRequest.getID());
messageContext.setInboundSAMLMessageIssueInstant(abstractRequest.getIssueInstant());
if (abstractRequest instanceof Request) {
Request request = (Request) abstractRequest;
if (request.getAttributeQuery() != null) {
extractAttributeQueryInfo(messageContext, request.getAttributeQuery());
}
if (request.getAuthorizationDecisionQuery() != null) {
extractAuthorizationDecisionQueryInfo(messageContext, request.getAuthorizationDecisionQuery());
}
if (request.getAssertionArtifacts() != null) {
extractAssertionArtifactInfo(messageContext, request.getAssertionArtifacts());
}
}
}
示例2: validateAssertion
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/**
* Validates thats the request has an some form of assertion (directly, reference, or artifact) or query, but not
* both.
*
* @param request the request to validate
*
* @throws ValidationException thrown if the request has more than one assertion or both an assertion and a query
*/
protected void validateAssertion(Request request) throws ValidationException {
if (request.getQuery() != null) {
if (request.getAssertionArtifacts().size() != 0) {
throw new ValidationException("Both Query and one or more AssertionAtrifacts present");
}
if (request.getAssertionIDReferences().size() != 0) {
throw new ValidationException("Both Query and one ore more AsertionIDReferences present");
}
} else if (request.getAssertionArtifacts().size() != 0) {
if (request.getAssertionIDReferences().size() != 0) {
throw new ValidationException(
"Both one or more AssertionAtrifacts and one ore more AsertionIDReferences present");
}
} else if (request.getAssertionIDReferences().size() == 0) {
throw new ValidationException("No AssertionAtrifacts, No Query, and No AsertionIDReferences present");
}
}
示例3: processChildElement
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentElement, XMLObject childElement) throws UnmarshallingException {
Request request = (Request) parentElement;
try {
if (childElement instanceof Query) {
request.setQuery((Query) childElement);
} else if (childElement instanceof AssertionIDReference) {
request.getAssertionIDReferences().add((AssertionIDReference) childElement);
} else if (childElement instanceof AssertionArtifact) {
request.getAssertionArtifacts().add((AssertionArtifact) childElement);
} else {
super.processChildElement(parentElement, childElement);
}
} catch (IllegalArgumentException e) {
throw new UnmarshallingException(e);
}
}
示例4: testEncoding
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** Tests encoding a simple SAML message. */
@SuppressWarnings("unchecked")
public void testEncoding() throws Exception {
SAMLObjectBuilder<Request> requestBuilder = (SAMLObjectBuilder<Request>) builderFactory
.getBuilder(Request.DEFAULT_ELEMENT_NAME);
Request request = requestBuilder.buildObject();
request.setID("foo");
request.setIssueInstant(new DateTime(0));
request.setVersion(SAMLVersion.VERSION_11);
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();
BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));
messageContext.setPeerEntityEndpoint(samlEndpoint);
messageContext.setOutboundSAMLMessage(request);
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(-280457420, response.getContentAsString().hashCode());
}
示例5: testDecoding
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/**
* Tests decoding a SOAP 1.1 message.
*/
public void testDecoding() throws Exception {
String requestContent = "<soap11:Envelope xmlns:soap11=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap11:Body><saml:Request IssueInstant=\"1970-01-01T00:00:00.000Z\" MajorVersion=\"1\" "
+ "MinorVersion=\"1\" RequestID=\"foo\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:protocol\"/>"
+ "</soap11:Body></soap11:Envelope>";
httpRequest.setContent(requestContent.getBytes());
decoder.decode(messageContext);
assertTrue(messageContext.getInboundMessage() instanceof Envelope);
assertTrue(messageContext.getInboundSAMLMessage() instanceof Request);
}
示例6: populateRequiredData
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
super.populateRequiredData();
Request request = (Request) target;
QName qname = new QName(SAMLConstants.SAML10P_NS, AttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
request.setQuery((Query)buildXMLObject(qname));
}
示例7: testQueryAndAssertionIDReference
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public void testQueryAndAssertionIDReference() {
Request request = (Request) target;
QName qname = new QName(SAMLConstants.SAML1_NS, AssertionIDReference.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
request.getAssertionIDReferences().add((AssertionIDReference)buildXMLObject(qname));
assertValidationFail("Both Query & AssertionIDRefeference element present, should raise a Validation Exception");
}
示例8: testQueryAndAssertionArtifact
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public void testQueryAndAssertionArtifact() {
Request request = (Request) target;
QName qname = new QName(SAMLConstants.SAML10P_NS, AssertionArtifact.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
request.getAssertionArtifacts().add((AssertionArtifact)buildXMLObject(qname));
assertValidationFail("Both Query & AssertionArtifact element present, should raise a Validation Exception");
}
示例9: testAssertionIDRefAndAssertionArtifact
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public void testAssertionIDRefAndAssertionArtifact() {
Request request = (Request) target;
QName qname = new QName(SAMLConstants.SAML10P_NS, AssertionArtifact.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1P_PREFIX);
request.getAssertionArtifacts().add((AssertionArtifact)buildXMLObject(qname));
qname = new QName(SAMLConstants.SAML1_NS, AssertionIDReference.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
request.getAssertionIDReferences().add((AssertionIDReference)buildXMLObject(qname));
request.setQuery(null);
assertValidationFail("Both & AssertionIDRefeference AssertionArtifact element present, should raise a Validation Exception");
}
示例10: RequestTest
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public RequestTest() {
expectedID = "ident";
singleElementFile = "/data/org/opensaml/saml1/impl/singleRequest.xml";
singleElementOptionalAttributesFile = "/data/org/opensaml/saml1/impl/singleRequestAttributes.xml";
expectedIssueInstant = new DateTime(1970, 1, 1, 0, 0, 0, 100, ISOChronology.getInstanceUTC());
expectedMinorVersion = 1;
qname = Request.DEFAULT_ELEMENT_NAME;
}
示例11: testSingleElementUnmarshall
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
Request request = (Request) unmarshallElement(singleElementFile);
String id = request.getID();
assertNull("ID attribute has value " + id + "expected no value", id);
DateTime date = request.getIssueInstant();
assertNull("IssueInstant attribute has a value of " + date + ", expected no value", date);
assertNull("Query has value", request.getQuery());
assertEquals("AssertionArtifact present", 0, request.getAssertionArtifacts().size());
assertEquals("AssertionIDReferences present", 0, request.getAssertionIDReferences().size());
assertNull("IssueInstance has value", request.getIssueInstant());
}
示例12: testSingleElementOptionalAttributesUnmarshall
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesUnmarshall() {
Request request = (Request) unmarshallElement(singleElementOptionalAttributesFile);
assertEquals("ID", expectedID, request.getID());
assertEquals("MinorVersion", expectedMinorVersion, request.getMinorVersion());
assertEquals("IssueInstant", expectedIssueInstant, request.getIssueInstant());
}
示例13: testSingleElementOptionalAttributesMarshall
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
Request request = (Request) buildXMLObject(qname);
request.setID(expectedID);
request.setIssueInstant(expectedIssueInstant);
assertEquals(expectedOptionalAttributesDOM, request);
}
示例14: testSignatureUnmarshall
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public void testSignatureUnmarshall() {
Request request = (Request) unmarshallElement("/data/org/opensaml/saml1/impl/RequestWithSignature.xml");
assertNotNull("Request was null", request);
assertNotNull("Signature was null", request.getSignature());
assertNotNull("KeyInfo was null", request.getSignature().getKeyInfo());
}
示例15: testDOMIDResolutionUnmarshall
import org.opensaml.saml1.core.Request; //导入依赖的package包/类
public void testDOMIDResolutionUnmarshall() {
Request request = (Request) unmarshallElement("/data/org/opensaml/saml1/impl/RequestWithSignature.xml");
assertNotNull("Request was null", request);
assertNotNull("Signature was null", request.getSignature());
Document document = request.getSignature().getDOM().getOwnerDocument();
Element idElem = request.getDOM();
assertNotNull("DOM ID resolution returned null", document.getElementById(expectedID));
assertTrue("DOM elements were not equal", idElem.isSameNode(document.getElementById(expectedID)));
}