Package org.jboss.seam.security.external.jaxb.samlv2.protocol

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


     
      public void handleStatusResponseType( SAML2HandlerRequest request,
            SAML2HandlerResponse response ) throws ProcessingException
      {
         //Handler a log out response from IDP
         StatusResponseType statusResponseType = (StatusResponseType) request.getSAML2Object();
        
         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();
         StatusCodeType secondLevelstatusCode = statusCode.getStatusCode();
         if(secondLevelstatusCode.getValue().equals(JBossSAMLURIConstants.STATUS_SUCCESS.get()))
         {
            //we are successfully logged out
View Full Code Here


         String relayState = servletRequest.getParameter("RelayState");
        
         session.invalidate(); //Invalidate the current session at the SP
        
         //Generate a Logout Response
         StatusResponseType statusResponse = objectFactory.createStatusResponseType();
        
         //Status
         StatusType statusType = objectFactory.createStatusType();
         StatusCodeType statusCodeType = objectFactory.createStatusCodeType();
         statusCodeType.setValue(JBossSAMLURIConstants.STATUS_RESPONDER.get());
        
         //2nd level status code
         StatusCodeType status2ndLevel = objectFactory.createStatusCodeType();
         status2ndLevel.setValue(JBossSAMLURIConstants.STATUS_SUCCESS.get());
         statusCodeType.setStatusCode(status2ndLevel);
        
         statusType.setStatusCode(statusCodeType);
        
         statusResponse.setStatus(statusType);
        
         try
         {
            statusResponse.setIssueInstant(XMLTimeUtil.getIssueInstant());
         }
         catch (ConfigurationException e)
         {
            throw new ProcessingException(e);
         }
         statusResponse.setInResponseTo(logOutRequest.getID());
         statusResponse.setID(IDGenerator.create("ID_"));
        
         statusResponse.setIssuer(request.getIssuer());
        
         SAML2Response saml2Response = new SAML2Response();
         try
         {
            response.setResultingDocument(saml2Response.convert(statusResponse));
View Full Code Here

         String destination = null;
         Document samlResponse = null;
        
         if(samlResponseMessage != null)
         {
            StatusResponseType statusResponseType = null;
            try
            {
               samlObject = webRequestUtil.getSAMLObject(samlResponseMessage);
              
               boolean isPost = webRequestUtil.hasSAMLRequestInPostProfile();
               boolean isValid = validate(request.getRemoteAddr(),
                     request.getQueryString(),
                     new SessionHolder(samlResponseMessage, null), isPost);
              
               if(!isValid)
                  throw new GeneralSecurityException("Validation check failed");

               String issuer = null;
               IssuerInfoHolder idpIssuer = new IssuerInfoHolder(this.identityURL);
               ProtocolContext protocolContext = new HTTPContext(request,response, context);
               //Create the request/response
               SAML2HandlerRequest saml2HandlerRequest =
                  new DefaultSAML2HandlerRequest(protocolContext,
                        idpIssuer.getIssuer(), samlObject,
                        HANDLER_TYPE.IDP);
               saml2HandlerRequest.setRelayState(relayState);
              
               Map<String, Object> requestOptions = new HashMap<String, Object>();
               requestOptions.put("ROLE_GENERATOR", rg);
               saml2HandlerRequest.setOptions(requestOptions);
              
               SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();

               Set<SAML2Handler> handlers = chain.handlers();
              
               if(samlObject instanceof StatusResponseType)
               {
                  statusResponseType = (StatusResponseType) samlObject;
                  issuer = statusResponseType.getIssuer().getValue();
                  webRequestUtil.isTrusted(issuer);
                 
                  if(handlers != null)
                  {
                     for(SAML2Handler handler: handlers)
                     {
                        handler.handleStatusResponseType(saml2HandlerRequest, saml2HandlerResponse);
                     }
                  } 
               }
               else
                  throw new RuntimeException("Unknown type:" + samlObject.getClass().getName());

               samlResponse = saml2HandlerResponse.getResultingDocument();
               relayState = saml2HandlerResponse.getRelayState();
              
               destination = saml2HandlerResponse.getDestination();
            }
            catch(Exception e)
            {
               throw new RuntimeException(e);
            }
             
         }
         else
         //Send valid saml response after processing the request
         if(samlRequestMessage != null)
         {
            //Get the SAML Request Message
            RequestAbstractType requestAbstractType =  null;
            StatusResponseType statusResponseType = null;
           
            try
            {
               samlObject = webRequestUtil.getSAMLObject(samlRequestMessage);
              
View Full Code Here

      public void handleStatusResponseType( SAML2HandlerRequest request,
             SAML2HandlerResponse response ) throws ProcessingException
     
         //we got a logout response from a SP
         SAML2Object samlObject = request.getSAML2Object();
         StatusResponseType statusResponseType = (StatusResponseType) samlObject;
        
         HTTPContext httpContext = (HTTPContext) request.getContext();
         HttpServletRequest httpRequest = httpContext.getRequest();
         HttpSession httpSession = httpRequest.getSession(false);
        
         String relayState = request.getRelayState();
        
         ServletContext servletCtx = httpContext.getServletContext();
         IdentityServer server = (IdentityServer)servletCtx.getAttribute("IDENTITY_SERVER");
        
         if(server == null)
            throw new ProcessingException("Identity Server not found");
        
         String sessionID = httpSession.getId();
        
         String statusIssuer = statusResponseType.getIssuer().getValue();
         server.stack().deRegisterTransitParticipant(sessionID, statusIssuer);
        
         String nextParticipant = this.getParticipant(server, sessionID, relayState);
         if(nextParticipant == null || nextParticipant.equals(relayState))
         {
            //we are done with logout
           
            //TODO: check the in transit map for partial logouts

            try
            {
               generateSuccessStatusResponseType(statusResponseType.getInResponseTo(),
                     request, response, relayState);
            }
            catch (Exception e)
            {
               throw new ProcessingException(e);
View Full Code Here

            SAML2HandlerRequest request,
            SAML2HandlerResponse response,
            String originalIssuer)
            throws ConfigurationException, ParserConfigurationException, ProcessingException
      {
         StatusResponseType statusResponse = objectFactory.createStatusResponseType();
        
         //Status
         StatusType statusType = objectFactory.createStatusType();
         StatusCodeType statusCodeType = objectFactory.createStatusCodeType();
         statusCodeType.setValue(JBossSAMLURIConstants.STATUS_RESPONDER.get());
        
         //2nd level status code
         StatusCodeType status2ndLevel = objectFactory.createStatusCodeType();
         status2ndLevel.setValue(JBossSAMLURIConstants.STATUS_SUCCESS.get());
         statusCodeType.setStatusCode(status2ndLevel);
        
         statusType.setStatusCode(statusCodeType);
        
         statusResponse.setStatus(statusType);
        
         statusResponse.setIssueInstant(XMLTimeUtil.getIssueInstant());
         statusResponse.setInResponseTo(logOutRequestID);
         statusResponse.setID(IDGenerator.create("ID_"));
        
         statusResponse.setIssuer(request.getIssuer());
        
         try
         {
            SAML2Response saml2Response = new SAML2Response();
            response.setResultingDocument(saml2Response.convert(statusResponse));
View Full Code Here

         NameIDMappingResponseType nameIDResponseType = (NameIDMappingResponseType) statusResponseType;
         return SAMLProtocolFactory.getObjectFactory().createNameIDMappingResponse(nameIDResponseType);
      }
      else if(statusResponseType instanceof StatusResponseType)
      {
         StatusResponseType srt = (StatusResponseType) statusResponseType;
         return SAMLProtocolFactory.getObjectFactory().createLogoutResponse(srt);
      }
     
      ArtifactResponseType artifactResponse = (ArtifactResponseType) statusResponseType;
      return SAMLProtocolFactory.getObjectFactory().createArtifactResponse(artifactResponse);
View Full Code Here

    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();
        subject.getContent().add(assertionObjectFactory.createNameID(nameID));
        nameID.setValue(session.getPrincipal().getNameId().getValue());
        nameID.setFormat(session.getPrincipal().getNameId().getFormat());
        nameID.setNameQualifier(session.getPrincipal().getNameId().getQualifier());

        SubjectConfirmationType subjectConfirmation = assertionObjectFactory.createSubjectConfirmationType();
        subject.getContent().add(assertionObjectFactory.createSubjectConfirmation(subjectConfirmation));
        subjectConfirmation.setMethod(SamlConstants.CONFIRMATION_METHOD_BEARER);
        subjectConfirmation.setNameID(nameID);

        SubjectConfirmationDataType subjectConfirmationData = assertionObjectFactory.createSubjectConfirmationDataType();
        subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

        subjectConfirmationData.setRecipient(externalSamlEndpoint.getLocation());
        subjectConfirmationData.setNotOnOrAfter(SamlUtils.getXMLGregorianCalendarNowPlusDuration(GregorianCalendar.MINUTE, ASSERTION_VALIDITY_IN_MINUTES));
        subjectConfirmationData.setInResponseTo(samlDialogue.get().getExternalProviderMessageId());

        ConditionsType conditions = assertionObjectFactory.createConditionsType();
        assertion.setConditions(conditions);
        AudienceRestrictionType audienceRestriction = assertionObjectFactory.createAudienceRestrictionType();
        conditions.getConditionOrAudienceRestrictionOrOneTimeUse().add(audienceRestriction);
        audienceRestriction.getAudience().add(samlDialogue.get().getExternalProvider().getEntityId());

        AuthnStatementType authnStatement = assertionObjectFactory.createAuthnStatementType();
        assertion.getStatementOrAuthnStatementOrAuthzDecisionStatement().add(authnStatement);
        authnStatement.setAuthnInstant(SamlUtils.getXMLGregorianCalendarNow());
        authnStatement.setSessionIndex(((SamlIdpSessionImpl) session).getSessionIndex());

        AuthnContextType authnContext = assertionObjectFactory.createAuthnContextType();
        authnStatement.setAuthnContext(authnContext);
View Full Code Here

        session.setPrincipal(principal);
        session.setIdentityProvider(idp);

        for (StatementAbstractType statement : assertion.getStatementOrAuthnStatementOrAuthzDecisionStatement()) {
            if (statement instanceof AttributeStatementType) {
                AttributeStatementType attributeStatement = (AttributeStatementType) statement;
                List<AttributeType> attributes = new LinkedList<AttributeType>();
                for (Object object : attributeStatement.getAttributeOrEncryptedAttribute()) {
                    if (object instanceof AttributeType) {
                        attributes.add((AttributeType) object);
                    } else {
                        log.warn("Encrypted attributes are not supported. Ignoring the attribute.");
                    }
View Full Code Here

        subjectConfirmationData.setNotOnOrAfter(SamlUtils.getXMLGregorianCalendarNowPlusDuration(GregorianCalendar.MINUTE, ASSERTION_VALIDITY_IN_MINUTES));
        subjectConfirmationData.setInResponseTo(samlDialogue.get().getExternalProviderMessageId());

        ConditionsType conditions = assertionObjectFactory.createConditionsType();
        assertion.setConditions(conditions);
        AudienceRestrictionType audienceRestriction = assertionObjectFactory.createAudienceRestrictionType();
        conditions.getConditionOrAudienceRestrictionOrOneTimeUse().add(audienceRestriction);
        audienceRestriction.getAudience().add(samlDialogue.get().getExternalProvider().getEntityId());

        AuthnStatementType authnStatement = assertionObjectFactory.createAuthnStatementType();
        assertion.getStatementOrAuthnStatementOrAuthzDecisionStatement().add(authnStatement);
        authnStatement.setAuthnInstant(SamlUtils.getXMLGregorianCalendarNow());
        authnStatement.setSessionIndex(((SamlIdpSessionImpl) session).getSessionIndex());
View Full Code Here

        AuthnStatementType authnStatement = assertionObjectFactory.createAuthnStatementType();
        assertion.getStatementOrAuthnStatementOrAuthzDecisionStatement().add(authnStatement);
        authnStatement.setAuthnInstant(SamlUtils.getXMLGregorianCalendarNow());
        authnStatement.setSessionIndex(((SamlIdpSessionImpl) session).getSessionIndex());

        AuthnContextType authnContext = assertionObjectFactory.createAuthnContextType();
        authnStatement.setAuthnContext(authnContext);
        authnContext.getContent().add(assertionObjectFactory.createAuthnContextDeclRef(SamlConstants.AC_PASSWORD_PROTECTED_TRANSPORT));

        return response;
    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.security.external.jaxb.samlv2.protocol.StatusResponseType

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.