/** * Please modify this class to meet your needs * This class is not complete */test package com.test.saml.server; import java.util.List; import java.util.logging.Logger; import org.oasis.saml.protocol.ObjectFactory; import org.oasis.saml.protocol.RequestType; import org.oasis.saml.protocol.ResponseType; import org.opensaml.saml1.core.AssertionArtifact; import org.opensaml.saml1.core.Request; import org.opensaml.saml1.core.Response; import org.opensaml.saml1.core.StatusCode; import org.w3c.dom.Document; import org.w3c.dom.Element; import com.test.jaxb.JAXBUtil; import com.test.saml.SAMLUtil; /** * This class was generated by Apache CXF 2.0.6 Wed Oct 29 20:28:25 CDT 2008 * Generated source version: 2.0.6 */ @javax.jws.WebService( name = "SAMLTestServicePortType", serviceName = "SAMLTestService", portName = "SAMLTestServicePort", targetNamespace = "http://server.saml.test.com/SAMLTestService", // wsdlLocation = "file:SAMLTestService.wsdl", endpointInterface = "com.test.saml.server.SAMLTestServicePortType" ) public class SAMLTestServicePortTypeImpl implements SAMLTestServicePortType { private static final Logger LOG = Logger.getLogger(SAMLTestServicePortTypeImpl.class .getName()); private SAMLUtil samlUtil = null; private JAXBUtil jaxbUtil = null; private final static String SUCCESS_ASSERTION_ARTIFACT = "AAGZE1RNQJEFzYNCGAGPjWvtfa2dSKWOfa1QSITYBM2KSL3hh65SDVXZ"; private final static String INVALID_ASSERTION_ARTIFACT = "AAGZE1RNQJEFzYNCGAGPjWvtfa2dSKWOfa1QSITYBM2KSL3hh65SDVXQ"; /* * (non-Javadoc) * * @see com.test.saml.server.samltestservice.SAMLTestServicePortType#samlAssertionRequest(RequestType * request )* */ public ResponseType samlAssertionRequest( RequestType request ) { LOG.info("Executing operation samlAssertionRequest"); try { ObjectFactory factory = new ObjectFactory(); Document requestDocument = jaxbUtil.marshall(factory.createRequest(request)); Request samlRequest = (Request) samlUtil.unmarshall(requestDocument); samlUtil.validate("saml1-schema-validator", samlRequest); samlUtil.validate("saml1-spec-validator", samlRequest); String artifact = getAssertionArtifact(samlRequest); Response samlResponse = createResponse(artifact, samlRequest.getID()); Element responseDocument = samlUtil.marshall(samlResponse); ResponseType response = (ResponseType) jaxbUtil.unmarshall(responseDocument); return response; } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } } private String getAssertionArtifact( Request samlRequest ) { List assertionArtifacts = samlRequest.getAssertionArtifacts(); if (!assertionArtifacts.isEmpty()) { AssertionArtifact assertionArtifact = assertionArtifacts.get(0); return assertionArtifact.getAssertionArtifact(); } return null; } private Response createResponse( String artifact, String requestId ) { Response response = samlUtil.createResponse(requestId); if (artifact.equals(INVALID_ASSERTION_ARTIFACT)) { response.setStatus(samlUtil.createStatus(StatusCode.REQUEST_DENIED)); } else if (artifact.equals(INVALID_ASSERTION_ARTIFACT)) { response.setStatus(samlUtil.createStatus(StatusCode.SUCCESS)); } return response; } public SAMLUtil getSamlUtil() { return this.samlUtil; } public void setSamlUtil( SAMLUtil samlUtil ) { this.samlUtil = samlUtil; } public JAXBUtil getJaxbUtil() { return this.jaxbUtil; } public void setJaxbUtil( JAXBUtil jaxbUtil ) { this.jaxbUtil = jaxbUtil; } }