protected String getRTResponse(URI uri, RefreshToken refreshToken, Client client) { HashMap map = new HashMap(); map.put(OA2Constants.GRANT_TYPE, OA2Constants.REFRESH_TOKEN); map.put(OA2Constants.REFRESH_TOKEN, refreshToken.getToken()); map.put(OA2Constants.CLIENT_ID, client.getIdentifierString()); map.put(OA2Constants.CLIENT_SECRET, client.getSecret()); map.put(OA2Constants.SCOPE, "edu.uiuc.ncsa.myproxy"); String response = getServiceClient().getRawResponse(map); return response; }
public String getRawResponse(Map m) { return getRawResponse(convertToStringRequest(host().toString(), m)); }
/** * Gets asset * * @param client Client ID * @param props Map of properties * @param accessToken Access token * @return asset */ protected PAResponse getAsset(Client client, Map props, AccessToken accessToken) { HashMap m = new HashMap(); m.put(OA2Constants.ACCESS_TOKEN, accessToken.getToken().toString()); m.put(OA2Constants.CLIENT_ID, client.getIdentifierString()); m.put(OA2Constants.CLIENT_SECRET, client.getSecret()); m.put(OA2Constants.REDIRECT_URI, props.get(OA2Constants.REDIRECT_URI)); m.put(OA2Constants.CERT_REQ, String.valueOf(props.get(AbstractClientEnvironment.CERT_REQUEST_KEY))); m.put(OA2Constants.CERT_LIFETIME, String.valueOf(props.get(AbstractClientEnvironment.CERT_LIFETIME_KEY))); String response = getServiceClient().getRawResponse(m); // No JSON in the spec. Just a string of certs. MyX509Certificates myX509Certificate = null; try { myX509Certificate = new MyX509Certificates(CertUtil.fromX509PEM(response)); } catch (CertificateException e) { e.printStackTrace(); } PAResponse par = new PAResponse(myX509Certificate); return par; } }
public static JSONWebKeys getJsonWebKeys(ServiceClient serviceClient, String wellKnown) { if(serviceClient == null){ throw new GeneralException("Error: Missing service client."); } if(wellKnown == null || wellKnown.isEmpty()){ throw new GeneralException("Error: missing well known URI. Cannot get keys"); } // Fix for OAUTH-164, id_token support follows. String rawResponse = serviceClient.getRawResponse(wellKnown); JSON rawJSON = JSONSerializer.toJSON(rawResponse); if (!(rawJSON instanceof JSONObject)) { throw new IllegalStateException("Error: Attempted to get JSON Object but returned result is not JSON"); } JSONObject json = (JSONObject) rawJSON; String rawKeys = serviceClient.getRawResponse(json.getString("jwks_uri")); JSONWebKeys keys = null; JSONObject claims = null; try { keys = JSONWebKeyUtil.fromJSON(rawKeys); } catch (Throwable e) { throw new GeneralException("Error getting keys", e); } return keys; } /** Strictly for testing.
/** * Processes UserInfo request * * @param uiRequest User info request * @return User Info response */ public UIResponse processUIRequest(UIRequest uiRequest) { HashMap m = new HashMap(); m.put(OA2Constants.ACCESS_TOKEN, uiRequest.getAccessToken().getToken()); String response = getServiceClient().getRawResponse(m); return new UIResponse(uiRequest.getAccessToken(), response); } }
m.put(OA2Constants.NONCE, nonce); m.put(OA2Constants.PROMPT, OA2Constants.PROMPT_LOGIN); String responseString = getServiceClient().getRawResponse(m);
@Override public void doIt() throws Exception { HashMap<String, String> map = new HashMap<>(); map.put(AbstractServlet.PING_PARAMETER, ""); info("Making initial request to service at " + serviceClient.host()); try { // Quick comment: In the service client, a response with HTML status code of 204 (status=ok, no body) is // processed and if correct, returns a raw response of length zero. If another code occurs and there is // no body, then an exception is raised. This is why the check below is the right one for the current case. String response = serviceClient.getRawResponse(map); if (response.length() == 0) { // then all is ok. Maybe do some logging info("ping ok"); } else { // moar logging warn("Ping failed to server " + serviceClient.host() + ". This ping works against servers that are version 3.0 or higher."); System.exit(1); } } catch (Throwable t) { error("ping failed to server " + serviceClient.host(), t); System.exit(1); } // From here on down is the older version for servers that do not support the ping command. }
String response = getServiceClient().getRawResponse(m); JSONObject jsonObject = getAndCheckResponse(response); if (!jsonObject.containsKey(ACCESS_TOKEN)) {