@Test (expected= APIAccessDeniedException.class) public void processArtifactBindingInvalidRequest() { setRealm(false); HttpServletRequest request = Mockito.mock(HttpServletRequest.class); UriInfo uriInfo = Mockito.mock(UriInfo.class); Mockito.when(request.getParameter("RelayState")).thenReturn("My Realm"); resource.processArtifactBinding(request, uriInfo); }
@GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } }
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }  }
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }  @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); }
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }  @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); static SimpleDateFormat ft; }