Guest User

Untitled

a guest
Dec 7th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. curl --request POST --header "X-OpenAM-Username: demo"
  2. --header "X-OpenAM-Password: changeit"
  3. --header "Content-Type: application/json"
  4. "http://openam.example.com:8080/sso/json/authenticate"
  5.  
  6. {"tokenId":"AQIC5wM2LY4SfcyTReB5nbrLt3QaH-7GhPuU2-uK2k5tJsA.*AAJTSQACMDEAAlNLABMyOTUxODgxODAwOTE0MTA4NDE3*","successUrl":"/sso/console"}
  7.  
  8. curl --request POST
  9. --header "Content-Type: application/json"
  10. "http://openam.example.com:8080/sso/json/sessions/AQIC5wM2LY4SfczadxSebQWi9UEyd2ZDnz_io0Pe6NDgMhY.*AAJTSQACMDEAAlNLABM3MTMzMTYwMzM1NjE4NTE4NTMx*?_action=validate"
  11.  
  12. {"valid":true,"uid":"demo","realm":"/"}
  13.  
  14. curl --request GET
  15. --header "iPlanetDirectoryPro: AQIC5wM2LY4SfczadxSebQWi9UEyd2ZDnz_io0Pe6NDgMhY.*AAJTSQACMDEAAlNLABM3MTMzMTYwMzM1NjE4NTE4NTMx*"
  16. "http://openam.example.com:8080/sso/json/users/demo"
  17.  
  18. {"username":"demo","realm":"/","uid":["demo"],"userPassword":["{SSHA}cIgTNGHWd4t4Ff3SHa6a9pjMyn/Z3e3EOp5mrA=="],"sn":["demo"],"createTimestamp":["20160406210602Z"],"cn":["demo"],"givenName":["demo"],"inetUserStatus":["Active"],"dn":["uid=demo,ou=people,dc=example,dc=com"],"objectClass":["devicePrintProfilesContainer","person","sunIdentityServerLibertyPPService","inetorgperson","sunFederationManagerDataStore","iPlanetPreferences","iplanet-am-auth-configuration-service","organizationalperson","sunFMSAML2NameIdentifier","oathUser","inetuser","forgerock-am-dashboard-service","iplanet-am-managed-person","iplanet-am-user-service","sunAMAuthAccountLockout","top"],"universalid":["id=demo,ou=user,dc=openamcfg,dc=example,dc=com"]}
  19.  
  20. curl --request POST
  21. --header "iplanetdirectorypro: AQIC5wM2LY4SfczUFNs-TJwFrCVAKgR0NulIAyNaIkQmjis.*AAJTSQACMDEA
  22. AlNLABQtNTQ3NDE2Njc5ODk4MjYzMzA2MQ..*"
  23. --header "Content-Type: application/json"
  24. http://openam.example.com:8080/openam/json/users?_action=idFromSession
  25.  
  26. String httpsURL = "https://openam.example.com:8080/openam/json/users?_action=idFromSession";
  27. URL url = new URL(httpsURL);
  28. HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
  29.  
  30. //add request headers
  31. con.setRequestMethod("POST");
  32. con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0");
  33. con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  34. con.setRequestProperty("Content-Type", "application/json");
  35.  
  36. // Add session token as header
  37. con.setRequestProperty("iplanetdirectorypro", "AQIC5wM2LY4SfczUFNs-TJwFrCVAKgR0NulIAyNaIkQmjis.*AAJTSQACMDEA
  38. AlNLABQtNTQ3NDE2Njc5ODk4MjYzMzA2MQ..*");
  39.  
  40. // Send post request
  41. con.setDoOutput(true);
  42. // Read output
  43. BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  44.  
  45. Response fieldResponse = given().auth().oauth2( oAuthLogin.getToken())
  46. .config(new RestAssuredConfig().
  47. decoderConfig(
  48. new DecoderConfig("UTF-8")
  49. ).encoderConfig(
  50. new EncoderConfig("UTF-8", "UTF-8")
  51. ))
  52. .header("iplanetDirectoryPro", oAuthLogin.getToken())
  53. .header("Content-Type", "application/json")
  54. // .contentType("application/json")
  55. .body(myRequest).with()
  56. .when()
  57. .post(dataPostUrl)
  58. .then()
  59. .assertThat()
  60. .log().ifError()
  61. .statusCode(200)
  62. .extract().response();
Add Comment
Please, Sign In to add comment