public StatusResponseType(StatusResponseType srt) { this(srt.getID(), srt.getIssueInstant()); this.issuer = srt.getIssuer(); this.signature = srt.getSignature(); this.extensions = srt.getExtensions(); this.status = srt.getStatus(); this.inResponseTo = srt.getInResponseTo(); this.destination = srt.getDestination(); this.consent = srt.getConsent(); }
private void generateSuccessStatusResponseType(String logOutRequestID, SAML2HandlerRequest request, SAML2HandlerResponse response, String originalIssuer) throws ConfigurationException, ParserConfigurationException, ProcessingException { logger.trace("Generating Success Status Response for " + originalIssuer); StatusResponseType statusResponse = new StatusResponseType(IDGenerator.create("ID_"), XMLTimeUtil.getIssueInstant()); // Status StatusType statusType = new StatusType(); StatusCodeType statusCodeType = new StatusCodeType(); statusCodeType.setValue(URI.create(JBossSAMLURIConstants.STATUS_SUCCESS.get())); statusType.setStatusCode(statusCodeType); statusResponse.setStatus(statusType); statusResponse.setInResponseTo(logOutRequestID); statusResponse.setIssuer(request.getIssuer()); statusResponse.setDestination(originalIssuer); try { SAML2Response saml2Response = new SAML2Response(); response.setResultingDocument(saml2Response.convert(statusResponse)); } catch (ParsingException je) { throw logger.processingError(je); } response.setDestination(originalIssuer); }
public void handleStatusResponseType(SAML2HandlerRequest request, SAML2HandlerResponse response) throws ProcessingException { // Handler a log out response from IDP StatusResponseType statusResponseType = (StatusResponseType) request.getSAML2Object(); checkDestination(statusResponseType.getDestination(), getSPConfiguration().getServiceURL()); HTTPContext httpContext = (HTTPContext) request.getContext(); HttpServletRequest servletRequest = httpContext.getRequest(); HttpSession session = servletRequest.getSession(false); // TODO: Deal with partial logout report StatusType statusType = statusResponseType.getStatus(); StatusCodeType statusCode = statusType.getStatusCode(); URI statusCodeValueURI = statusCode.getValue(); boolean success = false; if (statusCodeValueURI != null) { String statusCodeValue = statusCodeValueURI.toString(); if (JBossSAMLURIConstants.STATUS_SUCCESS.get().equals(statusCodeValue)) { success = true; session.invalidate(); } } }
/** * Write the common attributes for all response types * @param statusResponse * @throws ProcessingException */ private void writeBaseAttributes(StatusResponseType statusResponse) throws ProcessingException { //Attributes StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), statusResponse.getID()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.VERSION.get(), statusResponse.getVersion()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISSUE_INSTANT.get(), statusResponse.getIssueInstant() .toString()); String destination = statusResponse.getDestination(); if (StringUtil.isNotNull(destination)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.DESTINATION.get(), destination); String consent = statusResponse.getConsent(); if (StringUtil.isNotNull(consent)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.CONSENT.get(), consent); String inResponseTo = statusResponse.getInResponseTo(); if (StringUtil.isNotNull(inResponseTo)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.IN_RESPONSE_TO.get(), inResponseTo); } }
XMLGregorianCalendar issueInstantVal = XMLTimeUtil.parse(StaxParserUtil.getAttributeValue(issueInstant)); StatusResponseType response = new StatusResponseType(id, issueInstantVal); response.setDestination(StaxParserUtil.getAttributeValue(destination)); response.setConsent(StaxParserUtil.getAttributeValue(consent)); response.setInResponseTo(StaxParserUtil.getAttributeValue(inResponseTo)); return response;
public void handleStatusResponseType(SAML2HandlerRequest request, SAML2HandlerResponse response, ProviderType spConfiguration) throws ProcessingException { StatusResponseType statusResponseType = (StatusResponseType) request.getSAML2Object(); String issuer = statusResponseType.getIssuer().getValue(); trustIssuer(spConfiguration, request, issuer); }
/** * Write a {@code StatusResponseType} * * @param response * @param qname QName of the starting element * @param out * @throws ProcessingException */ public void write(StatusResponseType response, QName qname) throws ProcessingException { if (qname == null) { StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS_RESPONSE_TYPE.get(), PROTOCOL_NSURI.get()); } else { StaxUtil.writeStartElement(writer, qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI()); } StaxUtil.writeNameSpace(writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get()); StaxUtil.writeDefaultNameSpace(writer, ASSERTION_NSURI.get()); writeBaseAttributes(response); NameIDType issuer = response.getIssuer(); write(issuer, new QName(ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get(), ASSERTION_PREFIX)); StatusType status = response.getStatus(); write(status); StaxUtil.writeEndElement(writer); StaxUtil.flush(writer); }
String statusIssuer = statusResponseType.getIssuer().getValue(); server.stack().deRegisterTransitParticipant(sessionID, statusIssuer); generateSuccessStatusResponseType(statusResponseType.getInResponseTo(), request, response, relayState); Boolean isPost = server.stack().getBinding(relayState); if (isPost == null)
public StatusResponseType createStatusResponse(RequestAbstractType request, String statusCode, String statusMessage) { ObjectFactory objectFactory = new ObjectFactory(); org.picketlink.identity.federation.saml.v2.assertion.ObjectFactory assertionObjectFactory = new org.picketlink.identity.federation.saml.v2.assertion.ObjectFactory(); StatusResponseType response = objectFactory.createStatusResponseType(); response.setID(generateId()); response.setIssueInstant(generateIssueInstant()); NameIDType issuer = assertionObjectFactory.createNameIDType(); issuer.setValue(serviceProvider.getSamlConfiguration().getEntityId()); response.setIssuer(issuer); response.setVersion(JBossSAMLConstants.VERSION_2_0.get()); response.setInResponseTo(request.getID()); StatusCodeType statusCodeJaxb = objectFactory.createStatusCodeType(); statusCodeJaxb.setValue(statusCode); StatusType statusType = objectFactory.createStatusType(); statusType.setStatusCode(statusCodeJaxb); if (statusMessage != null) { statusType.setStatusMessage(statusMessage); } response.setStatus(statusType); return response; }
StatusResponseType statusResponseType = (StatusResponseType) samlObject; checkDestination(statusResponseType.getDestination(), getProviderconfig().getIdentityURL()); String statusIssuer = statusResponseType.getIssuer().getValue(); generateSuccessStatusResponseType(statusResponseType.getInResponseTo(), request, response, relayState);
public Object parse(XMLEventReader xmlEventReader) throws ParsingException { // Get the startelement StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader); StaxParserUtil.validate(startElement, LOGOUT_RESPONSE.get()); StatusResponseType response = parseBaseAttributes(startElement); while (xmlEventReader.hasNext()) { // Let us peek at the next start element startElement = StaxParserUtil.peekNextStartElement(xmlEventReader); if (startElement == null) break; String elementName = StaxParserUtil.getStartElementName(startElement); if (JBossSAMLConstants.ISSUER.get().equals(elementName)) { startElement = StaxParserUtil.getNextStartElement(xmlEventReader); NameIDType issuer = new NameIDType(); issuer.setValue(StaxParserUtil.getElementText(xmlEventReader)); response.setIssuer(issuer); } else if (JBossSAMLConstants.SIGNATURE.get().equals(elementName)) { startElement = StaxParserUtil.getNextStartElement(xmlEventReader); StaxParserUtil.bypassElementBlock(xmlEventReader, JBossSAMLConstants.SIGNATURE.get()); } else if (JBossSAMLConstants.STATUS.get().equals(elementName)) { response.setStatus(parseStatus(xmlEventReader)); } } return response; }
public void processIDPResponse(HttpServletRequest httpRequest, HttpServletResponse httpResponse, StatusResponseType response, RequestContext requestContext, SamlIdentityProvider idp) { if (response.getStatus() != null && response.getStatus().getStatusCode().getValue().equals(JBossSAMLURIConstants.STATUS_SUCCESS.get())) { Identity.instance().logout(); } else { throw new RuntimeException("Single logout failed. Status code: " + (response.getStatus() == null ? "null" : response.getStatus().getStatusCode().getValue())); } try { httpResponse.sendRedirect(serviceProvider.getLoggedOutUrl()); } catch (IOException e) { throw new RuntimeException(e); } } }
try samlResponse.setDestination(endpoint.getResponseLocation());
/** * Write the common attributes for all response types * * @param statusResponse * @throws ProcessingException */ private void writeBaseAttributes(StatusResponseType statusResponse) throws ProcessingException { // Attributes StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), statusResponse.getID()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.VERSION.get(), statusResponse.getVersion()); StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISSUE_INSTANT.get(), statusResponse.getIssueInstant().toString()); String destination = statusResponse.getDestination(); if (StringUtil.isNotNull(destination)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.DESTINATION.get(), destination); String consent = statusResponse.getConsent(); if (StringUtil.isNotNull(consent)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.CONSENT.get(), consent); String inResponseTo = statusResponse.getInResponseTo(); if (StringUtil.isNotNull(inResponseTo)) StaxUtil.writeAttribute(writer, JBossSAMLConstants.IN_RESPONSE_TO.get(), inResponseTo); } }
XMLGregorianCalendar issueInstantVal = XMLTimeUtil.parse(StaxParserUtil.getAttributeValue(issueInstant)); StatusResponseType response = new StatusResponseType(id, issueInstantVal); response.setDestination(StaxParserUtil.getAttributeValue(destination)); response.setConsent(StaxParserUtil.getAttributeValue(consent)); response.setInResponseTo(StaxParserUtil.getAttributeValue(inResponseTo)); return response;
public void handleStatusResponseType(SAML2HandlerRequest request, SAML2HandlerResponse response, ProviderType spConfiguration) throws ProcessingException { StatusResponseType statusResponseType = (StatusResponseType) request.getSAML2Object(); String issuer = statusResponseType.getIssuer().getValue(); trustIssuer(spConfiguration, request, issuer); }
/** * Write a {@code StatusResponseType} * * @param response * @param qname QName of the starting element * @param out * * @throws ProcessingException */ public void write(StatusResponseType response, QName qname) throws ProcessingException { if (qname == null) { StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS_RESPONSE_TYPE.get(), PROTOCOL_NSURI.get()); } else { StaxUtil.writeStartElement(writer, qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI()); } StaxUtil.writeNameSpace(writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get()); StaxUtil.writeDefaultNameSpace(writer, ASSERTION_NSURI.get()); writeBaseAttributes(response); NameIDType issuer = response.getIssuer(); write(issuer, new QName(ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get(), ASSERTION_PREFIX)); StatusType status = response.getStatus(); write(status); StaxUtil.writeEndElement(writer); StaxUtil.flush(writer); }
String statusIssuer = statusResponseType.getIssuer().getValue(); server.stack().deRegisterTransitParticipant(sessionID, statusIssuer); generateSuccessStatusResponseType(statusResponseType.getInResponseTo(), request, response, relayState); Boolean isPost = server.stack().getBinding(relayState); if (isPost == null)
StatusResponseType statusResponseType = (StatusResponseType) samlObject; checkDestination(statusResponseType.getDestination(), getProviderconfig().getIdentityURL()); String statusIssuer = statusResponseType.getIssuer().getValue(); generateSuccessStatusResponseType(statusResponseType.getInResponseTo(), request, response, relayState);
public Object parse(XMLEventReader xmlEventReader) throws ParsingException { // Get the startelement StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader); StaxParserUtil.validate(startElement, LOGOUT_RESPONSE.get()); StatusResponseType response = parseBaseAttributes(startElement); while (xmlEventReader.hasNext()) { // Let us peek at the next start element startElement = StaxParserUtil.peekNextStartElement(xmlEventReader); if (startElement == null) break; String elementName = StaxParserUtil.getStartElementName(startElement); if (JBossSAMLConstants.ISSUER.get().equals(elementName)) { startElement = StaxParserUtil.getNextStartElement(xmlEventReader); NameIDType issuer = new NameIDType(); issuer.setValue(StaxParserUtil.getElementText(xmlEventReader)); response.setIssuer(issuer); } else if (JBossSAMLConstants.SIGNATURE.get().equals(elementName)) { startElement = StaxParserUtil.getNextStartElement(xmlEventReader); StaxParserUtil.bypassElementBlock(xmlEventReader, JBossSAMLConstants.SIGNATURE.get()); } else if (JBossSAMLConstants.STATUS.get().equals(elementName)) { response.setStatus(parseStatus(xmlEventReader)); } } return response; }