本文整理汇总了Java中org.opensaml.saml2.core.ArtifactResponse类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResponse类的具体用法?Java ArtifactResponse怎么用?Java ArtifactResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactResponse类属于org.opensaml.saml2.core包,在下文中一共展示了ArtifactResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChildElement
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的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);
}
}
示例2: testPost
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Test
public void testPost() throws Exception {
String id = Utils.generateUUID();
handler.registerRequest(id, idpEntityId);
ArtifactResponse r = (ArtifactResponse) buildResponse(Utils.generateUUID(), true, false, id).getBody().getUnknownXMLObjects().get(0);
final String response = Base64.encodeBytes(XMLHelper.nodeToString(SAMLUtil.marshallObject(r.getMessage())).getBytes());
context.checking(new Expectations() {{
allowing(req).getCookies(); will(returnValue(null));
allowing(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(response));
one(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(handler.saveRequest(new Request("requesturi", "query", "GET", new HashMap<String, String[]>()))));
one(session).setAttribute(with(equal(Constants.SESSION_USER_ASSERTION)), with(any(UserAssertion.class)));
one(res).sendRedirect("requesturi?query");
one(session).getMaxInactiveInterval(); will(returnValue(30));
}});
expectCacheHeaders();
sh.handlePost(ctx);
}
示例3: testRedirectWithUrlFragmentIfSavedInCookie
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Test
public void testRedirectWithUrlFragmentIfSavedInCookie() throws Exception {
String id = Utils.generateUUID();
handler.registerRequest(id, idpEntityId);
ArtifactResponse r = (ArtifactResponse) buildResponse(Utils.generateUUID(), true, false, id).getBody().getUnknownXMLObjects().get(0);
final String response = Base64.encodeBytes(XMLHelper.nodeToString(SAMLUtil.marshallObject(r.getMessage())).getBytes());
final Cookie fragment = new Cookie("oiosaml-fragment", URLEncoder.encode("#test=more", "utf-8"));
context.checking(new Expectations() {{
allowing(req).getCookies(); will(returnValue(new Cookie[] { fragment }));
one(res).addCookie(with(any(Cookie.class)));
allowing(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(response));
one(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(handler.saveRequest(new Request("requesturi", "query", "GET", new HashMap<String, String[]>()))));
one(session).setAttribute(with(equal(Constants.SESSION_USER_ASSERTION)), with(any(UserAssertion.class)));
one(res).sendRedirect("requesturi?query#test=more");
one(session).getMaxInactiveInterval(); will(returnValue(30));
}});
expectCacheHeaders();
sh.handlePost(ctx);
}
示例4: authenticationHookMustBeInvokedIfConfigured
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Test
public void authenticationHookMustBeInvokedIfConfigured() throws Exception {
AuthenticationHandlerStub.invoked = false;
conf.put(Constants.PROP_AUTHENTICATION_HANDLER, AuthenticationHandlerStub.class.getName());
String id = Utils.generateUUID();
handler.registerRequest(id, idpEntityId);
ArtifactResponse r = (ArtifactResponse) buildResponse(Utils.generateUUID(), true, false, id).getBody().getUnknownXMLObjects().get(0);
final String response = Base64.encodeBytes(XMLHelper.nodeToString(SAMLUtil.marshallObject(r.getMessage())).getBytes());
context.checking(new Expectations() {{
allowing(req).getCookies(); will(returnValue(null));
allowing(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(response));
one(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(handler.saveRequest(new Request("requesturi", "query", "GET", new HashMap<String, String[]>()))));
one(session).setAttribute(with(equal(Constants.SESSION_USER_ASSERTION)), with(any(UserAssertion.class)));
one(res).sendRedirect("requesturi?query");
one(session).getMaxInactiveInterval(); will(returnValue(30));
}});
expectCacheHeaders();
AuthenticationHandlerStub.succeed = true;
sh.handlePost(ctx);
assertTrue(AuthenticationHandlerStub.invoked);
}
示例5: authenticationHookFailureMustAbort
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Test
public void authenticationHookFailureMustAbort() throws Exception {
AuthenticationHandlerStub.invoked = false;
conf.put(Constants.PROP_AUTHENTICATION_HANDLER, AuthenticationHandlerStub.class.getName());
String id = Utils.generateUUID();
handler.registerRequest(id, idpEntityId);
ArtifactResponse r = (ArtifactResponse) buildResponse(Utils.generateUUID(), true, false, id).getBody().getUnknownXMLObjects().get(0);
final String response = Base64.encodeBytes(XMLHelper.nodeToString(SAMLUtil.marshallObject(r.getMessage())).getBytes());
context.checking(new Expectations() {{
allowing(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(response));
one(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(handler.saveRequest(new Request("requesturi", "query", "GET", new HashMap<String, String[]>()))));
}});
AuthenticationHandlerStub.succeed = false;
sh.handlePost(ctx);
assertTrue(AuthenticationHandlerStub.invoked);
}
示例6: processArtifactBinding
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/**
* Handles artifact binding request.
* @param request
* @param uriInfo
* @return
*/
@GET
@Path("sso/artifact")
public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) {
String artifact = request.getParameter("SAMLart");
String realmId = request.getParameter("RelayState");
if (artifact == null) {
throw new APIAccessDeniedException("No artifact provided by the IdP");
}
String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact);
ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl);
Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve);
XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry);
ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0);
org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage();
return processSAMLResponse(samlResponse, uriInfo);
}
示例7: setUp
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
srt = (Response) ((ArtifactResponse)SAMLUtil.unmarshallElement(getClass().getResourceAsStream("response.xml"))).getMessage();
srt.setDestination(destination);
srt.getIssuer().setValue(issuerValue);
response = new OIOResponse(srt);
credential = TestHelper.getCredential();
cert = TestHelper.getCertificate(credential);
response.sign(credential);
}
示例8: testArtifactResolve
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
@Test
public void testArtifactResolve() throws Exception {
ArtifactResolve ar = SAMLUtil.buildXMLObject(ArtifactResolve.class);
Envelope env = client.wsCall(ar, "http://localhost:12349", "test", "test", true);
assertTrue(env.getBody().getUnknownXMLObjects().get(0) instanceof ArtifactResponse);
assertEquals("\"http://www.oasis-open.org/committees/security\"", ds.headers.get("SOAPAction"));
assertEquals("test:test", new String(Base64.decode(ds.headers.get("Authorization").split(" ")[1]), "UTF-8"));
}
示例9: run
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
public void run() {
try {
Socket client = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
headers = new HashMap<String, String>();
while ((line = in.readLine()) != null) {
if ("".equals(line.trim())) {
for (int i = 0; i < Integer.parseInt(headers.get("Content-Length")); i++) {
sb.append((char)in.read());
}
break;
}
String[] h = line.split(": ");
if (h.length == 2) {
headers.put(h[0], h[1]);
}
}
PrintWriter pw = new PrintWriter(client.getOutputStream());
pw.println("HTTP/1.1 200 OK");
pw.println("Server: test");
pw.println();
Envelope env = SAMLUtil.buildXMLObject(Envelope.class);
Body body = SAMLUtil.buildXMLObject(Body.class);
env.setBody(body);
body.getUnknownXMLObjects().add(SAMLUtil.buildXMLObject(ArtifactResponse.class));
pw.println(XMLHelper.nodeToString(SAMLUtil.marshallObject(env)));
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例10: testSingleElementMarshall
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
QName qname = new QName(SAMLConstants.SAML20P_NS, ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
ArtifactResponse ar = (ArtifactResponse) buildXMLObject(qname);
super.populateRequiredAttributes(ar);
assertEquals(expectedDOM, ar);
}
示例11: testSingleElementOptionalAttributesMarshall
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
QName qname = new QName(SAMLConstants.SAML20P_NS, ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
ArtifactResponse ar = (ArtifactResponse) buildXMLObject(qname);
super.populateRequiredAttributes(ar);
super.populateOptionalAttributes(ar);
assertEquals(expectedOptionalAttributesDOM, ar);
}
示例12: testChildElementsMarshall
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
QName qname = new QName(SAMLConstants.SAML20P_NS, ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
ArtifactResponse ar = (ArtifactResponse) buildXMLObject(qname);
super.populateChildElements(ar);
assertEquals(expectedChildElementsDOM, ar);
}
示例13: validate
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void validate(ArtifactResponse response) throws ValidationException {
super.validate(response);
}
示例14: buildObject
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public ArtifactResponse buildObject() {
return buildObject(SAMLConstants.SAML20P_NS, ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME,
SAMLConstants.SAML20P_PREFIX);
}
示例15: ArtifactResponseMarshaller
import org.opensaml.saml2.core.ArtifactResponse; //导入依赖的package包/类
/** Constructor. */
public ArtifactResponseMarshaller() {
super(SAMLConstants.SAML20P_NS, ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME);
}