当前位置: 首页>>代码示例>>Java>>正文


Java LogoutResponse类代码示例

本文整理汇总了Java中org.opensaml.saml2.core.LogoutResponse的典型用法代码示例。如果您正苦于以下问题:Java LogoutResponse类的具体用法?Java LogoutResponse怎么用?Java LogoutResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LogoutResponse类属于org.opensaml.saml2.core包,在下文中一共展示了LogoutResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doSLO

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
/**
 * This method handles the logout requests from the IdP
 * Any request for the defined logout URL is handled here
 *
 * @param request
 * @throws javax.servlet.ServletException
 * @throws IOException
 */
public void doSLO(HttpServletRequest request) throws SAMLSSOException {

    doBootstrap();
    XMLObject samlObject = null;
    if (request.getParameter(SSOConstants.HTTP_POST_PARAM_SAML2_AUTH_REQ) != null) {
        samlObject = unmarshall(new String(Base64.decode(request.getParameter(
                SSOConstants.HTTP_POST_PARAM_SAML2_AUTH_REQ))));
    }
    if (samlObject == null) {
        samlObject = unmarshall(new String(Base64.decode(request.getParameter(
                SSOConstants.HTTP_POST_PARAM_SAML2_RESP))));
    }
    if (samlObject instanceof LogoutRequest) {
        LogoutRequest logoutRequest = (LogoutRequest) samlObject;
        String sessionIndex = logoutRequest.getSessionIndexes().get(0).getSessionIndex();
    } else if (samlObject instanceof LogoutResponse) {
        request.getSession().invalidate();
    } else {
        throw new SAMLSSOException("Invalid Single Logout SAML Request");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:DefaultSAML2SSOManager.java

示例2: processResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
public void processResponse(HttpServletRequest request, HttpServletResponse response)
        throws SSOAgentException {

    String saml2SSOResponse = request.getParameter(SSOAgentConstants.SAML2SSO.HTTP_POST_PARAM_SAML2_RESP);

    if (saml2SSOResponse != null) {
        String decodedResponse = new String(Base64.decode(saml2SSOResponse), Charset.forName("UTF-8"));
        XMLObject samlObject = SSOAgentUtils.unmarshall(decodedResponse);
        if (samlObject instanceof LogoutResponse) {
            //This is a SAML response for a single logout request from the SP
            doSLO(request);
        } else {
            processSSOResponse(request);
        }
        String relayState = request.getParameter(RelayState.DEFAULT_ELEMENT_LOCAL_NAME);

        if (relayState != null && !relayState.isEmpty() && !"null".equalsIgnoreCase(relayState)) { //additional
            // checks for incompetent IdPs
            ssoAgentConfig.getSAML2().setRelayState(relayState);
        }

    } else {
        throw new SSOAgentException("Invalid SAML2 Response. SAML2 Response can not be null.");
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:26,代码来源:SAML2SSOManager.java

示例3: buildLogoutResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
public LogoutResponse buildLogoutResponse(String id, String status, String statMsg)
        throws SSOAgentException {

    LogoutResponse logoutResp = new LogoutResponseBuilder().buildObject();
    logoutResp.setID(SSOAgentUtils.createID());
    logoutResp.setInResponseTo(id);

    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(ssoAgentConfig.getSAML2().getSPEntityId());
    logoutResp.setIssuer(issuer);

    logoutResp.setStatus(buildStatus(status, statMsg));
    logoutResp.setIssueInstant(new DateTime());
    logoutResp.setDestination(ssoAgentConfig.getSAML2().getIdPURL());

    SSOAgentUtils.setSignatureValue(logoutResp, XMLSignature.ALGO_ID_SIGNATURE_RSA,
            new X509CredentialImpl(ssoAgentConfig.getSAML2().getSSOAgentX509Credential()));

    return logoutResp;
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:22,代码来源:SAML2SSOManager.java

示例4: testGetRedirectResponseURL

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
@Test
public void testGetRedirectResponseURL() throws Exception {
	Credential cred = getCredential();
	String url = response.getRedirectURL(cred, "relayState");
	
	assertNotNull(url);
	
	URI u = new URI(url);
	assertEquals("destination", u.getHost());

	String req = Utils.getParameter("SAMLResponse", url);
	assertNotNull(req);
	
	Document doc = parseBase64Encoded(req);
	LogoutResponse lr = (LogoutResponse) Configuration.getUnmarshallerFactory().getUnmarshaller(doc.getDocumentElement()).unmarshall(doc.getDocumentElement());
	assertEquals("entityId", lr.getIssuer().getValue());
	assertEquals("status", lr.getStatus().getStatusCode().getValue());
	assertEquals("consent", lr.getConsent());
	assertEquals(request.getID(), lr.getInResponseTo());
	assertEquals("http://destination", lr.getDestination());
	
	System.out.println(url);
	validateUrlSignature(cred, url, req, "SAMLResponse");
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:OIOLogoutResponseTest.java

示例5: testRedirect

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的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());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:26,代码来源:LogoutServiceHTTPRedirectHandlerTest.java

示例6: failWhenInvalidSignature

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的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());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:23,代码来源:LogoutServiceHTTPRedirectHandlerTest.java

示例7: buildErrorResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
/**
 * Builds the SAML error response and sets the compressed value to the reqValidationResponseDTO
 *
 * @param id
 * @param status
 * @param statMsg
 * @param destination
 * @return
 * @throws IdentityException
 */
private SAMLSSOReqValidationResponseDTO buildErrorResponse(String id, String status, String statMsg, String
        destination, String responseSigningAlgorithmUri, String responseDigestAlgorithmUri)
        throws IdentityException {
    SAMLSSOReqValidationResponseDTO reqValidationResponseDTO = new SAMLSSOReqValidationResponseDTO();
    LogoutResponse logoutResp = new SingleLogoutMessageBuilder().buildLogoutResponse(id, status, statMsg,
            destination, false, null, responseSigningAlgorithmUri, responseDigestAlgorithmUri);
    reqValidationResponseDTO.setLogOutReq(true);
    reqValidationResponseDTO.setValid(false);
    try {
        reqValidationResponseDTO.setResponse(SAMLSSOUtil.compressResponse(SAMLSSOUtil.marshall(logoutResp)));
    } catch (IOException e) {
        throw IdentityException.error("Error while creating logout response", e);
    }
    return reqValidationResponseDTO;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:26,代码来源:SPInitLogoutRequestProcessor.java

示例8: buildLogoutResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
/**
 * Build a SAML2 Single Logout Response.
 * 
 * @param binding
 *            the request binding
 * @return the authentication request
 */
protected LogoutResponse buildLogoutResponse(final SamlBindingEnum binding) {
	final DateTime issueInstant = new DateTime();
	final LogoutResponse logoutResponse = this.logoutResponseBuilder
			.buildObject(LogoutResponse.DEFAULT_ELEMENT_NAME);

	logoutResponse.setIssueInstant(issueInstant);
	logoutResponse.setIssuer(this.buildIssuer());

	logoutResponse.setDestination(this.idpConfig.getIdpSloEndpointUrl(binding));
	logoutResponse.setVersion(SAMLVersion.VERSION_20);

	this.getSaml20SpProcessor().signSamlObject(logoutResponse);

	return logoutResponse;
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:23,代码来源:OpenSaml20IdpConnector.java

示例9: testFindSaml20IdpConnectorToUseToProcessResponses

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
/**
 * The SP receive à LogoutResponse from the IdP. Which IdPConnector to choose ?
 * @throws Exception
 */
@Test
public void testFindSaml20IdpConnectorToUseToProcessResponses() throws Exception {
	// Mock the Original Request the response is responding to.
	Mockito.when(this.samlStorage.findAuthentication(SESSION_INDEX_1)).thenReturn(this.buildBasicSamlAuthentication());
	// Build the original request with IdpConnector1
	final IOutgoingSaml logoutRequest = this.idpConnector1.buildSaml20SingleLogoutRequest(SESSION_INDEX_1, SamlBindingEnum.SAML_20_HTTP_POST);
	Mockito.when(this.samlStorage.findRequestWaitingForResponse(REQUEST_ID)).thenReturn((IRequestWaitingForResponse) logoutRequest.getSamlQuery());
	
	
	final LogoutResponse logoutResponse = this.logoutResponseBuilder.buildObject();
	final Issuer issuer = issuerBuilder.buildObject();
	
	// Issuer
	issuer.setValue(IDP1_ENTITY_ID);
	
	// Request
	logoutResponse.setIssuer(issuer);
	logoutResponse.setID(RESPONSE_ID);
	logoutResponse.setInResponseTo(REQUEST_ID);
	
	final ISaml20IdpConnector connectorToUse = this.spProcessor.findSaml20IdpConnectorToUse(logoutResponse);
	Assert.assertNotNull("No IdPConnector to use found !", connectorToUse);
	Assert.assertEquals("Wrong IdPConnector used !", this.idpConnector1, connectorToUse);
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:29,代码来源:OpenSaml20IntegrationTest.java

示例10: createLogoutResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private LogoutResponse createLogoutResponse(String id, 
                                    String code, String msg) {
    
  // Consume LogoutResponse
  LogoutResponse lresp = ((SAMLObjectBuilder<LogoutResponse>) 
            _bf.getBuilder(LogoutResponse.DEFAULT_ELEMENT_NAME)).
                                                          buildObject();
  String uid = UUID.randomUUID().toString();
  
  lresp.setID(uid);
  lresp.setInResponseTo(id);
  lresp.setIssueInstant(new DateTime());
  lresp.setVersion(SAMLVersion.VERSION_20);
  lresp.setIssuer(getIssuer());
  
  // Set status code
  Status status = ((SAMLObjectBuilder<Status>) _bf.getBuilder(
              Status.DEFAULT_ELEMENT_NAME)).buildObject();
  
  StatusCode scode = ((SAMLObjectBuilder<StatusCode>) _bf.getBuilder(
              StatusCode.DEFAULT_ELEMENT_NAME)).buildObject();
  scode.setValue(code);
  status.setStatusCode(scode);
  
  if (!msg.equals("")) {
    StatusMessage smsg = ((SAMLObjectBuilder<StatusMessage>) _bf.getBuilder(
                          StatusMessage.DEFAULT_ELEMENT_NAME)).buildObject();
    smsg.setMessage(msg);
    status.setStatusMessage(smsg);
  }
  
  lresp.setStatus(status);
  
  return lresp;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:37,代码来源:SamlSecurityProvider.java

示例11: fromRequest

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
public static OIOLogoutResponse fromRequest(OIOLogoutRequest request, String statusCode, String consent, String entityId, String destination) {
	LogoutResponse logoutResponse = SAMLUtil.buildXMLObject(LogoutResponse.class);

	logoutResponse.setID(Utils.generateUUID());
	logoutResponse.setIssueInstant(new DateTime(DateTimeZone.UTC));
	logoutResponse.setVersion(SAMLVersion.VERSION_20);
	logoutResponse.setStatus(SAMLUtil.createStatus(statusCode != null ? statusCode : StatusCode.SUCCESS_URI));
	
	if (request != null) {
		logoutResponse.setInResponseTo(request.getID());
	}
	logoutResponse.setIssuer(SAMLUtil.createIssuer(entityId));
	logoutResponse.setDestination(destination);
	if (consent != null) {
		logoutResponse.setConsent(consent);
	}
	if (statusCode != null && !StatusCode.SUCCESS_URI.equals(statusCode)) {
		log.error("Invalid <LogoutRequest>: " + consent);
	}
	try {
		if (log.isDebugEnabled()) log.debug("Validate the logoutResponse...");
		logoutResponse.validate(true);
		if (log.isDebugEnabled()) log.debug("...OK");
	} catch (ValidationException e) {
		throw new WrappedException(Layer.CLIENT, e);
	}

	return new OIOLogoutResponse(logoutResponse);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:30,代码来源:OIOLogoutResponse.java

示例12: testToSoapEnvelope

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
@Test
public void testToSoapEnvelope() {
	String xml = response.toSoapEnvelope();
	Envelope e = (Envelope) SAMLUtil.unmarshallElementFromString(xml);
	Body body = e.getBody();
	assertNotNull(body);
	
	List<XMLObject> objects = body.getUnknownXMLObjects();
	assertEquals(1, objects.size());
	assertTrue(objects.get(0) instanceof LogoutResponse);
	
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:13,代码来源:OIOLogoutResponseTest.java

示例13: parseResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
private LogoutResponse parseResponse() throws ParserConfigurationException,
		SAXException, IOException, UnsupportedEncodingException,
		UnmarshallingException {
	Document doc = parseBase64Encoded(Utils.getParameter("SAMLResponse", urlExtractor.getValue()));
	LogoutResponse lr = (LogoutResponse) Configuration.getUnmarshallerFactory().getUnmarshaller(doc.getDocumentElement()).unmarshall(doc.getDocumentElement());
	return lr;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:8,代码来源:LogoutServiceHTTPRedirectHandlerTest.java

示例14: processResponse

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
@Override
public void processResponse(HttpServletRequest request) throws SAMLSSOException {

    doBootstrap();
    String decodedResponse = new String(Base64.decode(request.getParameter(
            SSOConstants.HTTP_POST_PARAM_SAML2_RESP)));
    XMLObject samlObject = unmarshall(decodedResponse);
    if (samlObject instanceof LogoutResponse) {
        //This is a SAML response for a single logout request from the SP
        doSLO(request);
    } else {
        processSSOResponse(request);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:15,代码来源:DefaultSAML2SSOManager.java

示例15: testSingleElementMarshall

import org.opensaml.saml2.core.LogoutResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
    QName qname = new QName(SAMLConstants.SAML20P_NS, LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
    LogoutResponse resp = (LogoutResponse) buildXMLObject(qname);
    
    super.populateRequiredAttributes(resp);
    
    assertEquals(expectedDOM, resp);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:LogoutResponseTest.java


注:本文中的org.opensaml.saml2.core.LogoutResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。