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

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


        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


        response.setIssuer(issuer);

        response.setVersion(SamlConstants.VERSION_2_0);
        response.setInResponseTo(samlDialogue.get().getExternalProviderMessageId());

        StatusCodeType statusCodeJaxb = objectFactory.createStatusCodeType();
        statusCodeJaxb.setValue(statusCode);

        StatusType statusType = objectFactory.createStatusType();
        statusType.setStatusCode(statusCodeJaxb);
        if (statusMessage != null) {
            statusType.setStatusMessage(statusMessage);
View Full Code Here

        NameIDType nameIdJaxb = logoutRequest.getNameID();
        SamlNameId samlNameId = new SamlNameIdImpl(nameIdJaxb.getValue(), nameIdJaxb.getFormat(), nameIdJaxb.getNameQualifier());
        removeSessions(samlNameId, idp.getEntityId(), logoutRequest.getSessionIndex());

        StatusResponseType statusResponse = samlMessageFactory.createStatusResponse(SamlConstants.STATUS_SUCCESS, null);

        samlMessageSender.sendResponse(idp, statusResponse, SamlProfile.SINGLE_LOGOUT, httpResponse);

        dialogue.setFinished(true);
    }
View Full Code Here

    private ObjectFactory objectFactory = new ObjectFactory();

    private org.jboss.seam.security.external.jaxb.samlv2.assertion.ObjectFactory assertionObjectFactory = new org.jboss.seam.security.external.jaxb.samlv2.assertion.ObjectFactory();

    public StatusResponseType createStatusResponse(String statusCode, String statusMessage) {
        StatusResponseType response = objectFactory.createStatusResponseType();

        fillStatusResponseFields(response, statusCode, statusMessage);

        return response;
    }
View Full Code Here

        }

        Document document = getDocument(is);
        String issuerEntityId;
        RequestAbstractType samlRequestMessage = null;
        StatusResponseType samlResponseMessage = null;
        if (samlRequestOrResponse.isRequest()) {
            samlRequestMessage = getSamlRequest(document);
            issuerEntityId = samlRequestMessage.getIssuer().getValue();
        } else {
            samlResponseMessage = getSamlResponse(document);
            issuerEntityId = samlResponseMessage.getIssuer().getValue();
        }
        log.debug("Received: " + SamlUtils.getDocumentAsString(document));

        try {
            if (samlRequestOrResponse.isRequest() || samlResponseMessage.getInResponseTo() == null) {
                // Request or unsolicited response

                String destination = samlRequestOrResponse.isRequest() ? samlRequestMessage.getDestination() : samlResponseMessage.getDestination();
                if (!samlEntityBean.get().getServiceURL(service).equals(destination)) {
                    throw new InvalidRequestException("Destination (" + destination + ") is not valid.");
                }

                dialogueManager.beginDialogue();
                samlDialogue.get().setExternalProviderMessageId(samlRequestOrResponse.isRequest() ? samlRequestMessage.getID() : samlResponseMessage.getID());
                SamlExternalEntity externalProvider = samlEntityBean.get().getExternalSamlEntityByEntityId(issuerEntityId);
                if (externalProvider == null) {
                    throw new InvalidRequestException("Received message from unknown entity id " + issuerEntityId);
                }
                samlDialogue.get().setExternalProvider(externalProvider);
            } else {
                String dialogueId = samlResponseMessage.getInResponseTo();
                if (!dialogueManager.isExistingDialogue(dialogueId)) {
                    throw new InvalidRequestException("No request that corresponds with the received response");
                }

                dialogueManager.attachDialogue(dialogueId);
View Full Code Here

    private StatusResponseType getSamlResponse(Document document) throws InvalidRequestException {
        try {
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            @SuppressWarnings("unchecked")
            JAXBElement<StatusResponseType> jaxbResponseType = (JAXBElement<StatusResponseType>) unmarshaller.unmarshal(document);
            StatusResponseType statusResponse = jaxbResponseType.getValue();
            return statusResponse;
        } catch (JAXBException e) {
            throw new InvalidRequestException("SAML message could not be parsed", e);
        }
    }
View Full Code Here

    public void handleSucceededAuthentication(SamlIdpSession session, HttpServletResponse response) {
        sendAuthenticationResponse(samlDialogue.getExternalProvider(), session, false, response);
    }

    private void sendAuthenticationResponse(SamlExternalEntity serviceProvider, SamlIdpSession session, boolean failed, HttpServletResponse response) {
        StatusResponseType statusResponse;

        if (failed) {
            statusResponse = samlMessageFactory.createStatusResponse(SamlConstants.STATUS_RESPONDER, null);
        } else {
            SamlService service = serviceProvider.getService(SamlProfile.SINGLE_SIGN_ON);
View Full Code Here

    }

    private void finishSingleLogoutProcess(HttpServletResponse response) {
        boolean failed = samlIdpIncomingLogoutDialogue.get().isFailed();
        if (samlDialogue.get().getExternalProvider() != null) {
            StatusResponseType statusResponse = samlMessageFactory.createStatusResponse(failed ? SamlConstants.STATUS_RESPONDER : SamlConstants.STATUS_SUCCESS, null);
            samlMessageSender.sendResponse(samlDialogue.get().getExternalProvider(), statusResponse, SamlProfile.SINGLE_LOGOUT, response);
        } else {
            if (failed) {
                samlIdentityProviderSpi.get().globalLogoutFailed(responseHandler.createResponseHolder(response));
            } else {
View Full Code Here

      sendAuthenticationResponse(samlDialogue.getExternalProvider(), session, false, response);
   }

   private void sendAuthenticationResponse(SamlExternalEntity serviceProvider, SamlIdpSession session, boolean failed, HttpServletResponse response)
   {
      StatusResponseType statusResponse;

      if (failed)
      {
         statusResponse = samlMessageFactory.createStatusResponse(SamlConstants.STATUS_RESPONDER, null);
      }
View Full Code Here

            }
        }
    }

    public void processIDPResponse(HttpServletRequest httpRequest, HttpServletResponse httpResponse, StatusResponseType statusResponse) {
        StatusType status = statusResponse.getStatus();
        if (status.getStatusCode().getValue().equals(SamlConstants.STATUS_SUCCESS)) {
            samlServiceProviderSpi.get().globalLogoutSucceeded(responseHandler.createResponseHolder(httpResponse));
        } else {
            String statusCodeLevel1 = status.getStatusCode().getValue();
            String statusCodeLevel2 = null;
            if (status.getStatusCode().getStatusCode() != null) {
                statusCodeLevel2 = status.getStatusCode().getStatusCode().getValue();
            }
            samlServiceProviderSpi.get().globalLogoutFailed(statusCodeLevel1, statusCodeLevel2, responseHandler.createResponseHolder(httpResponse));
        }
        dialogue.setFinished(true);
    }
View Full Code Here

TOP

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

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.