本文整理汇总了Java中org.opensaml.saml2.core.StatusCode类的典型用法代码示例。如果您正苦于以下问题:Java StatusCode类的具体用法?Java StatusCode怎么用?Java StatusCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatusCode类属于org.opensaml.saml2.core包,在下文中一共展示了StatusCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSingleLogout_IT_SLO_1
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
login();
Page logoutPage = client.getPage(BASE + "/saml/Logout");
assertEquals(302, logoutPage.getWebResponse().getStatusCode());
String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
assertTrue(logoutRedirect + " did not start with: " + idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation(), logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));
handler.url = null;
client.getPage(BASE + "/sp/priv1.jsp");
assertNotNull(handler.url);
assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
assertEquals("joetest", lr.getNameID().getValue());
OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
Page responsePage = client.getPage(redirectURL);
assertEquals(302, responsePage.getWebResponse().getStatusCode());
assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
示例2: testSingleLogout_IT_SLO_1
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
login();
Page logoutPage = client.getPage(BASE + "/saml/Logout");
assertEquals(302, logoutPage.getWebResponse().getStatusCode());
String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
assertTrue(logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));
handler.url = null;
client.getPage(BASE + "/sp/priv1.jsp");
assertNotNull(handler.url);
assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
assertEquals("joetest", lr.getNameID().getValue());
OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
Page responsePage = client.getPage(redirectURL);
assertEquals(302, responsePage.getWebResponse().getStatusCode());
assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
示例3: buildStatus
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
private Status buildStatus(String status, String statMsg) {
Status stat = new StatusBuilder().buildObject();
// Set the status code.
StatusCode statCode = new StatusCodeBuilder().buildObject();
statCode.setValue(status);
stat.setStatusCode(statCode);
// Set the status Message.
if (statMsg != null) {
StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
statMesssage.setMessage(statMsg);
stat.setStatusMessage(statMesssage);
}
return stat;
}
示例4: testAssuranceLevelTooLow_IT_LOA_1
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void testAssuranceLevelTooLow_IT_LOA_1() throws Exception {
client.getPage(BASE + "/sp/priv1.jsp");
WebRequestSettings req = buildResponse(StatusCode.SUCCESS_URI, 1);
Page responsePage = client.getPage(req);
assertEquals(302, responsePage.getWebResponse().getStatusCode());
assertEquals(BASE + "/sp/priv1.jsp", responsePage.getWebResponse().getResponseHeaderValue("Location"));
HtmlPage loggedInPage = (HtmlPage) client.getPage(responsePage.getWebResponse().getResponseHeaderValue("Location"));
WebAssert.assertTextPresent(loggedInPage, "Assurance level too low");
handler.url = null;
client.getPage(BASE + "/sp/priv1.jsp");
assertNotNull("User should be logged out", handler.url);
}
示例5: validateResponse
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
protected void validateResponse(String requestId, String expectedDestination, boolean allowPassive) {
String statusCode = response.getStatus().getStatusCode().getValue();
if (!StatusCode.SUCCESS_URI.equals(statusCode)) {
StatusCode is = response.getStatus().getStatusCode().getStatusCode();
if (is == null || !(StatusCode.NO_PASSIVE_URI.equals(is.getValue()) && allowPassive)) {
String msg = response.getStatus().getStatusMessage() == null ? "" : response.getStatus().getStatusMessage().getMessage();
throw new ValidationException("Got StatusCode " + statusCode + " should be " + StatusCode.SUCCESS_URI + ". Message: " + msg);
}
}
if (!isDestinationOK(expectedDestination)) {
throw new ValidationException("Wrong destination. Expected " + expectedDestination + ", was " + response.getDestination());
}
if (requestId != null && !requestId.equals(response.getInResponseTo())) {
throw new ValidationException("Wrong InResponseTo. Expected " + requestId + ", was " + response.getInResponseTo());
}
}
示例6: testRedirect
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void testRedirect() throws Exception {
setHandler();
assertTrue(handler.isLoggedIn(session.getId()));
OIOLogoutRequest lr = OIOLogoutRequest.buildLogoutRequest(session, spMetadata.getSingleLogoutServiceHTTPRedirectLocation(), idpEntityId, handler);
final String requestURL = lr.getRedirectRequestURL(credential);
context.checking(new Expectations() {{
allowing(req).getParameter("SAMLRequest"); will(returnValue(URLDecoder.decode(Utils.getParameter("SAMLRequest", requestURL), "UTF-8")));
allowing(req).getParameter("RelayState"); will(returnValue(null));
allowing(req).getParameter("SigAlg"); will(returnValue(URLDecoder.decode(Utils.getParameter("SigAlg", requestURL), "UTF-8")));
allowing(req).getParameter("Signature"); will(returnValue(URLDecoder.decode(Utils.getParameter("Signature", requestURL), "UTF-8")));
allowing(req).getMethod(); will(returnValue("GET"));
allowing(req).getRequestURL(); will(returnValue(new StringBuffer(spMetadata.getSingleLogoutServiceHTTPRedirectLocation())));
allowing(req).getQueryString(); will(returnValue(requestURL.substring(requestURL.indexOf('?') + 1)));
one(res).sendRedirect(with(urlExtractor));
one(session).removeAttribute(Constants.SESSION_USER_ASSERTION);
}});
logoutServiceHttpRedirectHandler.handleGet(ctx);
assertFalse(handler.isLoggedIn(session.getId()));
LogoutResponse lresp = parseResponse();
assertEquals(StatusCode.SUCCESS_URI, lresp.getStatus().getStatusCode().getValue());
}
示例7: failWhenInvalidSignature
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void failWhenInvalidSignature() throws Exception {
OIOLogoutRequest lr = OIOLogoutRequest.buildLogoutRequest(session, spMetadata.getSingleLogoutServiceHTTPRedirectLocation(), idpEntityId, handler);
final String requestURL = lr.getRedirectRequestURL(credential);
context.checking(new Expectations() {{
allowing(req).getParameter("SAMLRequest"); will(returnValue(URLDecoder.decode(Utils.getParameter("SAMLRequest", requestURL), "UTF-8")));
allowing(req).getParameter("RelayState"); will(returnValue(null));
allowing(req).getParameter("SigAlg"); will(returnValue(URLDecoder.decode(Utils.getParameter("SigAlg", requestURL), "UTF-8")));
// destroy the signature value to make it fail
allowing(req).getParameter("Signature"); will(returnValue("test" + URLDecoder.decode(Utils.getParameter("Signature", requestURL), "UTF-8")));
allowing(req).getMethod(); will(returnValue("GET"));
allowing(req).getRequestURL(); will(returnValue(new StringBuffer(spMetadata.getSingleLogoutServiceHTTPRedirectLocation())));
allowing(req).getQueryString(); will(returnValue(requestURL.substring(requestURL.indexOf('?') + 1)));
one(res).sendRedirect(with(urlExtractor));
}});
logoutServiceHttpRedirectHandler.handleGet(ctx);
LogoutResponse lresp = parseResponse();
assertEquals(StatusCode.AUTHN_FAILED_URI, lresp.getStatus().getStatusCode().getValue());
}
示例8: handleSuccess
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void handleSuccess() throws Exception {
response.setStatus(SAMLUtil.createStatus(StatusCode.SUCCESS_URI));
response.setDestination(spMetadata.getAssertionConsumerServiceLocation(0));
Assertion assertion = TestHelper.buildAssertion(spMetadata.getAssertionConsumerServiceLocation(0), spMetadata.getEntityID());
response.getAssertions().add(assertion);
final String xml = TestHelper.signObject(response, credential);
context.checking(new Expectations() {{
atLeast(1).of(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(Base64.encodeBytes(xml.getBytes())));
allowing(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(handler.saveRequest(new Request("uri", "query", "GET", new HashMap<String, String[]>()))));
one(session).setAttribute(with(equal(Constants.SESSION_USER_ASSERTION)), with(any(UserAssertion.class)));
one(res).sendRedirect("uri?query");
one(req).getCookies(); will(returnValue(null));
one(session).getMaxInactiveInterval(); will(returnValue(30));
}});
expectCacheHeaders();
sh.handlePost(ctx);
}
示例9: failOnWrongDestination
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void failOnWrongDestination() throws Exception {
response.setStatus(SAMLUtil.createStatus(StatusCode.SUCCESS_URI));
response.setDestination("http://consumer");
Assertion assertion = TestHelper.buildAssertion(spMetadata.getAssertionConsumerServiceLocation(0), spMetadata.getEntityID());
response.getAssertions().add(assertion);
final String xml = TestHelper.signObject(response, credential);
context.checking(new Expectations() {{
atLeast(1).of(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(Base64.encodeBytes(xml.getBytes())));
allowing(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue(""));
}});
try {
sh.handlePost(ctx);
fail("Wrong destination, should fail");
} catch (RuntimeException e) {}
}
示例10: testReceiveResponseLoggedIn
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testReceiveResponseLoggedIn() throws Exception{
OIOLogoutRequest lr = OIOLogoutRequest.buildLogoutRequest(session, "http://slo", idpEntityId, handler);
handler.registerRequest(lr.getID(), idpMetadata.getFirstMetadata().getEntityID());
OIOLogoutResponse resp = OIOLogoutResponse.fromRequest(lr, StatusCode.SUCCESS_URI, "consent", idpEntityId, spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
String responseUrl = resp.getRedirectURL(credential, "relayState");
setExpectations(req, responseUrl, spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
context.checking(new Expectations() {{
one(res).sendRedirect("url");
one(session).removeAttribute(Constants.SESSION_USER_ASSERTION);
}});
lh.handleGet(ctx);
System.out.println(XMLHelper.nodeToString(TestHelper.parseBase64Encoded("nVLLbsIwELzzFZHvedh5OLFCpKocikQlBIhDL5VxNjQi2MjroH5%2BDYiiXjjUh%2FWuNTO7HrtemL0Z3QrwZDRCMAN0vZauN3pKvpw7oYhjRtOIpTyiBY1KKsosS2PTG5THIb6Gm8ga7LlX8LbZLFfQ9haUI8F8NiWfVZd0u06xihcFbynvZJvzIs9VsWNclhkrM%2Bqh%2Bj7GxngSKxjjvJKhKtM0zHaKhruMy7DNvRz41aXgSYgjzDU6qd2UsCQpw6QKab6hTLBUZNUHCbZg8XohFiUk%2BD4OGqdktFoYiT0KLY%2BAwimxfnlfCI8RJ2ucUWYgTa2RimsPeyMKf%2FCcLBHBXgwkzd3Ai0nRYPa9PlmIzr09RO2hjh%2FaTb120o14319NC8FWDiM874VXtFiPSgEi%2BSd9Kf28cri9IombOn7I%2FBY%2B%2BftXmsnkBw%3D%3D", true).getDocumentElement()));
handler.removeEntityIdForRequest(lr.getID());
}
示例11: testReceiveResponseCluster
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
@Test
public void testReceiveResponseCluster() throws Exception {
OIOLogoutRequest lr = OIOLogoutRequest.buildLogoutRequest(session, "http://cluster", idpEntityId, handler);
handler.registerRequest(lr.getID(), idpMetadata.getFirstMetadata().getEntityID());
OIOLogoutResponse resp = OIOLogoutResponse.fromRequest(lr, StatusCode.SUCCESS_URI, "consent", idpEntityId, spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
String responseUrl = resp.getRedirectURL(credential, "relayState");
setExpectations(req, responseUrl, "https://cluster:80/saml/LogoutServiceHTTPRedirectResponse");
context.checking(new Expectations() {{
one(res).sendRedirect("url");
one(session).removeAttribute(Constants.SESSION_USER_ASSERTION);
}});
String url = spMetadata.getDefaultAssertionConsumerService().getLocation();
String hostname = url.substring(0, url.indexOf('/', 8));
ctx = new RequestContext(new SAMLHttpServletRequest(req, hostname, null), res, idpMetadata, spMetadata, credential, configuration, handler, bindingHandlerFactory);
lh.handleGet(ctx);
}
示例12: buildStatus
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
private Status buildStatus(String status, String statMsg) {
Status stat = new StatusBuilder().buildObject();
// Set the status code
StatusCode statCode = new StatusCodeBuilder().buildObject();
statCode.setValue(status);
stat.setStatusCode(statCode);
// Set the status Message
if (statMsg != null) {
StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
statMesssage.setMessage(statMsg);
stat.setStatusMessage(statMesssage);
}
return stat;
}
示例13: buildResponse
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
/**
* Build the error response
*
* @param inResponseToID
* @param statusCodes
* @param statusMsg
* @return
*/
public Response buildResponse(String inResponseToID, List<String> statusCodes, String statusMsg,
String destination) throws IdentityException {
if (statusCodes == null || statusCodes.isEmpty()) {
throw IdentityException.error("No Status Values");
}
response.setIssuer(SAMLSSOUtil.getIssuer());
Status status = new StatusBuilder().buildObject();
StatusCode statusCode = null;
for (String statCode : statusCodes) {
statusCode = buildStatusCode(statCode, statusCode);
}
status.setStatusCode(statusCode);
buildStatusMsg(status, statusMsg);
response.setStatus(status);
response.setVersion(SAMLVersion.VERSION_20);
response.setID(SAMLSSOUtil.createID());
if (inResponseToID != null) {
response.setInResponseTo(inResponseToID);
}
if (destination != null) {
response.setDestination(destination);
}
response.setIssueInstant(new DateTime());
return response;
}
示例14: buildStatusCode
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
/**
* Build the StatusCode for Status of Response
*
* @param parentStatusCode
* @param childStatusCode
* @return
*/
private StatusCode buildStatusCode(String parentStatusCode, StatusCode childStatusCode) throws IdentityException {
if (parentStatusCode == null) {
throw IdentityException.error("Invalid SAML Response Status Code");
}
StatusCode statusCode = new StatusCodeBuilder().buildObject();
statusCode.setValue(parentStatusCode);
//Set the status Message
if (childStatusCode != null) {
statusCode.setStatusCode(childStatusCode);
return statusCode;
} else {
return statusCode;
}
}
示例15: buildStatus
import org.opensaml.saml2.core.StatusCode; //导入依赖的package包/类
private Status buildStatus(String status, String statMsg) {
Status stat = new StatusBuilder().buildObject();
//Set the status code
StatusCode statCode = new StatusCodeBuilder().buildObject();
statCode.setValue(status);
stat.setStatusCode(statCode);
//Set the status Message
if (statMsg != null) {
StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
statMesssage.setMessage(statMsg);
stat.setStatusMessage(statMesssage);
}
return stat;
}