gluu
公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開変数類 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest クラス
org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest の継承関係図
Inheritance graph
org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest 連携図
Collaboration graph

公開メンバ関数

void omittedTokenEndpointAuthMethodStep1 (final String registerPath, final String redirectUris) throws Exception
 
void omittedTokenEndpointAuthMethodStep2 (final String registerPath) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicStep1 (final String registerPath, final String redirectUris) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicStep2 (final String registerPath) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicStep3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicStep4 (final String tokenPath, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicFail1 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicFail2 (final String tokenPath, final String audience, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretBasicFail3 (final String tokenPath, final String userId, final String userSecret, final String audience, final String keyId, final String keyStoreFile, final String keyStoreSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostStep1 (final String registerPath, final String redirectUris) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostStep2 (final String registerPath) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostStep3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostStep4 (final String tokenPath, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostFail1 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostFail2 (final String tokenPath, final String audience, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretPostFail3 (final String tokenPath, final String userId, final String userSecret, final String audience, final String keyId, final String keyStoreFile, final String keyStoreSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtStep1 (final String registerPath, final String redirectUris) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtStep2 (final String registerPath) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtStep3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtStep4 (final String tokenPath, final String redirectUri, final String audience, final String keyId, final String dnName, final String keyStoreFile, final String keyStoreSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtFail1 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtFail2 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodClientSecretJwtFail3 (final String tokenPath, final String userId, final String userSecret, final String audience, final String keyId, final String keyStoreFile, final String keyStoreSecret) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtStep1 (final String registerPath, final String redirectUris, final String jwksUri) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtStep2 (final String registerPath) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtStep3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtStep4 (final String tokenPath, final String redirectUri, final String audience, final String keyId, final String keyStoreFile, final String keyStoreSecret) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtFail1 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtFail2 (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void tokenEndpointAuthMethodPrivateKeyJwtFail3 (final String tokenPath, final String audience, final String userId, final String userSecret) throws Exception
 
void initTestSuite (ITestContext context) throws FileNotFoundException, IOException
 
WebDriver getDriver ()
 
void setDriver (WebDriver driver)
 
String getAuthorizationEndpoint ()
 
void setAuthorizationEndpoint (String authorizationEndpoint)
 
String getTokenEndpoint ()
 
void setTokenEndpoint (String tokenEndpoint)
 
String getUserInfoEndpoint ()
 
void setUserInfoEndpoint (String userInfoEndpoint)
 
String getClientInfoEndpoint ()
 
void setClientInfoEndpoint (String clientInfoEndpoint)
 
String getCheckSessionIFrame ()
 
void setCheckSessionIFrame (String checkSessionIFrame)
 
String getEndSessionEndpoint ()
 
void setEndSessionEndpoint (String endSessionEndpoint)
 
String getJwksUri ()
 
void setJwksUri (String jwksUri)
 
String getRegistrationEndpoint ()
 
void setRegistrationEndpoint (String registrationEndpoint)
 
String getIntrospectionEndpoint ()
 
void setIntrospectionEndpoint (String p_introspectionEndpoint)
 
Map< String, List< String > > getScopeToClaimsMapping ()
 
void setScopeToClaimsMapping (Map< String, List< String >> p_scopeToClaimsMapping)
 
String getIdGenEndpoint ()
 
void setIdGenEndpoint (String p_idGenEndpoint)
 
String getConfigurationEndpoint ()
 
void setConfigurationEndpoint (String configurationEndpoint)
 
void startSelenium ()
 
void stopSelenium ()
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies, boolean useNewDriver)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies, boolean useNewDriver, int authzSteps)
 
AuthorizationResponse authenticateResourceOwnerAndDenyAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
 
AuthorizationResponse authorizationRequestAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
AuthorizationResponse authorizationRequestAndDenyAccess (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
AuthorizationResponse authenticateResourceOwner (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies)
 
String waitForResourceOwnerAndGrantLoginForm (String authorizeUrl, AuthorizationRequest authorizationRequest, boolean cleanupCookies)
 
String waitForResourceOwnerAndGrantLoginForm (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
void discovery (ITestContext context) throws Exception
 
void showTitle (String title)
 
void showTitle (String title)
 
void showEntity (String entity)
 
void showResponse (String title, Response response)
 

静的公開メンバ関数

static void showClient (BaseClient client)
 
static void showClient (BaseClient client, CookieStore cookieStore)
 
static void showClientUserAgent (BaseClient client)
 
static void assertErrorResponse (BaseResponseWithErrors p_response, IErrorType p_errorType)
 
static DefaultHttpClient createHttpClient ()
 
static DefaultHttpClient createHttpClient (HostnameVerifierType p_verifierType)
 
static ClientExecutor clientExecutor () throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static ClientExecutor clientExecutor (boolean trustAll) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static HttpClient createHttpClientTrustAll () throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static void showResponse (String title, Response response, Object entity)
 
static void fails (Throwable e)
 
static void output (String p_msg)
 
static Archive<?> createDeployment ()
 

静的公開変数類

static FileConfiguration testData
 

限定公開変数類

WebDriver driver
 
String authorizationEndpoint
 
String authorizationPageEndpoint
 
String gluuConfigurationEndpoint
 
String tokenEndpoint
 
String userInfoEndpoint
 
String clientInfoEndpoint
 
String checkSessionIFrame
 
String endSessionEndpoint
 
String jwksUri
 
String registrationEndpoint
 
String configurationEndpoint
 
String idGenEndpoint
 
String introspectionEndpoint
 
Map< String, List< String > > scopeToClaimsMapping
 

非公開変数類

URI url
 

静的非公開変数類

static String clientId1
 
static String registrationAccessToken1
 
static String registrationClientUri1
 
static String clientId2
 
static String clientSecret2
 
static String registrationAccessToken2
 
static String authorizationCode2
 
static String registrationClientUri2
 
static String clientId3
 
static String clientSecret3
 
static String registrationAccessToken3
 
static String authorizationCode3
 
static String registrationClientUri3
 
static String clientId4
 
static String clientSecret4
 
static String registrationAccessToken4
 
static String authorizationCode4
 
static String registrationClientUri4
 
static String clientId5
 
static String clientSecret5
 
static String registrationAccessToken5
 
static String authorizationCode5
 
static String registrationClientUri5
 

詳解

著者
Javier Rojas Blum
バージョン
November 29, 2017

関数詳解

◆ assertErrorResponse()

static void org.xdi.oxauth.BaseTest.assertErrorResponse ( BaseResponseWithErrors  p_response,
IErrorType  p_errorType 
)
inlinestaticinherited
787  {
788  assertEquals(p_response.getStatus(), 400, "Unexpected response code. Entity: " + p_response.getEntity());
789  assertNotNull(p_response.getEntity(), "The entity is null");
790  assertEquals(p_response.getErrorType(), p_errorType);
791  assertTrue(StringUtils.isNotBlank(p_response.getErrorDescription()));
792  }
T getErrorType()
Definition: BaseResponseWithErrors.java:48
String getEntity()
Definition: BaseResponse.java:85
int getStatus()
Definition: BaseResponse.java:49
String getErrorDescription()
Definition: BaseResponseWithErrors.java:40

◆ authenticateResourceOwner()

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwner ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) No authorization page.

556  {
557  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
558 
559  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
560  authorizeClient.setRequest(authorizationRequest);
561 
562  System.out.println("authenticateResourceOwner: authorizationRequestUrl:" + authorizationRequestUrl);
563  startSelenium();
564  if (cleanupCookies) {
565  System.out.println("authenticateResourceOwner: Cleaning cookies");
567  }
568 // try {
569  driver.navigate().to(authorizationRequestUrl);
570 // } catch (WebDriverException ex) {
571 // if (ex.getCause() instanceof ScriptException) {
572 // System.out.println("authenticateResourceOwner: Script error: " + ex.getMessage());
573 // } else {
574 // throw ex;
575 // }
576 // }
577 
578  if (userSecret != null) {
579  if (userId != null) {
580  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
581  usernameElement.sendKeys(userId);
582  }
583 
584  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
585  passwordElement.sendKeys(userSecret);
586 
587  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
588 
589  loginButton.click();
590  }
591 
592  String authorizationResponseStr = driver.getCurrentUrl();
593 
594  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
595  String sessionState = null;
596  if (sessionStateCookie != null) {
597  sessionState = sessionStateCookie.getValue();
598  }
599  System.out.println("authenticateResourceOwner: sessionState:" + sessionState);
600 
601  stopSelenium();
602 
603  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
604  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
605  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
606  }
607  authorizeClient.setResponse(authorizationResponse);
608  showClientUserAgent(authorizeClient);
609 
610  return authorizationResponse;
611  }
FORM_POST
Definition: ResponseMode.java:33
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void deleteAllCookies()
Definition: BaseTest.java:661
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authenticateResourceOwnerAndDenyAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndDenyAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret 
)
inlineinherited
408  {
409  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
410 
411  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
412  authorizeClient.setRequest(authorizationRequest);
413 
414  System.out.println("authenticateResourceOwnerAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
415  startSelenium();
416  driver.navigate().to(authorizationRequestUrl);
417 
418  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
419  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
420  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
421 
422  if (userId != null) {
423  usernameElement.sendKeys(userId);
424  }
425  passwordElement.sendKeys(userSecret);
426  loginButton.click();
427 
428  String authorizationResponseStr = driver.getCurrentUrl();
429 
430  WebElement doNotAllowButton = driver.findElement(By.id(authorizeFormDoNotAllowButton));
431 
432  final String previousURL = driver.getCurrentUrl();
433  doNotAllowButton.click();
434  WebDriverWait wait = new WebDriverWait(driver, 10);
435  wait.until(new ExpectedCondition<Boolean>() {
436  public Boolean apply(WebDriver d) {
437  return (d.getCurrentUrl() != previousURL);
438  }
439  });
440 
441  authorizationResponseStr = driver.getCurrentUrl();
442 
443  Cookie sessionIdCookie = driver.manage().getCookieNamed("session_id");
444  String sessionId = null;
445  if (sessionIdCookie != null) {
446  sessionId = sessionIdCookie.getValue();
447  }
448  System.out.println("authenticateResourceOwnerAndDenyAccess: sessionId:" + sessionId);
449 
450  stopSelenium();
451 
452  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
453  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
454  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
455  }
456  authorizationResponse.setSessionId(sessionId);
457  authorizeClient.setResponse(authorizationResponse);
458  showClientUserAgent(authorizeClient);
459 
460  return authorizationResponse;
461  }
FORM_POST
Definition: ResponseMode.java:33
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void stopSelenium()
Definition: BaseTest.java:243
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
void setSessionId(String p_sessionId)
Definition: AuthorizationResponse.java:212
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authenticateResourceOwnerAndGrantAccess() [1/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

253  {
254  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, true);
255  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [2/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

262  {
263  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, cleanupCookies, false);
264  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [3/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies,
boolean  useNewDriver 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

272  {
273  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, cleanupCookies, useNewDriver, 1);
274  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [4/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies,
boolean  useNewDriver,
int  authzSteps 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

282  {
283  WebDriver currentDriver = initWebDriver(useNewDriver, cleanupCookies);
284 
285  AuthorizeClient authorizeClient = processAuthentication(currentDriver, authorizeUrl, authorizationRequest,
286  userId, userSecret);
287 
288  int remainAuthzSteps = authzSteps;
289 
290  String authorizationResponseStr = null;
291  do {
292  authorizationResponseStr = acceptAuthorization(currentDriver);
293  remainAuthzSteps--;
294  } while (remainAuthzSteps >= 1);
295 
296  AuthorizationResponse authorizationResponse = buildAuthorizationResponse(authorizationRequest, useNewDriver,
297  currentDriver, authorizeClient, authorizationResponseStr);
298 
299  stopWebDriver(useNewDriver, currentDriver);
300 
301  return authorizationResponse;
302  }
AuthorizationResponse buildAuthorizationResponse(AuthorizationRequest authorizationRequest, boolean useNewDriver, WebDriver currentDriver, AuthorizeClient authorizeClient, String authorizationResponseStr)
Definition: BaseTest.java:387
String acceptAuthorization(WebDriver currentDriver)
Definition: BaseTest.java:358
AuthorizeClient processAuthentication(WebDriver currentDriver, String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:330
Definition: AuthorizeClient.java:29
WebDriver initWebDriver(boolean useNewDriver, boolean cleanupCookies)
Definition: BaseTest.java:304
Definition: AuthorizationResponse.java:32
void stopWebDriver(boolean useNewDriver, WebDriver currentDriver)
Definition: BaseTest.java:321

◆ authorizationRequestAndDenyAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authorizationRequestAndDenyAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited
509  {
510  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
511 
512  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
513  authorizeClient.setRequest(authorizationRequest);
514 
515  System.out.println("authorizationRequestAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
516  startSelenium();
517  driver.navigate().to(authorizationRequestUrl);
518 
519  WebElement doNotAllowButton = driver.findElement(By.id(authorizeFormDoNotAllowButton));
520 
521  final String previousURL = driver.getCurrentUrl();
522  doNotAllowButton.click();
523  WebDriverWait wait = new WebDriverWait(driver, 10);
524  wait.until(new ExpectedCondition<Boolean>() {
525  public Boolean apply(WebDriver d) {
526  return (d.getCurrentUrl() != previousURL);
527  }
528  });
529 
530  String authorizationResponseStr = driver.getCurrentUrl();
531 
532  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
533  String sessionState = null;
534  if (sessionStateCookie != null) {
535  sessionState = sessionStateCookie.getValue();
536  }
537  System.out.println("authorizationRequestAndDenyAccess: sessionState:" + sessionState);
538 
539  stopSelenium();
540 
541  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
542  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
543  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
544  }
545  authorizeClient.setResponse(authorizationResponse);
546  showClientUserAgent(authorizeClient);
547 
548  return authorizationResponse;
549  }
FORM_POST
Definition: ResponseMode.java:33
void stopSelenium()
Definition: BaseTest.java:243
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authorizationRequestAndGrantAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authorizationRequestAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited
464  {
465  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
466 
467  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
468  authorizeClient.setRequest(authorizationRequest);
469 
470  System.out.println("authorizationRequestAndGrantAccess: authorizationRequestUrl:" + authorizationRequestUrl);
471  startSelenium();
472  driver.navigate().to(authorizationRequestUrl);
473 
474  String authorizationResponseStr = driver.getCurrentUrl();
475 
476  WebElement allowButton = driver.findElement(By.id(authorizeFormAllowButton));
477 
478  final String previousURL = driver.getCurrentUrl();
479  allowButton.click();
480  WebDriverWait wait = new WebDriverWait(driver, 10);
481  wait.until(new ExpectedCondition<Boolean>() {
482  public Boolean apply(WebDriver d) {
483  return (d.getCurrentUrl() != previousURL);
484  }
485  });
486 
487  authorizationResponseStr = driver.getCurrentUrl();
488 
489  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
490  String sessionState = null;
491  if (sessionStateCookie != null) {
492  sessionState = sessionStateCookie.getValue();
493  }
494  System.out.println("authorizationRequestAndGrantAccess: sessionState:" + sessionState);
495 
496  stopSelenium();
497 
498  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
499  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
500  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
501  }
502  authorizeClient.setResponse(authorizationResponse);
503  showClientUserAgent(authorizeClient);
504 
505  return authorizationResponse;
506  }
FORM_POST
Definition: ResponseMode.java:33
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783
String authorizeFormAllowButton
Definition: BaseTest.java:91

◆ clientExecutor() [1/2]

static ClientExecutor org.xdi.oxauth.BaseTest.clientExecutor ( ) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
822  {
823  return clientExecutor(false);
824  }
static ClientExecutor clientExecutor()
Definition: BaseTest.java:822

◆ clientExecutor() [2/2]

static ClientExecutor org.xdi.oxauth.BaseTest.clientExecutor ( boolean  trustAll) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
826  {
827  if (trustAll) {
828  return new ApacheHttpClient4Executor(createHttpClientTrustAll());
829  }
830  return ClientRequest.getDefaultExecutor();
831  }
static HttpClient createHttpClientTrustAll()
Definition: BaseTest.java:833

◆ createDeployment()

static Archive<?> org.xdi.oxauth.ConfigurableTest.createDeployment ( )
inlinestaticinherited
40  {
41  return Deployments.createDeployment();
42  }

◆ createHttpClient() [1/2]

static DefaultHttpClient org.xdi.oxauth.BaseTest.createHttpClient ( )
inlinestaticinherited
794  {
795  return createHttpClient(HostnameVerifierType.DEFAULT);
796  }
static DefaultHttpClient createHttpClient()
Definition: BaseTest.java:794

◆ createHttpClient() [2/2]

static DefaultHttpClient org.xdi.oxauth.BaseTest.createHttpClient ( HostnameVerifierType  p_verifierType)
inlinestaticinherited
798  {
799  if (p_verifierType != null && p_verifierType != HostnameVerifierType.DEFAULT) {
800  switch (p_verifierType) {
801  case ALLOW_ALL:
802  HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
803 
804  DefaultHttpClient client = new DefaultHttpClient();
805 
806  SchemeRegistry registry = new SchemeRegistry();
807  SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
808  socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
809  registry.register(new Scheme("https", socketFactory, 443));
810  SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
811 
812  // Set verifier
813  HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
814  return new DefaultHttpClient(mgr, client.getParams());
815  case DEFAULT:
816  return new DefaultHttpClient();
817  }
818  }
819  return new DefaultHttpClient();
820  }

◆ createHttpClientTrustAll()

static HttpClient org.xdi.oxauth.BaseTest.createHttpClientTrustAll ( ) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
833  {
834  SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
835  @Override
836  public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
837  return true;
838  }
839  }, new AllowAllHostnameVerifier());
840 
841  SchemeRegistry registry = new SchemeRegistry();
842  registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
843  registry.register(new Scheme("https", 443, sf));
844  ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
845  return new DefaultHttpClient(ccm);
846  }

◆ discovery()

void org.xdi.oxauth.BaseTest.discovery ( ITestContext  context) throws Exception
inlineinherited
670  {
671  // Load Form Interaction
672  loginFormUsername = context.getCurrentXmlTest().getParameter("loginFormUsername");
673  loginFormPassword = context.getCurrentXmlTest().getParameter("loginFormPassword");
674  loginFormLoginButton = context.getCurrentXmlTest().getParameter("loginFormLoginButton");
675  authorizeFormAllowButton = context.getCurrentXmlTest().getParameter("authorizeFormAllowButton");
676  authorizeFormDoNotAllowButton = context.getCurrentXmlTest().getParameter("authorizeFormDoNotAllowButton");
677 
678  String resource = context.getCurrentXmlTest().getParameter("swdResource");
679 
680  if (StringUtils.isNotBlank(resource)) {
681 
682  showTitle("OpenID Connect Discovery");
683 
684  OpenIdConnectDiscoveryClient openIdConnectDiscoveryClient = new OpenIdConnectDiscoveryClient(resource);
685  OpenIdConnectDiscoveryResponse openIdConnectDiscoveryResponse = openIdConnectDiscoveryClient.exec(clientExecutor(true));
686 
687  showClient(openIdConnectDiscoveryClient);
688  assertEquals(openIdConnectDiscoveryResponse.getStatus(), 200, "Unexpected response code");
689  assertNotNull(openIdConnectDiscoveryResponse.getSubject());
690  assertTrue(openIdConnectDiscoveryResponse.getLinks().size() > 0);
691 
692  configurationEndpoint = openIdConnectDiscoveryResponse.getLinks().get(0).getHref() +
693  "/.well-known/openid-configuration";
694 
695  System.out.println("OpenID Connect Configuration");
696 
697  OpenIdConfigurationClient client = new OpenIdConfigurationClient(configurationEndpoint);
698  client.setExecutor(clientExecutor(true));
700 
701  showClient(client);
702  assertEquals(response.getStatus(), 200, "Unexpected response code");
703  assertNotNull(response.getIssuer(), "The issuer is null");
704  assertNotNull(response.getAuthorizationEndpoint(), "The authorizationEndpoint is null");
705  assertNotNull(response.getTokenEndpoint(), "The tokenEndpoint is null");
706  assertNotNull(response.getUserInfoEndpoint(), "The userInfoEndPoint is null");
707  assertNotNull(response.getJwksUri(), "The jwksUri is null");
708  assertNotNull(response.getRegistrationEndpoint(), "The registrationEndpoint is null");
709 
710  assertTrue(response.getScopesSupported().size() > 0, "The scopesSupported is empty");
711  assertTrue(response.getScopeToClaimsMapping().size() > 0, "The scope to claims mapping is empty");
712  assertTrue(response.getResponseTypesSupported().size() > 0, "The responseTypesSupported is empty");
713  assertTrue(response.getGrantTypesSupported().size() > 0, "The grantTypesSupported is empty");
714  assertTrue(response.getAcrValuesSupported().size() >= 0, "The acrValuesSupported is empty");
715  assertTrue(response.getSubjectTypesSupported().size() > 0, "The subjectTypesSupported is empty");
716  assertTrue(response.getIdTokenSigningAlgValuesSupported().size() > 0, "The idTokenSigningAlgValuesSupported is empty");
717  assertTrue(response.getRequestObjectSigningAlgValuesSupported().size() > 0, "The requestObjectSigningAlgValuesSupported is empty");
718  assertTrue(response.getTokenEndpointAuthMethodsSupported().size() > 0, "The tokenEndpointAuthMethodsSupported is empty");
719  assertTrue(response.getClaimsSupported().size() > 0, "The claimsSupported is empty");
720 
722  tokenEndpoint = response.getTokenEndpoint();
727  jwksUri = response.getJwksUri();
732  gluuConfigurationEndpoint = determineGluuConfigurationEndpoint(openIdConnectDiscoveryResponse.getLinks().get(0).getHref());
733  } else {
734  showTitle("Loading configuration endpoints from properties file");
735 
736  authorizationEndpoint = context.getCurrentXmlTest().getParameter("authorizationEndpoint");
737  tokenEndpoint = context.getCurrentXmlTest().getParameter("tokenEndpoint");
738  userInfoEndpoint = context.getCurrentXmlTest().getParameter("userInfoEndpoint");
739  clientInfoEndpoint = context.getCurrentXmlTest().getParameter("clientInfoEndpoint");
740  checkSessionIFrame = context.getCurrentXmlTest().getParameter("checkSessionIFrame");
741  endSessionEndpoint = context.getCurrentXmlTest().getParameter("endSessionEndpoint");
742  jwksUri = context.getCurrentXmlTest().getParameter("jwksUri");
743  registrationEndpoint = context.getCurrentXmlTest().getParameter("registrationEndpoint");
744  configurationEndpoint = context.getCurrentXmlTest().getParameter("configurationEndpoint");
745  idGenEndpoint = context.getCurrentXmlTest().getParameter("idGenEndpoint");
746  introspectionEndpoint = context.getCurrentXmlTest().getParameter("introspectionEndpoint");
747  scopeToClaimsMapping = new HashMap<String, List<String>>();
748  }
749 
751  }
String registrationEndpoint
Definition: BaseTest.java:81
String getIntrospectionEndpoint()
Definition: OpenIdConfigurationResponse.java:343
List< String > getTokenEndpointAuthMethodsSupported()
Definition: OpenIdConfigurationResponse.java:642
String determineAuthorizationPageEndpoint(String authorizationEndpoint)
Definition: BaseTest.java:753
String jwksUri
Definition: BaseTest.java:80
String getRegistrationEndpoint()
Definition: OpenIdConfigurationResponse.java:310
String clientInfoEndpoint
Definition: BaseTest.java:77
String getCheckSessionIFrame()
Definition: OpenIdConfigurationResponse.java:248
String authorizationPageEndpoint
Definition: BaseTest.java:73
String idGenEndpoint
Definition: BaseTest.java:83
String getIdGenerationEndpoint()
Definition: OpenIdConfigurationResponse.java:327
static void showClient(BaseClient client)
Definition: BaseTest.java:775
List< String > getRequestObjectSigningAlgValuesSupported()
Definition: OpenIdConfigurationResponse.java:579
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
String configurationEndpoint
Definition: BaseTest.java:82
List< String > getSubjectTypesSupported()
Definition: OpenIdConfigurationResponse.java:438
String getEndSessionEndpoint()
Definition: OpenIdConfigurationResponse.java:268
String tokenEndpoint
Definition: BaseTest.java:75
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
List< String > getAcrValuesSupported()
Definition: OpenIdConfigurationResponse.java:418
String getClientInfoEndpoint()
Definition: OpenIdConfigurationResponse.java:228
List< String > getGrantTypesSupported()
Definition: OpenIdConfigurationResponse.java:398
String checkSessionIFrame
Definition: BaseTest.java:78
void setExecutor(ClientExecutor executor)
Definition: BaseClient.java:84
OpenIdConfigurationResponse execOpenIdConfiguration()
Definition: OpenIdConfigurationClient.java:47
String loginFormLoginButton
Definition: BaseTest.java:90
String gluuConfigurationEndpoint
Definition: BaseTest.java:74
Map< String, List< String > > getScopeToClaimsMapping()
Definition: OpenIdConfigurationResponse.java:136
String getJwksUri()
Definition: OpenIdConfigurationResponse.java:289
String getTokenEndpoint()
Definition: OpenIdConfigurationResponse.java:192
List< String > getIdTokenSigningAlgValuesSupported()
Definition: OpenIdConfigurationResponse.java:519
Definition: OpenIdConnectDiscoveryClient.java:29
String introspectionEndpoint
Definition: BaseTest.java:84
void showTitle(String title)
Definition: BaseTest.java:761
List< String > getResponseTypesSupported()
Definition: OpenIdConfigurationResponse.java:378
String endSessionEndpoint
Definition: BaseTest.java:79
String getSubject()
Definition: OpenIdConnectDiscoveryResponse.java:32
List< String > getScopesSupported()
Definition: OpenIdConfigurationResponse.java:360
String determineGluuConfigurationEndpoint(String host)
Definition: BaseTest.java:757
OpenIdConnectDiscoveryResponse exec()
Definition: OpenIdConnectDiscoveryClient.java:47
String getAuthorizationEndpoint()
Definition: OpenIdConfigurationResponse.java:174
String userInfoEndpoint
Definition: BaseTest.java:76
Definition: OpenIdConfigurationClient.java:27
int getStatus()
Definition: BaseResponse.java:49
List< WebFingerLink > getLinks()
Definition: OpenIdConnectDiscoveryResponse.java:40
List< String > getClaimsSupported()
Definition: OpenIdConfigurationResponse.java:728
Definition: OpenIdConnectDiscoveryResponse.java:17
String authorizationEndpoint
Definition: BaseTest.java:72
String getUserInfoEndpoint()
Definition: OpenIdConfigurationResponse.java:210
Definition: OpenIdConfigurationResponse.java:26
static ClientExecutor clientExecutor()
Definition: BaseTest.java:822
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85
String authorizeFormAllowButton
Definition: BaseTest.java:91
String getIssuer()
Definition: OpenIdConfigurationResponse.java:156

◆ fails()

static void org.xdi.oxauth.BaseTest.fails ( Throwable  e)
inlinestaticinherited
50  {
51  Assert.fail(e.getMessage(), e);
52  }

◆ getAuthorizationEndpoint()

String org.xdi.oxauth.BaseTest.getAuthorizationEndpoint ( )
inlineinherited
134  {
135  return authorizationEndpoint;
136  }
String authorizationEndpoint
Definition: BaseTest.java:72

◆ getCheckSessionIFrame()

String org.xdi.oxauth.BaseTest.getCheckSessionIFrame ( )
inlineinherited
166  {
167  return checkSessionIFrame;
168  }
String checkSessionIFrame
Definition: BaseTest.java:78

◆ getClientInfoEndpoint()

String org.xdi.oxauth.BaseTest.getClientInfoEndpoint ( )
inlineinherited
158  {
159  return clientInfoEndpoint;
160  }
String clientInfoEndpoint
Definition: BaseTest.java:77

◆ getConfigurationEndpoint()

String org.xdi.oxauth.BaseTest.getConfigurationEndpoint ( )
inlineinherited
222  {
223  return configurationEndpoint;
224  }
String configurationEndpoint
Definition: BaseTest.java:82

◆ getDriver()

WebDriver org.xdi.oxauth.BaseTest.getDriver ( )
inlineinherited
126  {
127  return driver;
128  }
WebDriver driver
Definition: BaseTest.java:70

◆ getEndSessionEndpoint()

String org.xdi.oxauth.BaseTest.getEndSessionEndpoint ( )
inlineinherited
174  {
175  return endSessionEndpoint;
176  }
String endSessionEndpoint
Definition: BaseTest.java:79

◆ getIdGenEndpoint()

String org.xdi.oxauth.BaseTest.getIdGenEndpoint ( )
inlineinherited
214  {
215  return idGenEndpoint;
216  }
String idGenEndpoint
Definition: BaseTest.java:83

◆ getIntrospectionEndpoint()

String org.xdi.oxauth.BaseTest.getIntrospectionEndpoint ( )
inlineinherited
198  {
199  return introspectionEndpoint;
200  }
String introspectionEndpoint
Definition: BaseTest.java:84

◆ getJwksUri()

String org.xdi.oxauth.BaseTest.getJwksUri ( )
inlineinherited
182  {
183  return jwksUri;
184  }
String jwksUri
Definition: BaseTest.java:80

◆ getRegistrationEndpoint()

String org.xdi.oxauth.BaseTest.getRegistrationEndpoint ( )
inlineinherited
190  {
191  return registrationEndpoint;
192  }
String registrationEndpoint
Definition: BaseTest.java:81

◆ getScopeToClaimsMapping()

Map<String, List<String> > org.xdi.oxauth.BaseTest.getScopeToClaimsMapping ( )
inlineinherited
206  {
207  return scopeToClaimsMapping;
208  }
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85

◆ getTokenEndpoint()

String org.xdi.oxauth.BaseTest.getTokenEndpoint ( )
inlineinherited
142  {
143  return tokenEndpoint;
144  }
String tokenEndpoint
Definition: BaseTest.java:75

◆ getUserInfoEndpoint()

String org.xdi.oxauth.BaseTest.getUserInfoEndpoint ( )
inlineinherited
150  {
151  return userInfoEndpoint;
152  }
String userInfoEndpoint
Definition: BaseTest.java:76

◆ initTestSuite()

void org.xdi.oxauth.BaseTest.initTestSuite ( ITestContext  context) throws FileNotFoundException, IOException
inlineinherited
95  {
96  SecurityProviderUtility.installBCProvider();
97 
98  Reporter.log("Invoked init test suite method \n", true);
99 
100  String propertiesFile = context.getCurrentXmlTest().getParameter("propertiesFile");
101  if (StringHelper.isEmpty(propertiesFile)) {
102  propertiesFile = "target/test-classes/testng.properties";
103  //propertiesFile = "U:\\own\\project\\git\\oxAuth\\Client\\src\\test\\resources\\testng_yuriy.properties";
104  //propertiesFile = "/Users/JAVIER/IdeaProjects/oxAuth/Client/target/test-classes/testng.properties";
105  }
106 
107  FileInputStream conf = new FileInputStream(propertiesFile);
108  Properties prop = new Properties();
109  prop.load(conf);
110 
111  Map<String, String> parameters = new HashMap<String, String>();
112  for (Entry<Object, Object> entry : prop.entrySet()) {
113  Object key = entry.getKey();
114  Object value = entry.getValue();
115 
116  if (StringHelper.isEmptyString(key) || StringHelper.isEmptyString(value)) {
117  continue;
118  }
119  parameters.put(key.toString(), value.toString());
120  }
121 
122  // Overrided test paramters
123  context.getSuite().getXmlSuite().setParameters(parameters);
124  }

◆ omittedTokenEndpointAuthMethodStep1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.omittedTokenEndpointAuthMethodStep1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline

Register a client without specify a Token Endpoint Auth Method.

103  {
104  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
105 
106  String registerRequestContent = null;
107  try {
108  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
109  StringUtils.spaceSeparatedToList(redirectUris));
110 
111  registerRequestContent = registerRequest.getJSONParameters().toString(4);
112  } catch (JSONException e) {
113  e.printStackTrace();
114  fail(e.getMessage());
115  }
116 
117  Response response = request.post(Entity.json(registerRequestContent));
118  String entity = response.readEntity(String.class);
119 
120  showResponse("omittedTokenEndpointAuthMethodStep1", response, entity);
121 
122  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
123  assertNotNull(entity, "Unexpected result: " + entity);
124  try {
125  JSONObject jsonObj = new JSONObject(entity);
126  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
127  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
128  assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
129  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
130  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
131  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
132 
133  clientId1 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
134  registrationAccessToken1 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
135  registrationClientUri1 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
136  } catch (JSONException e) {
137  e.printStackTrace();
138  fail(e.getMessage() + "\nResponse was: " + entity);
139  }
140  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationAccessToken1
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:70
static String registrationClientUri1
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:71
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId1
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:69

◆ omittedTokenEndpointAuthMethodStep2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.omittedTokenEndpointAuthMethodStep2 ( final String  registerPath) throws Exception
inline

Read client to check whether it is using the default Token Endpoint Auth Method client_secret_basic.

148  {
149  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath + "?"
150  + registrationClientUri1.substring(registrationClientUri1.indexOf("?") + 1)).request();
151  request.header("Authorization", "Bearer " + registrationAccessToken1);
152 
153  Response response = request.get();
154  String entity = response.readEntity(String.class);
155 
156  showResponse("omittedTokenEndpointAuthMethodStep2", response, entity);
157 
158  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
159  assertNotNull(entity, "Unexpected result: " + entity);
160  try {
161  JSONObject jsonObj = new JSONObject(entity);
162  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
163  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
164  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
165  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
166 
167  // Registered Metadata
168  assertTrue(jsonObj.has(TOKEN_ENDPOINT_AUTH_METHOD.toString()));
169  assertEquals(jsonObj.getString(TOKEN_ENDPOINT_AUTH_METHOD.toString()),
170  AuthenticationMethod.CLIENT_SECRET_BASIC.toString());
171  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
172  assertTrue(jsonObj.has(RESPONSE_TYPES.toString()));
173  assertTrue(jsonObj.has(REDIRECT_URIS.toString()));
174  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
175  assertTrue(jsonObj.has(CLIENT_NAME.toString()));
176  assertTrue(jsonObj.has(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()));
177  assertTrue(jsonObj.has(SCOPE.toString()));
178  } catch (JSONException e) {
179  e.printStackTrace();
180  fail(e.getMessage() + "\nResponse was: " + entity);
181  }
182  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationAccessToken1
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:70
static String registrationClientUri1
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:71
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ output()

static void org.xdi.oxauth.BaseTest.output ( String  p_msg)
inlinestaticinherited
54  {
55  System.out.println(p_msg);
56  }

◆ setAuthorizationEndpoint()

void org.xdi.oxauth.BaseTest.setAuthorizationEndpoint ( String  authorizationEndpoint)
inlineinherited
138  {
140  }
String authorizationEndpoint
Definition: BaseTest.java:72

◆ setCheckSessionIFrame()

void org.xdi.oxauth.BaseTest.setCheckSessionIFrame ( String  checkSessionIFrame)
inlineinherited
170  {
172  }
String checkSessionIFrame
Definition: BaseTest.java:78

◆ setClientInfoEndpoint()

void org.xdi.oxauth.BaseTest.setClientInfoEndpoint ( String  clientInfoEndpoint)
inlineinherited
162  {
164  }
String clientInfoEndpoint
Definition: BaseTest.java:77

◆ setConfigurationEndpoint()

void org.xdi.oxauth.BaseTest.setConfigurationEndpoint ( String  configurationEndpoint)
inlineinherited
226  {
228  }
String configurationEndpoint
Definition: BaseTest.java:82

◆ setDriver()

void org.xdi.oxauth.BaseTest.setDriver ( WebDriver  driver)
inlineinherited
130  {
131  this.driver = driver;
132  }
WebDriver driver
Definition: BaseTest.java:70

◆ setEndSessionEndpoint()

void org.xdi.oxauth.BaseTest.setEndSessionEndpoint ( String  endSessionEndpoint)
inlineinherited
178  {
180  }
String endSessionEndpoint
Definition: BaseTest.java:79

◆ setIdGenEndpoint()

void org.xdi.oxauth.BaseTest.setIdGenEndpoint ( String  p_idGenEndpoint)
inlineinherited
218  {
219  idGenEndpoint = p_idGenEndpoint;
220  }
String idGenEndpoint
Definition: BaseTest.java:83

◆ setIntrospectionEndpoint()

void org.xdi.oxauth.BaseTest.setIntrospectionEndpoint ( String  p_introspectionEndpoint)
inlineinherited
202  {
203  introspectionEndpoint = p_introspectionEndpoint;
204  }
String introspectionEndpoint
Definition: BaseTest.java:84

◆ setJwksUri()

void org.xdi.oxauth.BaseTest.setJwksUri ( String  jwksUri)
inlineinherited
186  {
187  this.jwksUri = jwksUri;
188  }
String jwksUri
Definition: BaseTest.java:80

◆ setRegistrationEndpoint()

void org.xdi.oxauth.BaseTest.setRegistrationEndpoint ( String  registrationEndpoint)
inlineinherited
194  {
196  }
String registrationEndpoint
Definition: BaseTest.java:81

◆ setScopeToClaimsMapping()

void org.xdi.oxauth.BaseTest.setScopeToClaimsMapping ( Map< String, List< String >>  p_scopeToClaimsMapping)
inlineinherited
210  {
211  scopeToClaimsMapping = p_scopeToClaimsMapping;
212  }
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85

◆ setTokenEndpoint()

void org.xdi.oxauth.BaseTest.setTokenEndpoint ( String  tokenEndpoint)
inlineinherited
146  {
148  }
String tokenEndpoint
Definition: BaseTest.java:75

◆ setUserInfoEndpoint()

void org.xdi.oxauth.BaseTest.setUserInfoEndpoint ( String  userInfoEndpoint)
inlineinherited
154  {
156  }
String userInfoEndpoint
Definition: BaseTest.java:76

◆ showClient() [1/2]

static void org.xdi.oxauth.BaseTest.showClient ( BaseClient  client)
inlinestaticinherited
775  {
776  ClientUtils.showClient(client);
777  }
Definition: ClientUtils.java:17
static void showClient(BaseClient client)
Definition: ClientUtils.java:21

◆ showClient() [2/2]

static void org.xdi.oxauth.BaseTest.showClient ( BaseClient  client,
CookieStore  cookieStore 
)
inlinestaticinherited
779  {
780  ClientUtils.showClient(client, cookieStore);
781  }
Definition: ClientUtils.java:17
static void showClient(BaseClient client)
Definition: ClientUtils.java:21

◆ showClientUserAgent()

static void org.xdi.oxauth.BaseTest.showClientUserAgent ( BaseClient  client)
inlinestaticinherited
783  {
785  }
Definition: ClientUtils.java:17
static void showClientUserAgent(BaseClient client)
Definition: ClientUtils.java:35

◆ showEntity()

void org.xdi.oxauth.BaseTest.showEntity ( String  entity)
inlineinherited
769  {
770  if (entity != null) {
771  System.out.println("Entity: " + entity.replace("\\n", "\n"));
772  }
773  }

◆ showResponse() [1/2]

void org.xdi.oxauth.BaseTest.showResponse ( String  title,
Response  response 
)
inlineinherited
30  {
31  showResponse(title, response, null);
32  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ showResponse() [2/2]

static void org.xdi.oxauth.BaseTest.showResponse ( String  title,
Response  response,
Object  entity 
)
inlinestaticinherited
34  {
35  System.out.println(" ");
36  System.out.println("RESPONSE FOR: " + title);
37  System.out.println(response.getStatus());
38  for (Entry<String, List<Object>> headers : response.getHeaders().entrySet()) {
39  String headerName = headers.getKey();
40  System.out.println(headerName + ": " + headers.getValue());
41  }
42 
43  if (entity != null) {
44  System.out.println(entity.toString().replace("\\n", "\n"));
45  }
46  System.out.println(" ");
47  System.out.println("Status message: " + response.getStatus());
48  }

◆ showTitle() [1/2]

void org.xdi.oxauth.BaseTest.showTitle ( String  title)
inlineinherited
22  {
23  title = "TEST: " + title;
24 
25  System.out.println("#######################################################");
26  System.out.println(title);
27  System.out.println("#######################################################");
28  }

◆ showTitle() [2/2]

void org.xdi.oxauth.BaseTest.showTitle ( String  title)
inlineinherited
761  {
762  title = "TEST: " + title;
763 
764  System.out.println("#######################################################");
765  System.out.println(title);
766  System.out.println("#######################################################");
767  }

◆ startSelenium()

void org.xdi.oxauth.BaseTest.startSelenium ( )
inlineinherited
230  {
231  //System.setProperty("webdriver.chrome.driver", "/Users/JAVIER/tmp/chromedriver");
232  //driver = new ChromeDriver();
233 
234  //driver = new SafariDriver();
235 
236  //driver = new FirefoxDriver();
237 
238  //driver = new InternetExplorerDriver();
239 
240  driver = new HtmlUnitDriver(true);
241  }
WebDriver driver
Definition: BaseTest.java:70

◆ stopSelenium()

void org.xdi.oxauth.BaseTest.stopSelenium ( )
inlineinherited
243  {
244 // driver.close();
245  driver.quit();
246  }
WebDriver driver
Definition: BaseTest.java:70

◆ tokenEndpointAuthMethodClientSecretBasicFail1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicFail1 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 1: Call to Token Endpoint with Auth Method client_secret_post should fail.

382  {
383  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
384 
385  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
386  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_POST);
387  tokenRequest.setUsername(userId);
388  tokenRequest.setPassword(userSecret);
389  tokenRequest.setScope("email read_stream manage_pages");
390  tokenRequest.setAuthUsername(clientId2);
391  tokenRequest.setAuthPassword(clientSecret2);
392 
393  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
394 
395  Response response = request
396  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
397  String entity = response.readEntity(String.class);
398 
399  showResponse("tokenEndpointAuthMethodClientSecretBasicFail1", response, entity);
400 
401  assertEquals(response.getStatus(), 401, "Unexpected response code.");
402  assertNotNull(entity, "Unexpected result: " + entity);
403  try {
404  JSONObject jsonObj = new JSONObject(entity);
405  assertTrue(jsonObj.has("error"), "The error type is null");
406  assertTrue(jsonObj.has("error_description"), "The error description is null");
407  } catch (JSONException e) {
408  e.printStackTrace();
409  fail(e.getMessage() + "\nResponse was: " + entity);
410  }
411  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:74
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretBasicFail2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicFail2 ( final String  tokenPath,
final String  audience,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 2: Call to Token Endpoint with Auth Method client_secret_jwt should fail.

420  {
421  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
422 
423  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
424  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
425  tokenRequest.setAudience(audience);
426  tokenRequest.setUsername(userId);
427  tokenRequest.setPassword(userSecret);
428  tokenRequest.setScope("email read_stream manage_pages");
429  tokenRequest.setAuthUsername(clientId2);
430  tokenRequest.setAuthPassword(clientSecret2);
431 
432  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
433 
434  Response response = request
435  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
436  String entity = response.readEntity(String.class);
437 
438  showResponse("tokenEndpointAuthMethodClientSecretBasicFail2", response, entity);
439 
440  assertEquals(response.getStatus(), 401, "Unexpected response code.");
441  assertNotNull(entity, "Unexpected result: " + entity);
442  try {
443  JSONObject jsonObj = new JSONObject(entity);
444  assertTrue(jsonObj.has("error"), "The error type is null");
445  assertTrue(jsonObj.has("error_description"), "The error description is null");
446  } catch (JSONException e) {
447  e.printStackTrace();
448  fail(e.getMessage() + "\nResponse was: " + entity);
449  }
450  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:74
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretBasicFail3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicFail3 ( final String  tokenPath,
final String  userId,
final String  userSecret,
final String  audience,
final String  keyId,
final String  keyStoreFile,
final String  keyStoreSecret 
) throws Exception
inline

Fail 3: Call to Token Endpoint with Auth Method private_key_jwt should fail.

460  {
461  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
462 
463  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, null);
464 
465  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
466  tokenRequest.setAuthenticationMethod(AuthenticationMethod.PRIVATE_KEY_JWT);
467  tokenRequest.setAlgorithm(SignatureAlgorithm.RS256);
468  tokenRequest.setKeyId(keyId);
469  tokenRequest.setCryptoProvider(cryptoProvider);
470  tokenRequest.setAudience(audience);
471  tokenRequest.setUsername(userId);
472  tokenRequest.setPassword(userSecret);
473  tokenRequest.setScope("email read_stream manage_pages");
474  tokenRequest.setAuthUsername(clientId2);
475  tokenRequest.setAuthPassword(clientSecret2);
476 
477  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
478 
479  Response response = request
480  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
481  String entity = response.readEntity(String.class);
482 
483  showResponse("tokenEndpointAuthMethodClientSecretBasicFail3", response, entity);
484 
485  assertEquals(response.getStatus(), 401, "Unexpected response code.");
486  assertNotNull(entity, "Unexpected result: " + entity);
487  try {
488  JSONObject jsonObj = new JSONObject(entity);
489  assertTrue(jsonObj.has("error"), "The error type is null");
490  assertTrue(jsonObj.has("error_description"), "The error description is null");
491  } catch (JSONException e) {
492  e.printStackTrace();
493  fail(e.getMessage() + "\nResponse was: " + entity);
494  }
495  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:74
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretBasicStep1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicStep1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline

Register a client with Token Endpoint Auth Method client_secret_basic.

191  {
192  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
193 
194  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
195  StringUtils.spaceSeparatedToList(redirectUris));
196  registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
197  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
198 
199  String registerRequestContent = registerRequest.getJSONParameters().toString(4);
200 
201  Response response = request.post(Entity.json(registerRequestContent));
202  String entity = response.readEntity(String.class);
203 
204  showResponse("tokenEndpointAuthMethodClientSecretBasicStep1", response, entity);
205 
206  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
207  assertNotNull(entity, "Unexpected result: " + entity);
208  try {
209  JSONObject jsonObj = new JSONObject(entity);
210  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
211  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
212  assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
213  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
214  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
215  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
216 
217  clientId2 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
218  clientSecret2 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
219  registrationAccessToken2 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
220  registrationClientUri2 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
221  } catch (JSONException e) {
222  e.printStackTrace();
223  fail(e.getMessage() + "\nResponse was: " + entity);
224  }
225  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationAccessToken2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:75
static String clientSecret2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:74
static String registrationClientUri2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:77
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretBasicStep2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicStep2 ( final String  registerPath) throws Exception
inline

Read client to check whether it is using the Token Endpoint Auth Method client_secret_basic.

233  {
234  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath + "?"
235  + registrationClientUri2.substring(registrationClientUri2.indexOf("?") + 1)).request();
236  request.header("Authorization", "Bearer " + registrationAccessToken2);
237 
238  Response response = request.get();
239  String entity = response.readEntity(String.class);
240 
241  showResponse("tokenEndpointAuthMethodClientSecretBasicStep2", response, entity);
242 
243  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
244  assertNotNull(entity, "Unexpected result: " + entity);
245  try {
246  JSONObject jsonObj = new JSONObject(entity);
247  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
248  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
249  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
250  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
251 
252  // Registered Metadata
253  assertTrue(jsonObj.has(TOKEN_ENDPOINT_AUTH_METHOD.toString()));
254  assertEquals(jsonObj.getString(TOKEN_ENDPOINT_AUTH_METHOD.toString()),
255  AuthenticationMethod.CLIENT_SECRET_BASIC.toString());
256  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
257  assertTrue(jsonObj.has(RESPONSE_TYPES.toString()));
258  assertTrue(jsonObj.has(REDIRECT_URIS.toString()));
259  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
260  assertTrue(jsonObj.has(CLIENT_NAME.toString()));
261  assertTrue(jsonObj.has(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()));
262  assertTrue(jsonObj.has(SCOPE.toString()));
263  } catch (JSONException e) {
264  e.printStackTrace();
265  fail(e.getMessage() + "\nResponse was: " + entity);
266  }
267  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationAccessToken2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:75
static String registrationClientUri2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:77
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretBasicStep3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicStep3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline

Request authorization code.

275  {
276  List<ResponseType> responseTypes = new ArrayList<ResponseType>();
277  responseTypes.add(ResponseType.CODE);
278  List<String> scopes = new ArrayList<String>();
279  scopes.add("openid");
280  scopes.add("profile");
281  scopes.add("address");
282  scopes.add("email");
283  String state = UUID.randomUUID().toString();
284 
285  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId2, scopes,
286  redirectUri, null);
287  authorizationRequest.setState(state);
288  authorizationRequest.getPrompts().add(Prompt.NONE);
289  authorizationRequest.setAuthUsername(userId);
290  authorizationRequest.setAuthPassword(userSecret);
291 
292  Builder request = ResteasyClientBuilder.newClient()
293  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
294  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
295  request.header("Accept", MediaType.TEXT_PLAIN);
296 
297  Response response = request.get();
298  String entity = response.readEntity(String.class);
299 
300  showResponse("tokenEndpointAuthMethodClientSecretBasicStep3", response, entity);
301 
302  assertEquals(response.getStatus(), 302, "Unexpected response code.");
303  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
304 
305  if (response.getLocation() != null) {
306  try {
307  URI uri = new URI(response.getLocation().toString());
308  assertNotNull(uri.getQuery(), "The query string is null");
309 
310  Map<String, String> params = QueryStringDecoder.decode(uri.getQuery());
311 
312  assertNotNull(params.get(AuthorizeResponseParam.CODE), "The code is null");
313  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
314  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
315 
316  authorizationCode2 = params.get(AuthorizeResponseParam.CODE);
317  } catch (URISyntaxException e) {
318  e.printStackTrace();
319  fail("Response URI is not well formed");
320  } catch (Exception e) {
321  e.printStackTrace();
322  fail(e.getMessage());
323  }
324  }
325  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String authorizationCode2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:76

◆ tokenEndpointAuthMethodClientSecretBasicStep4()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretBasicStep4 ( final String  tokenPath,
final String  redirectUri 
) throws Exception
inline

Call to Token Endpoint with Auth Method client_secret_basic.

333  {
334  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
335 
336  TokenRequest tokenRequest = new TokenRequest(GrantType.AUTHORIZATION_CODE);
337  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
338  tokenRequest.setCode(authorizationCode2);
339  tokenRequest.setRedirectUri(redirectUri);
340  tokenRequest.setAuthUsername(clientId2);
341  tokenRequest.setAuthPassword(clientSecret2);
342 
343  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
344  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
345 
346  Response response = request
347  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
348  String entity = response.readEntity(String.class);
349 
350  showResponse("tokenEndpointAuthMethodClientSecretBasicStep4", response, entity);
351 
352  assertEquals(response.getStatus(), 200, "Unexpected response code.");
353  assertTrue(
354  response.getHeaderString("Cache-Control") != null
355  && response.getHeaderString("Cache-Control").equals("no-store"),
356  "Unexpected result: " + response.getHeaderString("Cache-Control"));
357  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
358  "Unexpected result: " + response.getHeaderString("Pragma"));
359  assertNotNull(entity, "Unexpected result: " + entity);
360  try {
361  JSONObject jsonObj = new JSONObject(entity);
362  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
363  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
364  assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
365  assertTrue(jsonObj.has("id_token"), "Unexpected result: id_token not found");
366  } catch (JSONException e) {
367  e.printStackTrace();
368  fail(e.getMessage() + "\nResponse was: " + entity);
369  } catch (Exception e) {
370  e.printStackTrace();
371  fail(e.getMessage());
372  }
373  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:74
static String clientId2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:73
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String authorizationCode2
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:76

◆ tokenEndpointAuthMethodClientSecretJwtFail1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtFail1 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 1: Call to Token Endpoint with Auth Method client_secret_basic should fail.

1010  {
1011  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1012 
1013  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1014  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
1015  tokenRequest.setUsername(userId);
1016  tokenRequest.setPassword(userSecret);
1017  tokenRequest.setScope("email read_stream manage_pages");
1018  tokenRequest.setAuthUsername(clientId4);
1019  tokenRequest.setAuthPassword(clientSecret4);
1020 
1021  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
1022  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1023 
1024  Response response = request
1025  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1026  String entity = response.readEntity(String.class);
1027 
1028  showResponse("tokenEndpointAuthMethodClientSecretJwtFail1", response, entity);
1029 
1030  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1031  assertNotNull(entity, "Unexpected result: " + entity);
1032  try {
1033  JSONObject jsonObj = new JSONObject(entity);
1034  assertTrue(jsonObj.has("error"), "The error type is null");
1035  assertTrue(jsonObj.has("error_description"), "The error description is null");
1036  } catch (JSONException e) {
1037  e.printStackTrace();
1038  fail(e.getMessage() + "\nResponse was: " + entity);
1039  }
1040  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:86
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85

◆ tokenEndpointAuthMethodClientSecretJwtFail2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtFail2 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 2: Call to Token Endpoint with Auth Method client_secret_post should fail.

1049  {
1050  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1051 
1052  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1053  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_POST);
1054  tokenRequest.setUsername(userId);
1055  tokenRequest.setPassword(userSecret);
1056  tokenRequest.setScope("email read_stream manage_pages");
1057  tokenRequest.setAuthUsername(clientId4);
1058  tokenRequest.setAuthPassword(clientSecret4);
1059 
1060  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1061 
1062  Response response = request
1063  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1064  String entity = response.readEntity(String.class);
1065 
1066  showResponse("tokenEndpointAuthMethodClientSecretJwtFail2", response, entity);
1067 
1068  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1069  assertNotNull(entity, "Unexpected result: " + entity);
1070  try {
1071  JSONObject jsonObj = new JSONObject(entity);
1072  assertTrue(jsonObj.has("error"), "The error type is null");
1073  assertTrue(jsonObj.has("error_description"), "The error description is null");
1074  } catch (JSONException e) {
1075  e.printStackTrace();
1076  fail(e.getMessage() + "\nResponse was: " + entity);
1077  }
1078  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:86
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85

◆ tokenEndpointAuthMethodClientSecretJwtFail3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtFail3 ( final String  tokenPath,
final String  userId,
final String  userSecret,
final String  audience,
final String  keyId,
final String  keyStoreFile,
final String  keyStoreSecret 
) throws Exception
inline

Fail 3: Call to Token Endpoint with Auth Method private_key_jwt should fail.

1088  {
1089  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1090 
1091  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, null);
1092 
1093  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1094  tokenRequest.setAuthenticationMethod(AuthenticationMethod.PRIVATE_KEY_JWT);
1095  tokenRequest.setAlgorithm(SignatureAlgorithm.RS256);
1096  tokenRequest.setKeyId(keyId);
1097  tokenRequest.setCryptoProvider(cryptoProvider);
1098  tokenRequest.setAudience(audience);
1099  tokenRequest.setUsername(userId);
1100  tokenRequest.setPassword(userSecret);
1101  tokenRequest.setScope("email read_stream manage_pages");
1102  tokenRequest.setAuthUsername(clientId4);
1103  tokenRequest.setAuthPassword(clientSecret4);
1104 
1105  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1106 
1107  Response response = request
1108  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1109  String entity = response.readEntity(String.class);
1110 
1111  showResponse("tokenEndpointAuthMethodClientSecretJwtFail3", response, entity);
1112 
1113  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1114  assertNotNull(entity, "Unexpected result: " + entity);
1115  try {
1116  JSONObject jsonObj = new JSONObject(entity);
1117  assertTrue(jsonObj.has("error"), "The error type is null");
1118  assertTrue(jsonObj.has("error_description"), "The error description is null");
1119  } catch (JSONException e) {
1120  e.printStackTrace();
1121  fail(e.getMessage() + "\nResponse was: " + entity);
1122  }
1123  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:86
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85

◆ tokenEndpointAuthMethodClientSecretJwtStep1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtStep1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline

Register a client with Token Endpoint Auth Method client_secret_jwt.

818  {
819 
820  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
821 
822  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
823  StringUtils.spaceSeparatedToList(redirectUris));
824  registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
825  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
826 
827  String registerRequestContent = registerRequest.getJSONParameters().toString(4);
828 
829  Response response = request.post(Entity.json(registerRequestContent));
830  String entity = response.readEntity(String.class);
831 
832  showResponse("tokenEndpointAuthMethodClientSecretJwtStep1", response, entity);
833 
834  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
835  assertNotNull(entity, "Unexpected result: " + entity);
836  try {
837  JSONObject jsonObj = new JSONObject(entity);
838  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
839  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
840  assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
841  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
842  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
843  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
844 
845  clientId4 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
846  clientSecret4 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
847  registrationAccessToken4 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
848  registrationClientUri4 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
849  } catch (JSONException e) {
850  e.printStackTrace();
851  fail(e.getMessage() + "\nResponse was: " + entity);
852  }
853  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationClientUri4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:89
static String clientSecret4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:86
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85
static String registrationAccessToken4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:87

◆ tokenEndpointAuthMethodClientSecretJwtStep2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtStep2 ( final String  registerPath) throws Exception
inline

Read client to check whether it is using the Token Endpoint Auth Method client_secret_jwt.

861  {
862  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath + "?"
863  + registrationClientUri4.substring(registrationClientUri4.indexOf("?") + 1)).request();
864  request.header("Authorization", "Bearer " + registrationAccessToken4);
865 
866  Response response = request.get();
867  String entity = response.readEntity(String.class);
868 
869  showResponse("tokenEndpointAuthMethodClientSecretJwtStep2", response, entity);
870 
871  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
872  assertNotNull(entity, "Unexpected result: " + entity);
873  try {
874  JSONObject jsonObj = new JSONObject(entity);
875  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
876  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
877  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
878  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
879 
880  // Registered Metadata
881  assertTrue(jsonObj.has(TOKEN_ENDPOINT_AUTH_METHOD.toString()));
882  assertEquals(jsonObj.getString(TOKEN_ENDPOINT_AUTH_METHOD.toString()),
883  AuthenticationMethod.CLIENT_SECRET_JWT.toString());
884  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
885  assertTrue(jsonObj.has(RESPONSE_TYPES.toString()));
886  assertTrue(jsonObj.has(REDIRECT_URIS.toString()));
887  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
888  assertTrue(jsonObj.has(CLIENT_NAME.toString()));
889  assertTrue(jsonObj.has(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()));
890  assertTrue(jsonObj.has(SCOPE.toString()));
891  } catch (JSONException e) {
892  e.printStackTrace();
893  fail(e.getMessage() + "\nResponse was: " + entity);
894  }
895  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationClientUri4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:89
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String registrationAccessToken4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:87

◆ tokenEndpointAuthMethodClientSecretJwtStep3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtStep3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline

Request authorization code.

903  {
904  List<ResponseType> responseTypes = new ArrayList<ResponseType>();
905  responseTypes.add(ResponseType.CODE);
906  List<String> scopes = new ArrayList<String>();
907  scopes.add("openid");
908  scopes.add("profile");
909  scopes.add("address");
910  scopes.add("email");
911  String state = UUID.randomUUID().toString();
912 
913  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId4, scopes,
914  redirectUri, null);
915  authorizationRequest.setState(state);
916  authorizationRequest.getPrompts().add(Prompt.NONE);
917  authorizationRequest.setAuthUsername(userId);
918  authorizationRequest.setAuthPassword(userSecret);
919 
920  Builder request = ResteasyClientBuilder.newClient()
921  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
922  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
923  request.header("Accept", MediaType.TEXT_PLAIN);
924 
925  Response response = request.get();
926 
927  String entity = response.readEntity(String.class);
928 
929  showResponse("tokenEndpointAuthMethodClientSecretJwtStep3", response, entity);
930 
931  assertEquals(response.getStatus(), 302, "Unexpected response code.");
932  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
933 
934  if (response.getLocation() != null) {
935  try {
936  URI uri = new URI(response.getLocation().toString());
937  assertNotNull(uri.getQuery(), "The query string is null");
938 
939  Map<String, String> params = QueryStringDecoder.decode(uri.getQuery());
940 
941  assertNotNull(params.get(AuthorizeResponseParam.CODE), "The code is null");
942  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
943  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
944 
945  authorizationCode4 = params.get(AuthorizeResponseParam.CODE);
946  } catch (URISyntaxException e) {
947  e.printStackTrace();
948  fail("Response URI is not well formed");
949  } catch (Exception e) {
950  e.printStackTrace();
951  fail(e.getMessage());
952  }
953  }
954  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String authorizationCode4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:88
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85

◆ tokenEndpointAuthMethodClientSecretJwtStep4()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretJwtStep4 ( final String  tokenPath,
final String  redirectUri,
final String  audience,
final String  keyId,
final String  dnName,
final String  keyStoreFile,
final String  keyStoreSecret 
) throws Exception
inline

Call to Token Endpoint with Auth Method client_secret_Jwt.

963  {
964  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
965 
966  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, dnName);
967 
968  TokenRequest tokenRequest = new TokenRequest(GrantType.AUTHORIZATION_CODE);
969  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
970  tokenRequest.setCryptoProvider(cryptoProvider);
971  tokenRequest.setKeyId(keyId);
972  tokenRequest.setAudience(audience);
973  tokenRequest.setCode(authorizationCode4);
974  tokenRequest.setRedirectUri(redirectUri);
975  tokenRequest.setAuthUsername(clientId4);
976  tokenRequest.setAuthPassword(clientSecret4);
977 
978  Response response = request
979  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
980  String entity = response.readEntity(String.class);
981 
982  showResponse("tokenEndpointAuthMethodClientSecretJwtStep4", response, entity);
983 
984  assertEquals(response.getStatus(), 200, "Unexpected response code.");
985  assertTrue(
986  response.getHeaderString("Cache-Control") != null
987  && response.getHeaderString("Cache-Control").equals("no-store"),
988  "Unexpected result: " + response.getHeaderString("Cache-Control"));
989  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
990  "Unexpected result: " + response.getHeaderString("Pragma"));
991  assertNotNull(entity, "Unexpected result: " + entity);
992  try {
993  JSONObject jsonObj = new JSONObject(entity);
994  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
995  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
996  assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
997  assertTrue(jsonObj.has("id_token"), "Unexpected result: id_token not found");
998  } catch (Exception e) {
999  fail(e.getMessage(), e);
1000  }
1001  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:86
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String authorizationCode4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:88
static String clientId4
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:85

◆ tokenEndpointAuthMethodClientSecretPostFail1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostFail1 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 1: Call to Token Endpoint with Auth Method client_secret_basic should fail.

695  {
696  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
697 
698  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
699  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
700  tokenRequest.setUsername(userId);
701  tokenRequest.setPassword(userSecret);
702  tokenRequest.setScope("email read_stream manage_pages");
703  tokenRequest.setAuthUsername(clientId3);
704  tokenRequest.setAuthPassword(clientSecret3);
705 
706  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
707  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
708 
709  Response response = request
710  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
711  String entity = response.readEntity(String.class);
712 
713  showResponse("tokenEndpointAuthMethodClientSecretPostFail1", response, entity);
714 
715  assertEquals(response.getStatus(), 401, "Unexpected response code.");
716  assertNotNull(entity, "Unexpected result: " + entity);
717  try {
718  JSONObject jsonObj = new JSONObject(entity);
719  assertTrue(jsonObj.has("error"), "The error type is null");
720  assertTrue(jsonObj.has("error_description"), "The error description is null");
721  } catch (JSONException e) {
722  e.printStackTrace();
723  fail(e.getMessage() + "\nResponse was: " + entity);
724  }
725  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
static String clientSecret3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostFail2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostFail2 ( final String  tokenPath,
final String  audience,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 2: Call to Token Endpoint with Auth Method client_secret_jwt should fail.

734  {
735  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
736 
737  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
738  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
739  tokenRequest.setAudience(audience);
740  tokenRequest.setUsername(userId);
741  tokenRequest.setPassword(userSecret);
742  tokenRequest.setScope("email read_stream manage_pages");
743  tokenRequest.setAuthUsername(clientId3);
744  tokenRequest.setAuthPassword(clientSecret3);
745 
746  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
747 
748  Response response = request
749  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
750  String entity = response.readEntity(String.class);
751 
752  showResponse("tokenEndpointAuthMethodClientSecretPostFail2", response, entity);
753 
754  assertEquals(response.getStatus(), 401, "Unexpected response code.");
755  assertNotNull(entity, "Unexpected result: " + entity);
756  try {
757  JSONObject jsonObj = new JSONObject(entity);
758  assertTrue(jsonObj.has("error"), "The error type is null");
759  assertTrue(jsonObj.has("error_description"), "The error description is null");
760  } catch (JSONException e) {
761  e.printStackTrace();
762  fail(e.getMessage() + "\nResponse was: " + entity);
763  }
764  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
static String clientSecret3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostFail3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostFail3 ( final String  tokenPath,
final String  userId,
final String  userSecret,
final String  audience,
final String  keyId,
final String  keyStoreFile,
final String  keyStoreSecret 
) throws Exception
inline

Fail 3: Call to Token Endpoint with Auth Method private_key_jwt should fail.

774  {
775  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
776 
777  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, null);
778 
779  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
780  tokenRequest.setAuthenticationMethod(AuthenticationMethod.PRIVATE_KEY_JWT);
781  tokenRequest.setAlgorithm(SignatureAlgorithm.RS256);
782  tokenRequest.setKeyId(keyId);
783  tokenRequest.setCryptoProvider(cryptoProvider);
784  tokenRequest.setAudience(audience);
785  tokenRequest.setUsername(userId);
786  tokenRequest.setPassword(userSecret);
787  tokenRequest.setScope("email read_stream manage_pages");
788  tokenRequest.setAuthUsername(clientId3);
789  tokenRequest.setAuthPassword(clientSecret3);
790 
791  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
792 
793  Response response = request
794  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
795  String entity = response.readEntity(String.class);
796 
797  showResponse("tokenEndpointAuthMethodClientSecretPostFail3", response, entity);
798 
799  assertEquals(response.getStatus(), 401, "Unexpected response code.");
800  assertNotNull(entity, "Unexpected result: " + entity);
801  try {
802  JSONObject jsonObj = new JSONObject(entity);
803  assertTrue(jsonObj.has("error"), "The error type is null");
804  assertTrue(jsonObj.has("error_description"), "The error description is null");
805  } catch (JSONException e) {
806  e.printStackTrace();
807  fail(e.getMessage() + "\nResponse was: " + entity);
808  }
809  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
static String clientSecret3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostStep1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostStep1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline

Register a client with Token Endpoint Auth Method client_secret_post.

504  {
505  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
506 
507  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
508  StringUtils.spaceSeparatedToList(redirectUris));
509  registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_POST);
510  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
511 
512  String registerRequestContent = registerRequest.getJSONParameters().toString(4);
513 
514  Response response = request.post(Entity.json(registerRequestContent));
515  String entity = response.readEntity(String.class);
516 
517  showResponse("tokenEndpointAuthMethodClientSecretPostStep1", response, entity);
518 
519  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
520  assertNotNull(entity, "Unexpected result: " + entity);
521  try {
522  JSONObject jsonObj = new JSONObject(entity);
523  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
524  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
525  assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
526  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
527  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
528  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
529 
530  clientId3 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
531  clientSecret3 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
532  registrationAccessToken3 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
533  registrationClientUri3 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
534  } catch (JSONException e) {
535  e.printStackTrace();
536  fail(e.getMessage() + "\nResponse was: " + entity);
537  }
538  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationClientUri3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:83
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
static String clientSecret3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:80
static String registrationAccessToken3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:81
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostStep2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostStep2 ( final String  registerPath) throws Exception
inline

Read client to check whether it is using the Token Endpoint Auth Method client_secret_post.

546  {
547 
548  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath + "?"
549  + registrationClientUri3.substring(registrationClientUri3.indexOf("?") + 1)).request();
550  request.header("Authorization", "Bearer " + registrationAccessToken3);
551 
552  Response response = request.get();
553  String entity = response.readEntity(String.class);
554 
555  showResponse("tokenEndpointAuthMethodClientSecretPostStep2", response, entity);
556 
557  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
558  assertNotNull(entity, "Unexpected result: " + entity);
559  try {
560  JSONObject jsonObj = new JSONObject(entity);
561  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
562  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
563  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
564  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
565 
566  // Registered Metadata
567  assertTrue(jsonObj.has(TOKEN_ENDPOINT_AUTH_METHOD.toString()));
568  assertEquals(jsonObj.getString(TOKEN_ENDPOINT_AUTH_METHOD.toString()),
569  AuthenticationMethod.CLIENT_SECRET_POST.toString());
570  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
571  assertTrue(jsonObj.has(RESPONSE_TYPES.toString()));
572  assertTrue(jsonObj.has(REDIRECT_URIS.toString()));
573  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
574  assertTrue(jsonObj.has(CLIENT_NAME.toString()));
575  assertTrue(jsonObj.has(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()));
576  assertTrue(jsonObj.has(SCOPE.toString()));
577  } catch (JSONException e) {
578  e.printStackTrace();
579  fail(e.getMessage() + "\nResponse was: " + entity);
580  }
581  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationClientUri3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:83
static String registrationAccessToken3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:81
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostStep3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostStep3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline

Request authorization code.

589  {
590  List<ResponseType> responseTypes = new ArrayList<ResponseType>();
591  responseTypes.add(ResponseType.CODE);
592  List<String> scopes = new ArrayList<String>();
593  scopes.add("openid");
594  scopes.add("profile");
595  scopes.add("address");
596  scopes.add("email");
597  String state = UUID.randomUUID().toString();
598 
599  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId3, scopes,
600  redirectUri, null);
601  authorizationRequest.setState(state);
602  authorizationRequest.getPrompts().add(Prompt.NONE);
603  authorizationRequest.setAuthUsername(userId);
604  authorizationRequest.setAuthPassword(userSecret);
605 
606  Builder request = ResteasyClientBuilder.newClient()
607  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
608  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
609  request.header("Accept", MediaType.TEXT_PLAIN);
610 
611  Response response = request.get();
612  String entity = response.readEntity(String.class);
613 
614  showResponse("tokenEndpointAuthMethodClientSecretPostStep3", response, entity);
615 
616  assertEquals(response.getStatus(), 302, "Unexpected response code.");
617  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
618 
619  if (response.getLocation() != null) {
620  try {
621  URI uri = new URI(response.getLocation().toString());
622  assertNotNull(uri.getQuery(), "The query string is null");
623 
624  Map<String, String> params = QueryStringDecoder.decode(uri.getQuery());
625 
626  assertNotNull(params.get(AuthorizeResponseParam.CODE), "The code is null");
627  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
628  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
629 
630  authorizationCode3 = params.get(AuthorizeResponseParam.CODE);
631  } catch (URISyntaxException e) {
632  e.printStackTrace();
633  fail("Response URI is not well formed");
634  } catch (Exception e) {
635  e.printStackTrace();
636  fail(e.getMessage());
637  }
638  }
639  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String authorizationCode3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:82
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodClientSecretPostStep4()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodClientSecretPostStep4 ( final String  tokenPath,
final String  redirectUri 
) throws Exception
inline

Call to Token Endpoint with Auth Method client_secret_post.

647  {
648  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
649 
650  TokenRequest tokenRequest = new TokenRequest(GrantType.AUTHORIZATION_CODE);
651  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_POST);
652  tokenRequest.setCode(authorizationCode3);
653  tokenRequest.setRedirectUri(redirectUri);
654  tokenRequest.setAuthUsername(clientId3);
655  tokenRequest.setAuthPassword(clientSecret3);
656 
657  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
658 
659  Response response = request
660  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
661  String entity = response.readEntity(String.class);
662 
663  showResponse("tokenEndpointAuthMethodClientSecretBasicStep4", response, entity);
664 
665  assertEquals(response.getStatus(), 200, "Unexpected response code.");
666  assertTrue(
667  response.getHeaderString("Cache-Control") != null
668  && response.getHeaderString("Cache-Control").equals("no-store"),
669  "Unexpected result: " + response.getHeaderString("Cache-Control"));
670  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
671  "Unexpected result: " + response.getHeaderString("Pragma"));
672  assertNotNull(entity, "Unexpected result: " + entity);
673  try {
674  JSONObject jsonObj = new JSONObject(entity);
675  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
676  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
677  assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
678  assertTrue(jsonObj.has("id_token"), "Unexpected result: id_token not found");
679  } catch (JSONException e) {
680  e.printStackTrace();
681  fail(e.getMessage() + "\nResponse was: " + entity);
682  } catch (Exception e) {
683  e.printStackTrace();
684  fail(e.getMessage());
685  }
686  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String authorizationCode3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:82
static String clientId3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:79
static String clientSecret3
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtFail1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtFail1 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 1: Call to Token Endpoint with Auth Method client_secret_basic should fail.

1329  {
1330  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1331 
1332  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1333  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
1334  tokenRequest.setUsername(userId);
1335  tokenRequest.setPassword(userSecret);
1336  tokenRequest.setScope("email read_stream manage_pages");
1337  tokenRequest.setAuthUsername(clientId5);
1338  tokenRequest.setAuthPassword(clientSecret5);
1339 
1340  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
1341  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1342 
1343  Response response = request
1344  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1345  String entity = response.readEntity(String.class);
1346 
1347  showResponse("tokenEndpointAuthMethodPrivateKeyJwtFail1", response, entity);
1348 
1349  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1350  assertNotNull(entity, "Unexpected result: " + entity);
1351  try {
1352  JSONObject jsonObj = new JSONObject(entity);
1353  assertTrue(jsonObj.has("error"), "The error type is null");
1354  assertTrue(jsonObj.has("error_description"), "The error description is null");
1355  } catch (JSONException e) {
1356  e.printStackTrace();
1357  fail(e.getMessage() + "\nResponse was: " + entity);
1358  }
1359  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:92
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtFail2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtFail2 ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 2: Call to Token Endpoint with Auth Method client_secret_post should fail.

1368  {
1369  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1370 
1371  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1372  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_POST);
1373  tokenRequest.setUsername(userId);
1374  tokenRequest.setPassword(userSecret);
1375  tokenRequest.setScope("email read_stream manage_pages");
1376  tokenRequest.setAuthUsername(clientId5);
1377  tokenRequest.setAuthPassword(clientSecret5);
1378 
1379  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1380 
1381  Response response = request
1382  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1383 
1384  String entity = response.readEntity(String.class);
1385 
1386  showResponse("tokenEndpointAuthMethodPrivateKeyJwtFail2", response, entity);
1387 
1388  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1389  assertNotNull(entity, "Unexpected result: " + entity);
1390  try {
1391  JSONObject jsonObj = new JSONObject(entity);
1392  assertTrue(jsonObj.has("error"), "The error type is null");
1393  assertTrue(jsonObj.has("error_description"), "The error description is null");
1394  } catch (JSONException e) {
1395  e.printStackTrace();
1396  fail(e.getMessage() + "\nResponse was: " + entity);
1397  }
1398  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:92
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtFail3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtFail3 ( final String  tokenPath,
final String  audience,
final String  userId,
final String  userSecret 
) throws Exception
inline

Fail 3: Call to Token Endpoint with Auth Method client_secret_jwt should fail.

1407  {
1408  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1409 
1410  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
1411  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
1412  tokenRequest.setAudience(audience);
1413  tokenRequest.setUsername(userId);
1414  tokenRequest.setPassword(userSecret);
1415  tokenRequest.setScope("email read_stream manage_pages");
1416  tokenRequest.setAuthUsername(clientId5);
1417  tokenRequest.setAuthPassword(clientSecret5);
1418 
1419  Response response = request
1420  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1421  String entity = response.readEntity(String.class);
1422 
1423  showResponse("tokenEndpointAuthMethodPrivateKeyJwtFail3", response, entity);
1424 
1425  assertEquals(response.getStatus(), 401, "Unexpected response code.");
1426  assertNotNull(entity, "Unexpected result: " + entity);
1427  try {
1428  JSONObject jsonObj = new JSONObject(entity);
1429  assertTrue(jsonObj.has("error"), "The error type is null");
1430  assertTrue(jsonObj.has("error_description"), "The error description is null");
1431  } catch (JSONException e) {
1432  e.printStackTrace();
1433  fail(e.getMessage() + "\nResponse was: " + entity);
1434  }
1435  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String clientSecret5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:92
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtStep1()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtStep1 ( final String  registerPath,
final String  redirectUris,
final String  jwksUri 
) throws Exception
inline

Register a client with Token Endpoint Auth Method private_key_jwt.

1132  {
1133  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
1134 
1135  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
1136  StringUtils.spaceSeparatedToList(redirectUris));
1137  registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.PRIVATE_KEY_JWT);
1138  registerRequest.setJwksUri(jwksUri);
1139  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
1140 
1141  String registerRequestContent = registerRequest.getJSONParameters().toString(4);
1142 
1143  Response response = request.post(Entity.json(registerRequestContent));
1144  String entity = response.readEntity(String.class);
1145 
1146  showResponse("tokenEndpointAuthMethodPrivateKeyJwtStep1", response, entity);
1147 
1148  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
1149  assertNotNull(entity, "Unexpected result: " + entity);
1150  try {
1151  JSONObject jsonObj = new JSONObject(entity);
1152  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
1153  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
1154  assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
1155  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
1156  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
1157  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
1158 
1159  clientId5 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
1160  clientSecret5 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
1161  registrationAccessToken5 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
1162  registrationClientUri5 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
1163  } catch (JSONException e) {
1164  e.printStackTrace();
1165  fail(e.getMessage() + "\nResponse was: " + entity);
1166  }
1167  }
static String registrationAccessToken5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:93
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
String jwksUri
Definition: BaseTest.java:80
static String clientSecret5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:92
static String registrationClientUri5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:95
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtStep2()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtStep2 ( final String  registerPath) throws Exception
inline

Read client to check whether it is using the Token Endpoint Auth Method private_key_jwt.

1175  {
1176  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath + "?"
1177  + registrationClientUri5.substring(registrationClientUri5.indexOf("?") + 1)).request();
1178  request.header("Authorization", "Bearer " + registrationAccessToken5);
1179 
1180  Response response = request.get();
1181  String entity = response.readEntity(String.class);
1182 
1183  showResponse("tokenEndpointAuthMethodPrivateKeyJwtStep2", response, entity);
1184 
1185  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
1186  assertNotNull(entity, "Unexpected result: " + entity);
1187  try {
1188  JSONObject jsonObj = new JSONObject(entity);
1189  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
1190  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
1191  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
1192  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
1193 
1194  // Registered Metadata
1195  assertTrue(jsonObj.has(TOKEN_ENDPOINT_AUTH_METHOD.toString()));
1196  assertEquals(jsonObj.getString(TOKEN_ENDPOINT_AUTH_METHOD.toString()),
1197  AuthenticationMethod.PRIVATE_KEY_JWT.toString());
1198  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
1199  assertTrue(jsonObj.has(RESPONSE_TYPES.toString()));
1200  assertTrue(jsonObj.has(REDIRECT_URIS.toString()));
1201  assertTrue(jsonObj.has(APPLICATION_TYPE.toString()));
1202  assertTrue(jsonObj.has(CLIENT_NAME.toString()));
1203  assertTrue(jsonObj.has(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()));
1204  assertTrue(jsonObj.has(SCOPE.toString()));
1205  } catch (JSONException e) {
1206  e.printStackTrace();
1207  fail(e.getMessage() + "\nResponse was: " + entity);
1208  }
1209  }
static String registrationAccessToken5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:93
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String registrationClientUri5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:95
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtStep3()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtStep3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline

Request authorization code.

1217  {
1218  List<ResponseType> responseTypes = new ArrayList<ResponseType>();
1219  responseTypes.add(ResponseType.CODE);
1220  List<String> scopes = new ArrayList<String>();
1221  scopes.add("openid");
1222  scopes.add("profile");
1223  scopes.add("address");
1224  scopes.add("email");
1225  String state = UUID.randomUUID().toString();
1226 
1227  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId5, scopes,
1228  redirectUri, null);
1229  authorizationRequest.setState(state);
1230  authorizationRequest.getPrompts().add(Prompt.NONE);
1231  authorizationRequest.setAuthUsername(userId);
1232  authorizationRequest.setAuthPassword(userSecret);
1233 
1234  Builder request = ResteasyClientBuilder.newClient()
1235  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
1236  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
1237  request.header("Accept", MediaType.TEXT_PLAIN);
1238 
1239  Response response = request.get();
1240  String entity = response.readEntity(String.class);
1241 
1242  showResponse("tokenEndpointAuthMethodPrivateKeyJwtStep3", response, entity);
1243 
1244  assertEquals(response.getStatus(), 302, "Unexpected response code.");
1245  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
1246 
1247  if (response.getLocation() != null) {
1248  try {
1249  URI uri = new URI(response.getLocation().toString());
1250  assertNotNull(uri.getQuery(), "The query string is null");
1251 
1252  Map<String, String> params = QueryStringDecoder.decode(uri.getQuery());
1253 
1254  assertNotNull(params.get(AuthorizeResponseParam.CODE), "The code is null");
1255  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
1256  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
1257 
1258  authorizationCode5 = params.get(AuthorizeResponseParam.CODE);
1259  } catch (URISyntaxException e) {
1260  e.printStackTrace();
1261  fail("Response URI is not well formed");
1262  } catch (Exception e) {
1263  e.printStackTrace();
1264  fail(e.getMessage());
1265  }
1266  }
1267  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String authorizationCode5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:94
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ tokenEndpointAuthMethodPrivateKeyJwtStep4()

void org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.tokenEndpointAuthMethodPrivateKeyJwtStep4 ( final String  tokenPath,
final String  redirectUri,
final String  audience,
final String  keyId,
final String  keyStoreFile,
final String  keyStoreSecret 
) throws Exception
inline

Call to Token Endpoint with Auth Method private_key_jwt.

1276  {
1277  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
1278 
1279  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, null);
1280 
1281  TokenRequest tokenRequest = new TokenRequest(GrantType.AUTHORIZATION_CODE);
1282  tokenRequest.setAuthenticationMethod(AuthenticationMethod.PRIVATE_KEY_JWT);
1283  tokenRequest.setAlgorithm(SignatureAlgorithm.RS256);
1284  tokenRequest.setKeyId(keyId);
1285  tokenRequest.setCryptoProvider(cryptoProvider);
1286  tokenRequest.setAudience(audience);
1287  tokenRequest.setCode(authorizationCode5);
1288  tokenRequest.setRedirectUri(redirectUri);
1289  tokenRequest.setAuthUsername(clientId5);
1290 
1291  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
1292 
1293  Response response = request
1294  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
1295  String entity = response.readEntity(String.class);
1296 
1297  showResponse("tokenEndpointAuthMethodPrivateKeyJwtStep4", response, entity);
1298 
1299  assertEquals(response.getStatus(), 200, "Unexpected response code.");
1300  assertTrue(
1301  response.getHeaderString("Cache-Control") != null
1302  && response.getHeaderString("Cache-Control").equals("no-store"),
1303  "Unexpected result: " + response.getHeaderString("Cache-Control"));
1304  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
1305  "Unexpected result: " + response.getHeaderString("Pragma"));
1306  assertNotNull(entity, "Unexpected result: " + entity);
1307  try {
1308  JSONObject jsonObj = new JSONObject(entity);
1309  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
1310  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
1311  assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
1312  assertTrue(jsonObj.has("id_token"), "Unexpected result: id_token not found");
1313  } catch (JSONException e) {
1314  e.printStackTrace();
1315  fail(e.getMessage() + "\nResponse was: " + entity);
1316  } catch (Exception e) {
1317  e.printStackTrace();
1318  fail(e.getMessage());
1319  }
1320  }
URI url
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:67
static String authorizationCode5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:94
static String clientId5
Definition: TokenEndpointAuthMethodRestrictionEmbeddedTest.java:91
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ waitForResourceOwnerAndGrantLoginForm() [1/2]

String org.xdi.oxauth.BaseTest.waitForResourceOwnerAndGrantLoginForm ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
boolean  cleanupCookies 
)
inlineinherited

Try to open login form (via the user-agent)

617  {
618  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
619 
620  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
621  authorizeClient.setRequest(authorizationRequest);
622 
623  System.out.println("waitForResourceOwnerAndGrantLoginForm: authorizationRequestUrl:" + authorizationRequestUrl);
624  startSelenium();
625  if (cleanupCookies) {
626  System.out.println("waitForResourceOwnerAndGrantLoginForm: Cleaning cookies");
628  }
629  driver.navigate().to(authorizationRequestUrl);
630 
631  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
632  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
633  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
634 
635  if ((usernameElement == null) || (passwordElement == null) || (loginButton == null)) {
636  return null;
637  }
638 
639  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
640  String sessionState = null;
641  if (sessionStateCookie != null) {
642  sessionState = sessionStateCookie.getValue();
643  }
644  System.out.println("waitForResourceOwnerAndGrantLoginForm: sessionState:" + sessionState);
645 
646  stopSelenium();
647 
648  showClientUserAgent(authorizeClient);
649 
650  return sessionState;
651  }
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void deleteAllCookies()
Definition: BaseTest.java:661
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
void setRequest(T request)
Definition: BaseClient.java:68
WebDriver driver
Definition: BaseTest.java:70
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ waitForResourceOwnerAndGrantLoginForm() [2/2]

String org.xdi.oxauth.BaseTest.waitForResourceOwnerAndGrantLoginForm ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited

Try to open login form (via the user-agent)

657  {
658  return waitForResourceOwnerAndGrantLoginForm(authorizeUrl, authorizationRequest, true);
659  }
String waitForResourceOwnerAndGrantLoginForm(String authorizeUrl, AuthorizationRequest authorizationRequest, boolean cleanupCookies)
Definition: BaseTest.java:616

メンバ詳解

◆ authorizationCode2

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.authorizationCode2
staticprivate

◆ authorizationCode3

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.authorizationCode3
staticprivate

◆ authorizationCode4

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.authorizationCode4
staticprivate

◆ authorizationCode5

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.authorizationCode5
staticprivate

◆ authorizationEndpoint

String org.xdi.oxauth.BaseTest.authorizationEndpoint
protectedinherited

◆ authorizationPageEndpoint

String org.xdi.oxauth.BaseTest.authorizationPageEndpoint
protectedinherited

◆ checkSessionIFrame

String org.xdi.oxauth.BaseTest.checkSessionIFrame
protectedinherited

◆ clientId1

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientId1
staticprivate

◆ clientId2

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientId2
staticprivate

◆ clientId3

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientId3
staticprivate

◆ clientId4

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientId4
staticprivate

◆ clientId5

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientId5
staticprivate

◆ clientInfoEndpoint

String org.xdi.oxauth.BaseTest.clientInfoEndpoint
protectedinherited

◆ clientSecret2

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientSecret2
staticprivate

◆ clientSecret3

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientSecret3
staticprivate

◆ clientSecret4

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientSecret4
staticprivate

◆ clientSecret5

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.clientSecret5
staticprivate

◆ configurationEndpoint

String org.xdi.oxauth.BaseTest.configurationEndpoint
protectedinherited

◆ driver

WebDriver org.xdi.oxauth.BaseTest.driver
protectedinherited

◆ endSessionEndpoint

String org.xdi.oxauth.BaseTest.endSessionEndpoint
protectedinherited

◆ gluuConfigurationEndpoint

String org.xdi.oxauth.BaseTest.gluuConfigurationEndpoint
protectedinherited

◆ idGenEndpoint

String org.xdi.oxauth.BaseTest.idGenEndpoint
protectedinherited

◆ introspectionEndpoint

String org.xdi.oxauth.BaseTest.introspectionEndpoint
protectedinherited

◆ jwksUri

String org.xdi.oxauth.BaseTest.jwksUri
protectedinherited

◆ registrationAccessToken1

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationAccessToken1
staticprivate

◆ registrationAccessToken2

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationAccessToken2
staticprivate

◆ registrationAccessToken3

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationAccessToken3
staticprivate

◆ registrationAccessToken4

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationAccessToken4
staticprivate

◆ registrationAccessToken5

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationAccessToken5
staticprivate

◆ registrationClientUri1

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationClientUri1
staticprivate

◆ registrationClientUri2

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationClientUri2
staticprivate

◆ registrationClientUri3

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationClientUri3
staticprivate

◆ registrationClientUri4

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationClientUri4
staticprivate

◆ registrationClientUri5

String org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.registrationClientUri5
staticprivate

◆ registrationEndpoint

String org.xdi.oxauth.BaseTest.registrationEndpoint
protectedinherited

◆ scopeToClaimsMapping

Map<String, List<String> > org.xdi.oxauth.BaseTest.scopeToClaimsMapping
protectedinherited

◆ testData

FileConfiguration org.xdi.oxauth.ConfigurableTest.testData
staticinherited

◆ tokenEndpoint

String org.xdi.oxauth.BaseTest.tokenEndpoint
protectedinherited

◆ url

URI org.xdi.oxauth.ws.rs.TokenEndpointAuthMethodRestrictionEmbeddedTest.url
private

◆ userInfoEndpoint

String org.xdi.oxauth.BaseTest.userInfoEndpoint
protectedinherited

このクラス詳解は次のファイルから抽出されました: