/** * <p>This method populate the request and session with a logout requests to start a global logout from the IdP.</p> * @param request * @param userPrincipal */ private HttpServletRequestWrapper prepareLocalGlobalLogoutRequest(HttpServletRequest request, Principal userPrincipal) { try { SAML2Request saml2Request = new SAML2Request(); LogoutRequestType lort = saml2Request.createLogoutRequest(getIdentityURL()); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); nameID.setFormat(URI.create(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())); lort.setNameID(nameID); lort.setDestination(URI.create(getIdentityURL())); byte[] responseBytes = DocumentUtil.getDocumentAsString(saml2Request.convert(lort)).getBytes("UTF-8"); final String samlRequest = RedirectBindingUtil.deflateBase64Encode(responseBytes); return new HttpServletRequestWrapper(request) { @Override public String getParameter(String name) { if (SAML_REQUEST_KEY.equals(name)) { return samlRequest; } return super.getParameter(name); } }; } catch (Exception e) { throw new RuntimeException("Could not perform IdP Initiated Single Logout.", e); } }
/** * <p>This method populate the request and session with a logout requests to start a global logout from the IdP.</p> * @param request * @param userPrincipal */ private HttpServletRequestWrapper prepareLocalGlobalLogoutRequest(HttpServletRequest request, Principal userPrincipal) { try { SAML2Request saml2Request = new SAML2Request(); LogoutRequestType lort = saml2Request.createLogoutRequest(getIdentityURL()); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); nameID.setFormat(URI.create(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())); lort.setNameID(nameID); lort.setDestination(URI.create(getIdentityURL())); byte[] responseBytes = DocumentUtil.getDocumentAsString(saml2Request.convert(lort)).getBytes("UTF-8"); final String samlRequest = RedirectBindingUtil.deflateBase64Encode(responseBytes); return new HttpServletRequestWrapper(request) { @Override public String getParameter(String name) { if (SAML_REQUEST_KEY.equals(name)) { return samlRequest; } return super.getParameter(name); } }; } catch (Exception e) { throw new RuntimeException("Could not perform IdP Initiated Single Logout.", e); } }
/** * <p>This method populate the request and session with a logout requests to start a global logout from the IdP.</p> * * @param request * @param userPrincipal */ private void prepareLocalGlobalLogoutRequest(Request request, Principal userPrincipal) { try { SAML2Request saml2Request = new SAML2Request(); LogoutRequestType lort = saml2Request.createLogoutRequest(getIdentityURL()); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); nameID.setFormat(URI.create(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())); lort.setNameID(nameID); lort.setDestination(URI.create(getIdentityURL())); byte[] responseBytes = DocumentUtil.getDocumentAsString(saml2Request.convert(lort)).getBytes("UTF-8"); String samlRequest = RedirectBindingUtil.deflateBase64Encode(responseBytes); Session session = request.getSessionInternal(); session.setNote(SAML_REQUEST_KEY, samlRequest); } catch (Exception e) { throw new RuntimeException("Could not perform IdP Initiated Single Logout.", e); } }
/** * <p>This method populate the request and session with a logout requests to start a global logout from the IdP.</p> * * @param request * @param userPrincipal */ private void prepareLocalGlobalLogoutRequest(Request request, Principal userPrincipal) { try { SAML2Request saml2Request = new SAML2Request(); LogoutRequestType lort = saml2Request.createLogoutRequest(getIdentityURL()); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); nameID.setFormat(URI.create(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())); lort.setNameID(nameID); lort.setDestination(URI.create(getIdentityURL())); byte[] responseBytes = DocumentUtil.getDocumentAsString(saml2Request.convert(lort)).getBytes("UTF-8"); String samlRequest = RedirectBindingUtil.deflateBase64Encode(responseBytes); Session session = request.getSessionInternal(); session.setNote(SAML_REQUEST_KEY, samlRequest); } catch (Exception e) { throw new RuntimeException("Could not perform IdP Initiated Single Logout.", e); } }
/** * <p>This method populate the request and session with a logout requests to start a global logout from the IdP.</p> * * @param request * @param userPrincipal */ private void prepareLocalGlobalLogoutRequest(Request request, Principal userPrincipal) { try { SAML2Request saml2Request = new SAML2Request(); LogoutRequestType lort = saml2Request.createLogoutRequest(getIdentityURL()); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); nameID.setFormat(URI.create(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())); lort.setNameID(nameID); lort.setDestination(URI.create(getIdentityURL())); byte[] responseBytes = DocumentUtil.getDocumentAsString(saml2Request.convert(lort)).getBytes("UTF-8"); String samlRequest = RedirectBindingUtil.deflateBase64Encode(responseBytes); Session session = request.getSessionInternal(); session.setNote(SAML_REQUEST_KEY, samlRequest); } catch (Exception e) { throw new RuntimeException("Could not perform IdP Initiated Single Logout.", e); } }
lot.setDestination(URI.create(logoutUrl));
lot.setDestination(URI.create(logoutUrl));
lot.setDestination(URI.create(logoutUrl));
private LogoutRequestType createLogoutRequest(SAML2HandlerRequest request, String participant) throws ConfigurationException, ProcessingException { HTTPContext httpContext = (HTTPContext) request.getContext(); HttpServletRequest httpServletRequest = httpContext.getRequest(); LogoutRequestType lort = new SAML2Request().createLogoutRequest(request.getIssuer().getValue()); Principal userPrincipal = httpServletRequest.getUserPrincipal(); if (userPrincipal == null) { throw logger.samlHandlerPrincipalNotFoundError(); } NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); //Deal with NameID Format String nameIDFormat = (String) handlerConfig.getParameter(GeneralConstants.NAMEID_FORMAT); if (StringUtil.isNullOrEmpty(nameIDFormat)) { nameIDFormat = JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(); } nameID.setFormat(URI.create(nameIDFormat)); lort.setNameID(nameID); long assertionValidity = PicketLinkCoreSTS.instance().getConfiguration().getIssuedTokenTimeout(); lort.setNotOnOrAfter(XMLTimeUtil.add(lort.getIssueInstant(), assertionValidity)); lort.setDestination(URI.create(participant)); return lort; }
private LogoutRequestType createLogoutRequest(SAML2HandlerRequest request, String participant) throws ConfigurationException, ProcessingException { HTTPContext httpContext = (HTTPContext) request.getContext(); HttpServletRequest httpServletRequest = httpContext.getRequest(); LogoutRequestType lort = new SAML2Request().createLogoutRequest(request.getIssuer().getValue()); Principal userPrincipal = httpServletRequest.getUserPrincipal(); if (userPrincipal == null) { throw logger.samlHandlerPrincipalNotFoundError(); } NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal.getName()); //Deal with NameID Format String nameIDFormat = (String) handlerConfig.getParameter(GeneralConstants.NAMEID_FORMAT); if (StringUtil.isNullOrEmpty(nameIDFormat)) { nameIDFormat = JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(); } nameID.setFormat(URI.create(nameIDFormat)); lort.setNameID(nameID); long assertionValidity = PicketLinkCoreSTS.instance().getConfiguration().getIssuedTokenTimeout(); lort.setNotOnOrAfter(XMLTimeUtil.add(lort.getIssueInstant(), assertionValidity)); lort.setDestination(URI.create(participant)); return lort; }
lort.setDestination(URI.create(participant));
lort.setDestination(URI.create(participant));
lort.setDestination(URI.create(participant));
lort.setNameID(nameID); lort.setDestination(URI.create(nextParticipant)); response.setResultingDocument(saml2Request.convert(lort)); response.setSendRequest(true);
lort.setNameID(nameID); lort.setDestination(URI.create(nextParticipant)); response.setResultingDocument(saml2Request.convert(lort)); response.setSendRequest(true);