Package org.picketlink.identity.federation.api.saml.v2.response

Examples of org.picketlink.identity.federation.api.saml.v2.response.SAML2Response


   public ResponseType getErrorResponse(String responseURL, String status,
         String identityURL)
   {
      ResponseType responseType = null;

      SAML2Response saml2Response = new SAML2Response();

      //Create a response type
      String id = IDGenerator.create("ID_");

      IssuerInfoHolder issuerHolder = new IssuerInfoHolder(identityURL);
      issuerHolder.setStatusCode(status);

      IDPInfoHolder idp = new IDPInfoHolder();
      idp.setNameIDFormatValue(null);
      idp.setNameIDFormat(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get());

      SPInfoHolder sp = new SPInfoHolder();
      sp.setResponseDestinationURI(responseURL);
      try
      {
         responseType = saml2Response.createResponseType(id, sp, idp, issuerHolder);
      }
      catch (ConfigurationException e1)
      {
         log.trace(e1);
         responseType = saml2Response.createResponseType();
      }

      log.debug("ResponseType = ");
      //Lets see how the response looks like
      if(log.isTraceEnabled())
      {
         StringWriter sw = new StringWriter();
         try
         {
            saml2Response.marshall(responseType, sw);
         }
         catch (JAXBException e)
         {
            log.trace(e);
         }
View Full Code Here


        
         //deal with SAML response from IDP
         byte[] base64DecodedResponse = PostBindingUtil.base64Decode(samlResponse);
         InputStream is = new ByteArrayInputStream(base64DecodedResponse);

         SAML2Response saml2Response = new SAML2Response();
        
         ResponseType responseType = saml2Response.getResponseType(is);
                 
         this.isTrusted(responseType.getIssuer().getValue());
        
         List<Object> assertions = responseType.getAssertionOrEncryptedAssertion();
         if(assertions.size() == 0)
View Full Code Here

            byte[] base64DecodedResponse = PostBindingUtil.base64Decode(samlResponse);
            InputStream is = new ByteArrayInputStream(base64DecodedResponse);

            try
            {
               SAML2Response saml2Response = new SAML2Response();
              
               ResponseType responseType = saml2Response.getResponseType(is);
              
               SAMLDocumentHolder samlDocumentHolder = saml2Response.getSamlDocumentHolder();
              
               boolean validSignature = this.verifySignature(samlDocumentHolder);
              
               if(validSignature == false)
                  throw new IssuerNotTrustedException("Signature in saml document is invalid");
View Full Code Here

      if(trace)
         log.trace("AssertionConsumerURL=" + assertionConsumerURL +
            "::assertion validity=" + assertionValidity);
      ResponseType responseType = null;    
     
      SAML2Response saml2Response = new SAML2Response();
           
      //Create a response type
      String id = IDGenerator.create("ID_");

      IssuerInfoHolder issuerHolder = new IssuerInfoHolder(identityURL);
      issuerHolder.setStatusCode(JBossSAMLURIConstants.STATUS_SUCCESS.get());

      IDPInfoHolder idp = new IDPInfoHolder();
      idp.setNameIDFormatValue(userPrincipal.getName());
      idp.setNameIDFormat(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get());

      SPInfoHolder sp = new SPInfoHolder();
      sp.setResponseDestinationURI(assertionConsumerURL);
      responseType = saml2Response.createResponseType(id, sp, idp, issuerHolder);
     
     
      //Add information on the roles
      AssertionType assertion = (AssertionType) responseType.getAssertionOrEncryptedAssertion().get(0);

      AttributeStatementType attrStatement = saml2Response.createAttributeStatement(roles);
      assertion.getStatementOrAuthnStatementOrAuthzDecisionStatement().add(attrStatement);
     
      //Add timed conditions
      saml2Response.createTimedConditions(assertion, assertionValidity);
      //Lets see how the response looks like
      if(log.isTraceEnabled())
      {
         StringWriter sw = new StringWriter();
         try
         {
            saml2Response.marshall(responseType, sw);
         }
         catch (JAXBException e)
         {
            log.trace(e);
         }
         catch (SAXException e)
         {
            log.trace(e);
         }
         log.trace("Response="+sw.toString());
      }
     
      if(trace)
         log.trace("Support Sig=" + supportSignature + " ::Post Profile?=" + hasSAMLRequestInPostProfile());
      if(supportSignature && hasSAMLRequestInPostProfile())
      {
         try
         {
            SAML2Signature saml2Signature = new SAML2Signature();
            samlResponseDocument = saml2Signature.sign(responseType, keyManager.getSigningKeyPair());
        
         catch (Exception e)
         { 
            if(trace) log.trace(e);
         }
      }
      else
         try
         {
            samlResponseDocument = saml2Response.convert(responseType);
         }
         catch (Exception e)
         {
            log.trace(e);
         }
View Full Code Here

    private static final PicketLinkLogger logger = PicketLinkLoggerFactory.getLogger();

    public static SAMLDocumentHolder parseRedirectBinding(String samlMessage) {
        InputStream is;
        is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
        SAML2Request saml2Request = new SAML2Request();
        try {
            saml2Request.getSAML2ObjectFromStream(is);
            return saml2Request.getSamlDocumentHolder();
        } catch (Exception e) {
            logger.samlBase64DecodingError(e);
        }
        return null;
View Full Code Here

    public static SAMLDocumentHolder parsePostBinding(String samlMessage) {
        InputStream is;
        byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
        is = new ByteArrayInputStream(samlBytes);
        SAML2Request saml2Request = new SAML2Request();
        try {
            saml2Request.getSAML2ObjectFromStream(is);
            return saml2Request.getSamlDocumentHolder();
        } catch (Exception e) {
            logger.samlBase64DecodingError(e);
        }
        return null;
    }
View Full Code Here

        Document samlResponseDocument = buildDocument();
        return new PostBindingBuilder(samlResponseDocument);

    }
    public Document buildDocument() throws ProcessingException, ConfigurationException, ParsingException {
        Document document = new SAML2Request().convert(createLogoutRequest());
        if (encrypt) encryptDocument(document);
        return document;
    }
View Full Code Here

        if (encrypt) encryptDocument(document);
        return document;
    }

    private LogoutRequestType createLogoutRequest() throws ConfigurationException {
        LogoutRequestType lort = new SAML2Request().createLogoutRequest(responseIssuer);

        NameIDType nameID = new NameIDType();
        nameID.setValue(userPrincipal);
        //Deal with NameID Format
        String nameIDFormat = JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get();
View Full Code Here

    }

    public SAMLDocumentHolder getSAMLDocumentHolder(String samlMessage) throws ParsingException, ConfigurationException,
            ProcessingException {
        InputStream is = null;
        SAML2Request saml2Request = new SAML2Request();

        try {
            if (redirectProfile) {
                is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
            } else {
                byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
                logger.trace("SAML Request Document: " + new String(samlBytes));
                is = new ByteArrayInputStream(samlBytes);
            }
        } catch (Exception rte) {
            logger.samlBase64DecodingError(rte);
            throw logger.parserError(rte);
        }

        saml2Request.getSAML2ObjectFromStream(is);

        return saml2Request.getSamlDocumentHolder();
    }
View Full Code Here

    }

    public RequestAbstractType getSAMLRequest(String samlMessage) throws ParsingException, ConfigurationException,
            ProcessingException {
        InputStream is = null;
        SAML2Request saml2Request = new SAML2Request();
        if (redirectProfile) {
            try {
                is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
            } catch (Exception e) {
                logger.samlParsingError(e);
                throw logger.parserError(e);
            }
        } else {
            byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
            logger.trace("SAML Request Document: " + new String(samlBytes));
            is = new ByteArrayInputStream(samlBytes);
        }
        return saml2Request.getRequestType(is);
    }
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.api.saml.v2.response.SAML2Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.