Examples of ResponseType


Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

    * @throws ConfigurationException
    */
   public static ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, AssertionType assertionType)
   throws ConfigurationException
   {
      ResponseType responseType = SAMLProtocolFactory.getObjectFactory().createResponseType();
      responseType.setVersion(issuerInfo.getSamlVersion());
     
      //ID
      responseType.setID(ID);
     
      //Issuer
      NameIDType issuer = issuerInfo.getIssuer();
      responseType.setIssuer(issuer);
     
      //Status
      String statusCode = issuerInfo.getStatusCode();
      if(statusCode == null)
         throw new IllegalArgumentException("issuerInfo missing status code");
     
      responseType.setStatus(createStatusType(statusCode) );
     
      XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
     
      //IssueInstant
      responseType.setIssueInstant(issueInstant);
      if(assertionType.getIssueInstant() == null)
         assertionType.setIssueInstant(issueInstant);
   
      responseType.getAssertionOrEncryptedAssertion().add(assertionType);
      return responseType;
   }
View Full Code Here

Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

      byte[] base64DecodedResponse = Base64.decode(samlResponse);
      InputStream is = new ByteArrayInputStream(base64DecodedResponse);

      SAML2Response saml2Response = new SAML2Response();

      ResponseType responseType;
      try
      {
         responseType = saml2Response.getResponseType(is);
      }
      catch (ParsingException e)
      {
         throw new RuntimeException(e);
      }
      catch (ConfigurationException e)
      {
         throw new RuntimeException(e);
      }

      StatusType statusType = responseType.getStatus();
      if (statusType == null)
      {
         throw new RuntimeException("Status Type from the IDP is null");
      }

      String statusValue = statusType.getStatusCode().getValue();
      if (JBossSAMLURIConstants.STATUS_SUCCESS.get().equals(statusValue) == false)
      {
         throw new RuntimeException("IDP forbid the user");
      }

      List<Object> assertions = responseType.getAssertionOrEncryptedAssertion();
      if (assertions.size() == 0)
      {
         throw new RuntimeException("IDP response does not contain assertions");
      }

      AuthenticatedUser user = null;

      for (Object assertion : responseType.getAssertionOrEncryptedAssertion())
      {
         if (assertion instanceof AssertionType)
         {
            AuthenticatedUser userInAssertion = handleAssertion((AssertionType) assertion);
            if (user == null)
View Full Code Here

Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

         {
            Fault fault = (Fault) response;
            return new Result(null,fault);
         }
        
         ResponseType responseType = (ResponseType) response;
         AssertionType at = (AssertionType) responseType.getAssertionOrEncryptedAssertion().get(0);
         XACMLAuthzDecisionStatementType xst = (XACMLAuthzDecisionStatementType) at.getStatementOrAuthnStatementOrAuthzDecisionStatement().get(0);
         ResultType rt = xst.getResponse().getResult().get(0);
         DecisionType dt = rt.getDecision();
        
         return new Result(dt,null);
View Full Code Here

Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

      Document samlResponseDocument = null;
     
      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
View Full Code Here

Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

    */
   public Document getErrorResponse(String responseURL, String status,
         String identityURL, boolean supportSignature)
   {
      Document samlResponse = null;
      ResponseType responseType = null;

      SAML2Response saml2Response = new SAML2Response();

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

Examples of org.jboss.identity.federation.saml.v2.protocol.ResponseType

            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");
              
               this.isTrusted(responseType.getIssuer().getValue());
              
               List<Object> assertions = responseType.getAssertionOrEncryptedAssertion();
               if(assertions.size() == 0)
                  throw new IllegalStateException("No assertions in reply from IDP");
              
               Object assertion = assertions.get(0);
               if(assertion instanceof EncryptedElementType)
View Full Code Here

Examples of org.jboss.seam.security.external.jaxb.samlv2.protocol.ResponseType

        return authnRequest;
    }

    public ResponseType createResponse(SamlIdpSession session, SamlEndpoint externalSamlEndpoint) {
        ResponseType response = objectFactory.createResponseType();

        fillStatusResponseFields(response, SamlConstants.STATUS_SUCCESS, null);

        AssertionType assertion = assertionObjectFactory.createAssertionType();
        response.getAssertionOrEncryptedAssertion().add(assertion);

        SubjectType subject = assertionObjectFactory.createSubjectType();
        assertion.setSubject(subject);

        NameIDType nameID = assertionObjectFactory.createNameIDType();
View Full Code Here

Examples of org.jboss.seam.security.external.jaxb.samlv2.protocol.ResponseType

        if (!(statusResponse instanceof ResponseType)) {
            throw new InvalidRequestException("Response does not have type ResponseType");
        }

        ResponseType response = (ResponseType) statusResponse;

        List<Object> assertions = response.getAssertionOrEncryptedAssertion();
        if (assertions.size() == 0) {
            throw new RuntimeException("IDP response does not contain assertions");
        }

        SamlSpSessionImpl session = createSession(response, idp);
View Full Code Here

Examples of org.jboss.seam.security.external.jaxb.samlv2.protocol.ResponseType

      if (!(statusResponse instanceof ResponseType))
      {
         throw new InvalidRequestException("Response does not have type ResponseType");
      }

      ResponseType response = (ResponseType) statusResponse;

      List<Object> assertions = response.getAssertionOrEncryptedAssertion();
      if (assertions.size() == 0)
      {
         throw new RuntimeException("IDP response does not contain assertions");
      }
View Full Code Here

Examples of org.jboss.seam.security.external.jaxb.samlv2.protocol.ResponseType

      return authnRequest;
   }

   public ResponseType createResponse(SamlIdpSession session, SamlEndpoint externalSamlEndpoint)
   {
      ResponseType response = objectFactory.createResponseType();

      fillStatusResponseFields(response, SamlConstants.STATUS_SUCCESS, null);

      AssertionType assertion = assertionObjectFactory.createAssertionType();
      response.getAssertionOrEncryptedAssertion().add(assertion);

      SubjectType subject = assertionObjectFactory.createSubjectType();
      assertion.setSubject(subject);

      NameIDType nameID = assertionObjectFactory.createNameIDType();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.