@Test public void test_introspectAccessToken_invalid() throws AppMisconfigurationException, ServerMisconfigurationException { Mockito.when(restTemplate.postForObject(Matchers.eq(MITREID_INTROSPECT_URL), Matchers.anyMap(), Matchers.anyObject())).thenReturn(INVALID_REST_RESPONSE); IApiTokenContents token = serviceToTest.introspectAccessToken(INVALID_ACCESS_TOKEN); Assert.assertNull(token); }
public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException { String introspectionUrl = propertyManager.getProperty(Properties.MITREID_INTROSPECT_URL); if (introspectionUrl == null || introspectionUrl.isEmpty()) { throw new ServerMisconfigurationException("Unable to load server URL"); } MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("token", accessToken); String validatedToken = null; try { validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class); } catch (RestClientException rce) { messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR); return null; } return parseValidatedToken(validatedToken); }
IntrospectTokenService implements IIntrospectTokenService { public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException { String introspectionUrl = propertyManager.getProperty(Properties.MITREID_INTROSPECT_URL); if (introspectionUrl == null || introspectionUrl.isEmpty()) { throw new ServerMisconfigurationException("Unable to load server URL"); } MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("token", accessToken); String validatedToken = null; try { validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class); } catch (RestClientException rce) { messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR); return null; } return parseValidatedToken(validatedToken); } }
IntrospectTokenService implements IIntrospectTokenService { public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException { String introspectionUrl = propertyManager.getProperty(Properties.MITREID_INTROSPECT_URL); if (introspectionUrl == null || introspectionUrl.isEmpty()) { throw new ServerMisconfigurationException("Unable to load server URL"); } MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("token", accessToken); String validatedToken = null; try { validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class); } catch (RestClientException rce) { messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR); return null; } return parseValidatedToken(validatedToken); }  }
IntrospectTokenService implements IIntrospectTokenService { public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException { String introspectionUrl = propertyManager.getProperty(Properties.MITREID_INTROSPECT_URL); if (introspectionUrl == null || introspectionUrl.isEmpty()) { throw new ServerMisconfigurationException("Unable to load server URL"); } MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("token", accessToken); String validatedToken = null; try { validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class); } catch (RestClientException rce) { messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR); return null; } return parseValidatedToken(validatedToken); }  IApiTokenContents introspectAccessToken(String accessToken); }
IntrospectTokenService implements IIntrospectTokenService { public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException { String introspectionUrl = propertyManager.getProperty(Properties.MITREID_INTROSPECT_URL); if (introspectionUrl == null || introspectionUrl.isEmpty()) { throw new ServerMisconfigurationException("Unable to load server URL"); } MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("token", accessToken); String validatedToken = null; try { validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class); } catch (RestClientException rce) { messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR); return null; } return parseValidatedToken(validatedToken); }  IApiTokenContents introspectAccessToken(String accessToken);  }