protected void sendHttpPostBindingRequest(String destination, Document samlDocument, String relayState, HttpServletResponse response, boolean willSendRequest) throws ProcessingException, IOException, ConfigurationException { String samlMessage = PostBindingUtil.base64Encode(DocumentUtil.getDocumentAsString(samlDocument)); DestinationInfoHolder destinationHolder = new DestinationInfoHolder(destination, samlMessage, relayState); PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); }
/** * Given a base64 encoded assertion string, parse into {@link org.picketlink.identity.federation.saml.v2.assertion.AssertionType} * @param base64EncodedAssertion * @return * @throws ParsingException */ protected AssertionType parseAssertion(String base64EncodedAssertion) throws ParsingException { InputStream inputStream = PostBindingUtil.base64DecodeAsStream(base64EncodedAssertion); // Load the assertion SAMLParser samlParser = new SAMLParser(); return (AssertionType) samlParser.parse(inputStream); }
/** * Apply base64 decoding on the message and return the stream * @param encodedString * @return */ public static InputStream base64DecodeAsStream(String encodedString) { if (encodedString == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "encodedString"); return new ByteArrayInputStream(base64Decode(encodedString)); }
destination = escapeHTML(destination); common(holder.getDestination(), response); StringBuilder builder = new StringBuilder(); relayState = escapeHTML(relayState); builder.append("<INPUT TYPE=\"HIDDEN\" NAME=\"RelayState\" " + "VALUE=\"" + relayState + "\"/>");
@POST public Response generateAssertion(@Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) throws Exception { Principal principal = httpServletRequest.getUserPrincipal(); if (principal == null) { // Send Error Response return Response.status(403).build(); } SAMLProtocolContext samlProtocolContext = getSAMLProtocolContext(principal.getName()); AssertionType assertionType = issueSAMLAssertion(samlProtocolContext); // TODO: sign/encrypt String base64EncodedAssertion = PostBindingUtil.base64Encode(AssertionUtil.asString(assertionType)); return Response.status(200).entity(base64EncodedAssertion).build(); } }
/** * Send the payload via HTTP/POST * @param destinationHolder {@link org.picketlink.identity.federation.core.saml.v2.holders.DestinationInfoHolder} holds info on the destination * @param response {@link javax.servlet.http.HttpServletResponse} * @param willSendRequest whether it is a SAML request or response so that the page title can be set * @throws IOException */ public void sendPost(DestinationInfoHolder destinationHolder,HttpServletResponse response, boolean willSendRequest) throws IOException{ PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); }
common(holder.getDestination(), response); StringBuilder builder = new StringBuilder();
@POST public Response generateAssertion(@Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) throws Exception { Principal principal = httpServletRequest.getUserPrincipal(); if (principal == null) { // Send Error Response return Response.status(403).build(); } SAMLProtocolContext samlProtocolContext = getSAMLProtocolContext(principal.getName()); AssertionType assertionType = issueSAMLAssertion(samlProtocolContext); // TODO: sign/encrypt String base64EncodedAssertion = PostBindingUtil.base64Encode(AssertionUtil.asString(assertionType)); return Response.status(200).entity(base64EncodedAssertion).build(); } }
/** * Send the payload via HTTP/POST * @param destinationHolder {@link org.picketlink.identity.federation.core.saml.v2.holders.DestinationInfoHolder} holds info on the destination * @param response {@link javax.servlet.http.HttpServletResponse} * @param willSendRequest whether it is a SAML request or response so that the page title can be set * @throws IOException */ public void sendPost(DestinationInfoHolder destinationHolder,HttpServletResponse response, boolean willSendRequest) throws IOException{ PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); }
destination = escapeHTML(destination); common(holder.getDestination(), response); StringBuilder builder = new StringBuilder(); relayState = escapeHTML(relayState); builder.append("<INPUT TYPE=\"HIDDEN\" NAME=\"RelayState\" " + "VALUE=\"" + relayState + "\"/>");
common(holder.getDestination(), response); StringBuilder builder = new StringBuilder();
protected void sendHttpPostBindingRequest(String destination, Document samlDocument, String relayState, HttpServletResponse response, boolean willSendRequest) throws ProcessingException, IOException, ConfigurationException { String samlMessage = PostBindingUtil.base64Encode(DocumentUtil.getDocumentAsString(samlDocument)); DestinationInfoHolder destinationHolder = new DestinationInfoHolder(destination, samlMessage, relayState); PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); }
/** * Given a base64 encoded assertion string, parse into {@link org.picketlink.identity.federation.saml.v2.assertion.AssertionType} * @param base64EncodedAssertion * @return * @throws ParsingException */ protected AssertionType parseAssertion(String base64EncodedAssertion) throws ParsingException { InputStream inputStream = PostBindingUtil.base64DecodeAsStream(base64EncodedAssertion); // Load the assertion SAMLParser samlParser = new SAMLParser(); return (AssertionType) samlParser.parse(inputStream); }
/** * <p> * Sends a HTTP POST request to the IDP. * </p> * * @param destination * @param samlDocument * @param relayState * @param response * @param willSendRequest * @throws org.picketlink.common.exceptions.TrustKeyProcessingException * @throws ProcessingException * @throws IOException * @throws ConfigurationException */ public void sendHttpPostBindingRequest(String destination, Document samlDocument, String relayState, HttpServletResponse response, boolean willSendRequest) throws ProcessingException, IOException, ConfigurationException { String samlMessage = PostBindingUtil.base64Encode(DocumentUtil.getDocumentAsString(samlDocument)); DestinationInfoHolder destinationHolder = new DestinationInfoHolder(destination, samlMessage, relayState); //PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); redirectionHandler.sendPost(destinationHolder, response, willSendRequest); }
/** * Apply base64 decoding on the message and return the stream * @param encodedString * @return */ public static InputStream base64DecodeAsStream(String encodedString) { if (encodedString == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "encodedString"); return new ByteArrayInputStream(base64Decode(encodedString)); }
common(holder.getDestination(), response); StringBuilder builder = new StringBuilder();
/** * <p> Sends a HTTP POST request to the IDP. </p> * * @param destination * @param samlDocument * @param relayState * @param response * @param willSendRequest * * @throws ProcessingException * @throws IOException * @throws ConfigurationException */ protected void sendHttpPostBindingRequest(String destination, Document samlDocument, String relayState, Response response, boolean willSendRequest) throws ProcessingException, IOException, ConfigurationException { String samlMessage = PostBindingUtil.base64Encode(DocumentUtil.getDocumentAsString(samlDocument)); DestinationInfoHolder destinationHolder = new DestinationInfoHolder(destination, samlMessage, relayState); PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); }
private Document toSAMLResponseDocument(String samlResponse, boolean isPostBinding) throws ParsingException { InputStream dataStream = null; if (isPostBinding) { // deal with SAML response from IDP dataStream = PostBindingUtil.base64DecodeAsStream(samlResponse); } else { // deal with SAML response from IDP dataStream = RedirectBindingUtil.base64DeflateDecode(samlResponse); } try { return DocumentUtil.getDocument(dataStream); } catch (Exception e) { logger.samlResponseFromIDPParsingFailed(); throw new ParsingException("", e); } }
/** * <p> * Sends a HTTP POST request to the IDP. * </p> * * @param destination * @param samlDocument * @param relayState * @param response * @param willSendRequest * @throws org.picketlink.common.exceptions.TrustKeyProcessingException * @throws ProcessingException * @throws IOException * @throws ConfigurationException */ public void sendHttpPostBindingRequest(String destination, Document samlDocument, String relayState, HttpServletResponse response, boolean willSendRequest) throws ProcessingException, IOException, ConfigurationException { String samlMessage = PostBindingUtil.base64Encode(DocumentUtil.getDocumentAsString(samlDocument)); DestinationInfoHolder destinationHolder = new DestinationInfoHolder(destination, samlMessage, relayState); //PostBindingUtil.sendPost(destinationHolder, response, willSendRequest); redirectionHandler.sendPost(destinationHolder, response, willSendRequest); }
/** * Apply base64 decoding on the message and return the stream * * @param encodedString * * @return */ public static InputStream base64DecodeAsStream(String encodedString) { if (encodedString == null) throw logger.nullArgumentError("encodedString"); return new ByteArrayInputStream(base64Decode(encodedString)); }