java - HowTo send a SAML Request? -


i want send saml request idp (azure ad) ia m not sure how send request @ all.

first used opensaml build authrequest. encoded string.

now wanted use apachehttpclient send request , read response , not sure if opensaml provides http sending methods @ idea use apaches httpclient now.

string encodedauthrequest = generateauthrequest(); string url = "http://myidp/samlendpoint"; closeablehttpclient client = httpclientbuilder.create().build(); httpget request = new httpget(url);  // add request header request.addheader("user-agent", user_agent);  // add else?  httpresponse response = client.execute(request); 

i stuck since not sure how setup request, need query parameter ?saml=.... in or have put encoded saml response in body post..

can or clarify these issue?

update guillaumes answer:

i have idps metadata:

<idpssodescriptor>     <singlesignonservice         binding="urn:oasis:names:tc:saml:2.0:bindings:http-redirect"         location="https://myidp/saml2" />     <singlesignonservice binding="urn:oasis:names:tc:saml:2.0:bindings:http-post"         location="https://myidp/saml2" /> 

depends on binding supposed use. idp documentation or metadata should mention that. there several:

  • redirect binding (using get), far common requests
  • post binding
  • artifact binding (more complex, have never seen used requests)
  • ...

i suppose redirect binding used in case (edit: added metadata idp, mentions can use both redirect , post bindings). described here: https://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf page 15.

short version: must first use deflate algorithm compress xml request, encode using base64, encode using url encoding, pass query parameter named samlrequest

?samlrequest=<your url-encoded base64-encoded deflated authnrequest> 

https://en.wikipedia.org/wiki/saml_2.0#sp_redirect_request.3b_idp_post_response


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -