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

公開メンバ関数

void dynamicClientRegistration (final String registerPath, final String redirectUris) throws Exception
 
void requestParameterMethod1Step1 (final String registerPath, final String redirectUris) throws Exception
 
void requestParameterMethod1Step2 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethodUserInfo (final String userInfoPath) throws Exception
 
void requestParameterMethod2Step1 (final String registerPath, final String redirectUris) throws Exception
 
void requestParameterMethod2Step2 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethod2Step3 (final String userInfoPath) throws Exception
 
void requestParameterMethodFail1 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethodFail2 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethodFail3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethodFail4 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestParameterMethodWithMaxAgeRestriction (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestFileMethod (final String authorizePath, final String userId, final String userSecret, final String redirectUri, @Optional final String requestFileBasePath, @Optional final String requestFileBaseUrl) throws Exception
 
void requestFileMethodFail1 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) throws Exception
 
void requestFileMethodFail2 (final String authorizePath, final String userId, final String userSecret, final String redirectUri, @Optional final String requestFileBaseUrl) throws Exception
 
void requestFileMethodFail3 (final String authorizePath, final String userId, final String userSecret, final String redirectUri, @Optional final String requestFileBasePath, @Optional final String requestFileBaseUrl) throws Exception
 
void requestParameterMethodAlgNoneStep1 (final String registerPath, final String redirectUris) throws Exception
 
void requestParameterMethodAlgNoneStep2 (final String authorizePath, final String userId, final String userSecret, final String redirectUri) 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 clientId
 
static String clientSecret
 
static String accessToken1
 
static String accessToken2
 
static String clientId1
 
static String clientSecret1
 
static String clientId2
 
static String clientSecret2
 
static String clientId3
 

詳解

Functional tests for OpenID Request Object (embedded)

著者
Javier Rojas Blum
バージョン
December 12, 2016

関数詳解

◆ 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

◆ dynamicClientRegistration()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.dynamicClientRegistration ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline
89  {
90  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
91 
92  String registerRequestContent = null;
93  try {
94  List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.TOKEN,
95  ResponseType.ID_TOKEN);
96 
97  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
98  StringUtils.spaceSeparatedToList(redirectUris));
99  registerRequest.setResponseTypes(responseTypes);
100  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
101 
102  registerRequestContent = registerRequest.getJSONParameters().toString(4);
103  } catch (JSONException e) {
104  e.printStackTrace();
105  fail(e.getMessage());
106  }
107 
108  Response response = request.post(Entity.json(registerRequestContent));
109  String entity = response.readEntity(String.class);
110 
111  showResponse("dynamicClientRegistration", response, entity);
112 
113  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
114  assertNotNull(entity, "Unexpected result: " + entity);
115  try {
116  final RegisterResponse registerResponse = RegisterResponse.valueOf(entity);
117  ClientTestUtil.assert_(registerResponse);
118 
119  clientId = registerResponse.getClientId();
120  clientSecret = registerResponse.getClientSecret();
121  } catch (Exception e) {
122  e.printStackTrace();
123  fail(e.getMessage() + "\nResponse was: " + entity);
124  }
125  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ 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  }

◆ output()

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

◆ requestFileMethod()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestFileMethod ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri,
@Optional final String  requestFileBasePath,
@Optional final String  requestFileBaseUrl 
) throws Exception
inline
772  {
773  if (StringHelper.isEmpty(requestFileBasePath) || StringHelper.isEmpty(requestFileBaseUrl)) {
774  return;
775  }
776 
777  final String state = UUID.randomUUID().toString();
778 
779  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
780  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
781  String nonce = UUID.randomUUID().toString();
782 
783  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
784  redirectUri, nonce);
785  authorizationRequest.setState(state);
786  authorizationRequest.getPrompts().add(Prompt.NONE);
787  authorizationRequest.setAuthUsername(userId);
788  authorizationRequest.setAuthPassword(userSecret);
789 
790  try {
791  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
792 
793  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
794  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
795  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
796  jwtAuthorizationRequest
797  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
798  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
799  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
800  jwtAuthorizationRequest
801  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
802  jwtAuthorizationRequest
803  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
804  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
805  ClaimValue.createValueList(new String[] { "2" })));
806  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
807  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
808  String hash = Base64Util.base64urlencode(JwtUtil.getMessageDigestSHA256(authJwt));
809  String fileName = UUID.randomUUID().toString() + ".txt";
810  String filePath = requestFileBasePath + File.separator + fileName;
811  String fileUrl = requestFileBaseUrl + "/" + fileName + "#" + hash;
812  FileWriter fw = new FileWriter(filePath);
813  BufferedWriter bw = new BufferedWriter(fw);
814  bw.write(authJwt);
815  bw.close();
816  fw.close();
817  authorizationRequest.setRequestUri(fileUrl);
818  System.out.println("Request JWT: " + authJwt);
819  System.out.println("Request File Path: " + filePath);
820  System.out.println("Request File URL: " + fileUrl);
821  } catch (Exception e) {
822  fail(e.getMessage(), e);
823  }
824 
825  Builder request = ResteasyClientBuilder.newClient()
826  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
827  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
828  request.header("Accept", MediaType.TEXT_PLAIN);
829 
830  Response response = request.get();
831  String entity = response.readEntity(String.class);
832 
833  showResponse("requestFileMethod", response, entity);
834 
835  assertEquals(response.getStatus(), 302, "Unexpected response code.");
836  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
837 
838  try {
839  URI uri = new URI(response.getLocation().toString());
840  assertNotNull(uri.getFragment(), "Query string is null");
841 
842  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
843 
844  assertNotNull(params.get("access_token"), "The accessToken is null");
845  assertNotNull(params.get("id_token"), "The idToken is null");
846  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
847  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
848  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
849  } catch (URISyntaxException e) {
850  e.printStackTrace();
851  fail("Response URI is not well formed");
852  } catch (Exception e) {
853  e.printStackTrace();
854  fail("Response URI is not well formed");
855  }
856  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestFileMethodFail1()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestFileMethodFail1 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
861  {
862 
863  final String state = UUID.randomUUID().toString();
864 
865  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
866  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
867  String nonce = UUID.randomUUID().toString();
868 
869  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
870  redirectUri, nonce);
871  authorizationRequest.setState(state);
872  authorizationRequest.getPrompts().add(Prompt.NONE);
873  authorizationRequest.setAuthUsername(userId);
874  authorizationRequest.setAuthPassword(userSecret);
875 
876  authorizationRequest.setRequest("FAKE_REQUEST");
877  authorizationRequest.setRequestUri("FAKE_REQUEST_URI");
878 
879  Builder request = ResteasyClientBuilder.newClient()
880  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
881  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
882  request.header("Accept", MediaType.TEXT_PLAIN);
883 
884  Response response = request.get();
885  String entity = response.readEntity(String.class);
886 
887  showResponse("requestFileMethodFail1", response, entity);
888 
889  assertEquals(response.getStatus(), 302, "Unexpected response code.");
890  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
891 
892  if (response.getLocation() != null) {
893  try {
894  URI uri = new URI(response.getLocation().toString());
895  assertNotNull(uri.getFragment(), "Fragment is null");
896 
897  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
898 
899  assertNotNull(params.get("error"), "The error value is null");
900  assertNotNull(params.get("error_description"), "The errorDescription value is null");
901  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
902  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
903  } catch (URISyntaxException e) {
904  e.printStackTrace();
905  fail("Response URI is not well formed");
906  }
907  }
908  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestFileMethodFail2()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestFileMethodFail2 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri,
@Optional final String  requestFileBaseUrl 
) throws Exception
inline
913  {
914  if (StringHelper.isEmpty(requestFileBaseUrl)) {
915  return;
916  }
917 
918  final String state = UUID.randomUUID().toString();
919 
920  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
921  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
922  String nonce = UUID.randomUUID().toString();
923 
924  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
925  redirectUri, nonce);
926  authorizationRequest.setState(state);
927  authorizationRequest.getPrompts().add(Prompt.NONE);
928  authorizationRequest.setAuthUsername(userId);
929  authorizationRequest.setAuthPassword(userSecret);
930 
931  authorizationRequest.setRequestUri(requestFileBaseUrl + "/FAKE_REQUEST_URI");
932 
933  Builder request = ResteasyClientBuilder.newClient()
934  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
935  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
936  request.header("Accept", MediaType.TEXT_PLAIN);
937 
938  Response response = request.get();
939  String entity = response.readEntity(String.class);
940 
941  showResponse("requestFileMethodFail2", response, entity);
942 
943  assertEquals(response.getStatus(), 302, "Unexpected response code.");
944  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
945 
946  if (response.getLocation() != null) {
947  try {
948  URI uri = new URI(response.getLocation().toString());
949  assertNotNull(uri.getFragment(), "Fragment is null");
950 
951  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
952 
953  assertNotNull(params.get("error"), "The error value is null");
954  assertNotNull(params.get("error_description"), "The errorDescription value is null");
955  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
956  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
957  } catch (URISyntaxException e) {
958  e.printStackTrace();
959  fail("Response URI is not well formed");
960  }
961  }
962  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestFileMethodFail3()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestFileMethodFail3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri,
@Optional final String  requestFileBasePath,
@Optional final String  requestFileBaseUrl 
) throws Exception
inline
969  {
970  if (StringHelper.isEmpty(requestFileBasePath) || StringHelper.isEmpty(requestFileBaseUrl)) {
971  return;
972  }
973 
974  final String state = UUID.randomUUID().toString();
975 
976  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
977  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
978  String nonce = UUID.randomUUID().toString();
979 
980  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
981  redirectUri, nonce);
982  authorizationRequest.setState(state);
983  authorizationRequest.getPrompts().add(Prompt.NONE);
984  authorizationRequest.setAuthUsername(userId);
985  authorizationRequest.setAuthPassword(userSecret);
986 
987  try {
988  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
989 
990  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
991  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
992  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
993  jwtAuthorizationRequest
994  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
995  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
996  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
997  jwtAuthorizationRequest
998  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
999  jwtAuthorizationRequest
1000  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
1001  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
1002  ClaimValue.createValueList(new String[] { "2" })));
1003  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
1004  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
1005  String hash = "INVALID_HASH";
1006  String fileName = UUID.randomUUID().toString() + ".txt";
1007  String filePath = requestFileBasePath + File.separator + fileName;
1008  String fileUrl = requestFileBaseUrl + "/" + fileName + "#" + hash;
1009  FileWriter fw = new FileWriter(filePath);
1010  BufferedWriter bw = new BufferedWriter(fw);
1011  bw.write(authJwt);
1012  bw.close();
1013  fw.close();
1014  authorizationRequest.setRequestUri(fileUrl);
1015  System.out.println("Request JWT: " + authJwt);
1016  System.out.println("Request File Path: " + filePath);
1017  System.out.println("Request File URL: " + fileUrl);
1018  } catch (Exception e) {
1019  e.printStackTrace();
1020  fail(e.getMessage(), e);
1021  }
1022 
1023  Builder request = ResteasyClientBuilder.newClient()
1024  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
1025  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
1026  request.header("Accept", MediaType.TEXT_PLAIN);
1027 
1028  Response response = request.get();
1029  String entity = response.readEntity(String.class);
1030 
1031  showResponse("requestFileMethodFail3", response, entity);
1032 
1033  assertEquals(response.getStatus(), 302, "Unexpected response code.");
1034  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
1035 
1036  if (response.getLocation() != null) {
1037  try {
1038  URI uri = new URI(response.getLocation().toString());
1039  assertNotNull(uri.getFragment(), "Fragment is null");
1040 
1041  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
1042 
1043  assertNotNull(params.get("error"), "The error value is null");
1044  assertNotNull(params.get("error_description"), "The errorDescription value is null");
1045  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
1046  assertNotNull(params.get(AuthorizeResponseParam.STATE), state);
1047  } catch (URISyntaxException e) {
1048  e.printStackTrace();
1049  fail("Response URI is not well formed");
1050  }
1051  }
1052  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestParameterMethod1Step1()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethod1Step1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline
129  {
130  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
131 
132  String registerRequestContent = null;
133  try {
134  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
135 
136  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
137  StringUtils.spaceSeparatedToList(redirectUris));
138  registerRequest.setResponseTypes(responseTypes);
139  registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.HS256);
140  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
141 
142  registerRequestContent = registerRequest.getJSONParameters().toString(4);
143  } catch (JSONException e) {
144  e.printStackTrace();
145  fail(e.getMessage());
146  }
147 
148  Response response = request.post(Entity.json(registerRequestContent));
149  String entity = response.readEntity(String.class);
150 
151  showResponse("requestParameterMethod1Step1", response, entity);
152 
153  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
154  assertNotNull(entity, "Unexpected result: " + entity);
155  try {
156  JSONObject jsonObj = new JSONObject(entity);
157  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
158  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
159  assertTrue(jsonObj.has(REGISTRATION_ACCESS_TOKEN.toString()));
160  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
161  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
162  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
163 
164  clientId1 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
165  clientSecret1 = jsonObj.getString(CLIENT_SECRET.toString());
166  } catch (JSONException e) {
167  e.printStackTrace();
168  fail(e.getMessage() + "\nResponse was: " + entity);
169  }
170  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId1
Definition: OpenIDRequestObjectEmbeddedTest.java:81
static String clientSecret1
Definition: OpenIDRequestObjectEmbeddedTest.java:82

◆ requestParameterMethod1Step2()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethod1Step2 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
175  {
176  final String state = UUID.randomUUID().toString();
177 
178  Builder request = null;
179  try {
180  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
181  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
182  String nonce = UUID.randomUUID().toString();
183 
184  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId1, scopes,
185  redirectUri, nonce);
186  authorizationRequest.setState(state);
187  authorizationRequest.getPrompts().add(Prompt.NONE);
188  authorizationRequest.setAuthUsername(userId);
189  authorizationRequest.setAuthPassword(userSecret);
190 
191  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
192 
193  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
194  SignatureAlgorithm.HS256, clientSecret1, cryptoProvider);
195  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
196  jwtAuthorizationRequest
197  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
198  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
199  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
200  jwtAuthorizationRequest
201  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
202  jwtAuthorizationRequest
203  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
204  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
205  ClaimValue.createValueList(new String[] { "2" })));
206  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
207  authorizationRequest.setRequest(authJwt);
208  System.out.println("Request JWT: " + authJwt);
209 
210  request = ResteasyClientBuilder.newClient()
211  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
212  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
213  request.header("Accept", MediaType.TEXT_PLAIN);
214  } catch (Exception e) {
215  fail(e.getMessage(), e);
216  }
217 
218  Response response = request.get();
219  String entity = response.readEntity(String.class);
220 
221  showResponse("requestParameterMethod1Step2", response, entity);
222 
223  assertEquals(response.getStatus(), 302, "Unexpected response code.");
224  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
225 
226  try {
227  URI uri = new URI(response.getLocation().toString());
228  assertNotNull(uri.getFragment(), "Query string is null");
229 
230  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
231 
232  assertNotNull(params.get(AuthorizeResponseParam.ACCESS_TOKEN), "The accessToken is null");
233  assertNotNull(params.get(AuthorizeResponseParam.ID_TOKEN), "The idToken is null");
234  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
235  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
236  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
237 
238  accessToken1 = params.get(AuthorizeResponseParam.ACCESS_TOKEN);
239  } catch (URISyntaxException e) {
240  e.printStackTrace();
241  fail("Response URI is not well formed");
242  }
243  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String accessToken1
Definition: OpenIDRequestObjectEmbeddedTest.java:79
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId1
Definition: OpenIDRequestObjectEmbeddedTest.java:81
static String clientSecret1
Definition: OpenIDRequestObjectEmbeddedTest.java:82

◆ requestParameterMethod2Step1()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethod2Step1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline
287  {
288  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
289 
290  String registerRequestContent = null;
291  try {
292  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN);
293 
294  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
295  StringUtils.spaceSeparatedToList(redirectUris));
296  registerRequest.setResponseTypes(responseTypes);
297  registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.HS256);
298  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
299 
300  registerRequestContent = registerRequest.getJSONParameters().toString(4);
301  } catch (JSONException e) {
302  e.printStackTrace();
303  fail(e.getMessage());
304  }
305 
306  Response response = request.post(Entity.json(registerRequestContent));
307  String entity = response.readEntity(String.class);
308 
309  showResponse("requestParameterMethod2Step1", response, entity);
310 
311  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
312  assertNotNull(entity, "Unexpected result: " + entity);
313  try {
314  JSONObject jsonObj = new JSONObject(entity);
315  assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
316  assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
317  assertTrue(jsonObj.has(REGISTRATION_ACCESS_TOKEN.toString()));
318  assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
319  assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
320  assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
321 
322  clientId2 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
323  clientSecret2 = jsonObj.getString(CLIENT_SECRET.toString());
324  } catch (JSONException e) {
325  e.printStackTrace();
326  fail(e.getMessage() + "\nResponse was: " + entity);
327  }
328  }
static String clientSecret2
Definition: OpenIDRequestObjectEmbeddedTest.java:84
static String clientId2
Definition: OpenIDRequestObjectEmbeddedTest.java:83
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethod2Step2()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethod2Step2 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
333  {
334  final String state = UUID.randomUUID().toString();
335 
336  Builder request = null;
337  try {
338  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN);
339  List<String> scopes = Arrays.asList("openid", "profile");
340  String nonce = UUID.randomUUID().toString();
341 
342  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId2, scopes,
343  redirectUri, nonce);
344  authorizationRequest.setState(state);
345  authorizationRequest.getPrompts().add(Prompt.NONE);
346  authorizationRequest.setAuthUsername(userId);
347  authorizationRequest.setAuthPassword(userSecret);
348 
349  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
350 
351  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
352  SignatureAlgorithm.HS256, clientSecret2, cryptoProvider);
353  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
354  jwtAuthorizationRequest.addUserInfoClaim(new Claim("name", ClaimValue.createEssential(true)));
355  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
356  authorizationRequest.setRequest(authJwt);
357  System.out.println("Request JWT: " + authJwt);
358 
359  request = ResteasyClientBuilder.newClient()
360  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
361  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
362  request.header("Accept", MediaType.TEXT_PLAIN);
363  } catch (Exception e) {
364  fail(e.getMessage(), e);
365  }
366 
367  Response response = request.get();
368  String entity = response.readEntity(String.class);
369 
370  showResponse("requestParameterMethod2Step2", response, entity);
371 
372  assertEquals(response.getStatus(), 302, "Unexpected response code.");
373  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
374 
375  try {
376  URI uri = new URI(response.getLocation().toString());
377  assertNotNull(uri.getFragment(), "Query string is null");
378 
379  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
380 
381  assertNotNull(params.get(AuthorizeResponseParam.ACCESS_TOKEN), "The accessToken is null");
382  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
383  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
384  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
385 
386  accessToken2 = params.get(AuthorizeResponseParam.ACCESS_TOKEN);
387  } catch (URISyntaxException e) {
388  e.printStackTrace();
389  fail("Response URI is not well formed");
390  }
391  }
static String clientSecret2
Definition: OpenIDRequestObjectEmbeddedTest.java:84
static String clientId2
Definition: OpenIDRequestObjectEmbeddedTest.java:83
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String accessToken2
Definition: OpenIDRequestObjectEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethod2Step3()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethod2Step3 ( final String  userInfoPath) throws Exception
inline
395  {
396  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request();
397  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
398 
399  UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken2);
400  userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
401 
402  Response response = request
403  .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters())));
404  String entity = response.readEntity(String.class);
405 
406  showResponse("requestParameterMethod2Step3", response, entity);
407 
408  assertEquals(response.getStatus(), 200, "Unexpected response code.");
409  assertTrue(
410  response.getHeaderString("Cache-Control") != null
411  && response.getHeaderString("Cache-Control").equals("no-store, private"),
412  "Unexpected result: " + response.getHeaderString("Cache-Control"));
413  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
414  "Unexpected result: " + response.getHeaderString("Pragma"));
415  assertNotNull(entity, "Unexpected result: " + entity);
416  try {
417  JSONObject jsonObj = new JSONObject(entity);
418  assertTrue(jsonObj.has(JwtClaimName.SUBJECT_IDENTIFIER));
419  assertTrue(jsonObj.has(JwtClaimName.NAME));
420  } catch (JSONException e) {
421  e.printStackTrace();
422  fail(e.getMessage() + "\nResponse was: " + entity);
423  } catch (Exception e) {
424  e.printStackTrace();
425  fail(e.getMessage());
426  }
427  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String accessToken2
Definition: OpenIDRequestObjectEmbeddedTest.java:80
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethodAlgNoneStep1()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodAlgNoneStep1 ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline
1057  {
1058 
1059  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
1060 
1061  String registerRequestContent = null;
1062  try {
1063  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN);
1064 
1065  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
1066  StringUtils.spaceSeparatedToList(redirectUris));
1067  registerRequest.setResponseTypes(responseTypes);
1068  registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.NONE);
1069  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
1070 
1071  registerRequestContent = registerRequest.getJSONParameters().toString(4);
1072  } catch (JSONException e) {
1073  e.printStackTrace();
1074  fail(e.getMessage());
1075  }
1076 
1077  Response response = request.post(Entity.json(registerRequestContent));
1078  String entity = response.readEntity(String.class);
1079 
1080  showResponse("requestParameterMethodAlgNoneStep1", response, entity);
1081 
1082  ResponseAsserter responseAsserter = ResponseAsserter.of(response.getStatus(), entity);
1083  responseAsserter.assertRegisterResponse();
1084  clientId3 = responseAsserter.getJson().getJson().getString(RegisterResponseParam.CLIENT_ID.toString());
1085  }
static String clientId3
Definition: OpenIDRequestObjectEmbeddedTest.java:85
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethodAlgNoneStep2()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodAlgNoneStep2 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
1090  {
1091 
1092  final String state = UUID.randomUUID().toString();
1093 
1094  Builder request = null;
1095  try {
1096  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN);
1097  List<String> scopes = Arrays.asList("openid");
1098  String nonce = UUID.randomUUID().toString();
1099 
1100  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId3, scopes,
1101  redirectUri, nonce);
1102  authorizationRequest.setState(state);
1103  authorizationRequest.getPrompts().add(Prompt.NONE);
1104  authorizationRequest.setAuthUsername(userId);
1105  authorizationRequest.setAuthPassword(userSecret);
1106 
1107  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
1108 
1109  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
1110  SignatureAlgorithm.NONE, cryptoProvider);
1111  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
1112  jwtAuthorizationRequest
1113  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
1114  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
1115  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
1116  jwtAuthorizationRequest
1117  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
1118  jwtAuthorizationRequest
1119  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
1120  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
1121  ClaimValue.createValueList(new String[] { "2" })));
1122  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
1123  authorizationRequest.setRequest(authJwt);
1124  System.out.println("Request JWT: " + authJwt);
1125 
1126  request = ResteasyClientBuilder.newClient()
1127  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
1128  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
1129  request.header("Accept", MediaType.TEXT_PLAIN);
1130  } catch (Exception e) {
1131  fail(e.getMessage(), e);
1132  }
1133 
1134  Response response = request.get();
1135  String entity = response.readEntity(String.class);
1136 
1137  showResponse("requestParameterMethodAlgNoneStep2", response, entity);
1138 
1139  assertEquals(response.getStatus(), 302, "Unexpected response code.");
1140  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
1141 
1142  try {
1143  URI uri = new URI(response.getLocation().toString());
1144  assertNotNull(uri.getFragment(), "Query string is null");
1145 
1146  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
1147 
1148  assertNotNull(params.get(AuthorizeResponseParam.ACCESS_TOKEN), "The accessToken is null");
1149  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
1150  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
1151  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
1152  } catch (URISyntaxException e) {
1153  e.printStackTrace();
1154  fail("Response URI is not well formed");
1155  }
1156  }
static String clientId3
Definition: OpenIDRequestObjectEmbeddedTest.java:85
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethodFail1()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodFail1 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
432  {
433  final String state = UUID.randomUUID().toString();
434 
435  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
436  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
437  String nonce = UUID.randomUUID().toString();
438 
439  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
440  redirectUri, nonce);
441  authorizationRequest.setState(state);
442  authorizationRequest.setRequest("INVALID_OPENID_REQUEST_OBJECT");
443  authorizationRequest.setAuthUsername(userId);
444  authorizationRequest.setAuthPassword(userSecret);
445 
446  Builder request = ResteasyClientBuilder.newClient()
447  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
448  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
449  request.header("Accept", MediaType.TEXT_PLAIN);
450 
451  Response response = request.get();
452  String entity = response.readEntity(String.class);
453 
454  showResponse("requestParameterMethodFail1 (Invalid OpenID Request Object)", response, entity);
455 
456  assertEquals(response.getStatus(), 302, "Unexpected response code.");
457  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
458 
459  if (response.getLocation() != null) {
460  try {
461  URI uri = new URI(response.getLocation().toString());
462  assertNotNull(uri.getFragment(), "Fragment is null");
463 
464  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
465 
466  assertNotNull(params.get("error"), "The error value is null");
467  assertNotNull(params.get("error_description"), "The errorDescription value is null");
468  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
469  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
470  } catch (URISyntaxException e) {
471  e.printStackTrace();
472  fail("Response URI is not well formed");
473  }
474  }
475  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestParameterMethodFail2()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodFail2 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
480  {
481 
482  final String state = UUID.randomUUID().toString();
483 
484  Builder request = null;
485  try {
486 
487  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
488  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
489  String nonce = UUID.randomUUID().toString();
490 
491  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
492  redirectUri, nonce);
493  authorizationRequest.setState(state);
494  authorizationRequest.setAuthUsername(userId);
495  authorizationRequest.setAuthPassword(userSecret);
496 
497  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
498 
499  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
500  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
501  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
502  jwtAuthorizationRequest
503  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
504  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
505  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
506  jwtAuthorizationRequest
507  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
508  jwtAuthorizationRequest
509  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
510  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
511  ClaimValue.createValueList(new String[] { "2" })));
512  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
513  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
514  authorizationRequest.setRequest(authJwt + "INVALID_SIGNATURE");
515  System.out.println("Request JWT: " + authJwt);
516 
517  request = ResteasyClientBuilder.newClient()
518  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
519  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
520  request.header("Accept", MediaType.TEXT_PLAIN);
521  } catch (Exception e) {
522  fail(e.getMessage(), e);
523  }
524 
525  Response response = request.get();
526  String entity = response.readEntity(String.class);
527 
528  showResponse("requestParameterMethodFail2 (Invalid OpenID Request Object, due to invalid signature)", response,
529  entity);
530 
531  assertEquals(response.getStatus(), 302, "Unexpected response code.");
532  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
533 
534  if (response.getLocation() != null) {
535  try {
536  URI uri = new URI(response.getLocation().toString());
537  assertNotNull(uri.getFragment(), "Fragment is null");
538 
539  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
540 
541  assertNotNull(params.get("error"), "The error value is null");
542  assertNotNull(params.get("error_description"), "The errorDescription value is null");
543  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
544  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
545  } catch (URISyntaxException e) {
546  e.printStackTrace();
547  fail("Response URI is not well formed");
548  }
549  }
550  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestParameterMethodFail3()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodFail3 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
555  {
556 
557  final String state = UUID.randomUUID().toString();
558 
559  Builder request = null;
560  try {
561  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
562  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
563  String nonce = UUID.randomUUID().toString();
564 
565  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
566  redirectUri, nonce);
567  authorizationRequest.setState(state);
568  authorizationRequest.setAuthUsername(userId);
569  authorizationRequest.setAuthPassword(userSecret);
570 
571  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
572 
573  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
574  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
575  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
576  jwtAuthorizationRequest
577  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
578  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
579  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
580  jwtAuthorizationRequest
581  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
582  jwtAuthorizationRequest
583  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
584  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
585  ClaimValue.createValueList(new String[] { "2" })));
586  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
587  jwtAuthorizationRequest.setClientId("INVALID_CLIENT_ID");
588  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
589  authorizationRequest.setRequest(authJwt);
590  System.out.println("Request JWT: " + authJwt);
591 
592  request = ResteasyClientBuilder.newClient()
593  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
594 
595  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
596  request.header("Accept", MediaType.TEXT_PLAIN);
597  } catch (Exception e) {
598  fail(e.getMessage(), e);
599  }
600 
601  Response response = request.get();
602  String entity = response.readEntity(String.class);
603 
604  showResponse("requestParameterMethodFail3 (Invalid OpenID Request Object)", response, entity);
605 
606  assertEquals(response.getStatus(), 302, "Unexpected response code.");
607  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
608 
609  if (response.getLocation() != null) {
610  try {
611  URI uri = new URI(response.getLocation().toString());
612  assertNotNull(uri.getFragment(), "Fragment is null");
613 
614  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
615 
616  assertNotNull(params.get("error"), "The error value is null");
617  assertNotNull(params.get("error_description"), "The errorDescription value is null");
618  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
619  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
620  } catch (URISyntaxException e) {
621  e.printStackTrace();
622  fail("Response URI is not well formed");
623  }
624  }
625  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestParameterMethodFail4()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodFail4 ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
630  {
631 
632  final String state = UUID.randomUUID().toString();
633 
634  Builder request = null;
635  try {
636  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN);
637  List<String> scopes = Arrays.asList("openid");
638  String nonce = UUID.randomUUID().toString();
639 
640  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
641  redirectUri, nonce);
642  authorizationRequest.setState(state);
643  authorizationRequest.getPrompts().add(Prompt.NONE);
644  authorizationRequest.setAuthUsername(userId);
645  authorizationRequest.setAuthPassword(userSecret);
646 
647  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
648 
649  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
650  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
651  jwtAuthorizationRequest.addIdTokenClaim(
652  new Claim(JwtClaimName.SUBJECT_IDENTIFIER, ClaimValue.createSingleValue("INVALID_USER_ID")));
653  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
654  authorizationRequest.setRequest(authJwt);
655  System.out.println("Request JWT: " + authJwt);
656 
657  request = ResteasyClientBuilder.newClient()
658  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
659  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
660  request.header("Accept", MediaType.TEXT_PLAIN);
661  } catch (Exception e) {
662  fail(e.getMessage(), e);
663  }
664 
665  Response response = request.get();
666  String entity = response.readEntity(String.class);
667 
668  showResponse("requestParameterMethodFail4", response, entity);
669 
670  assertEquals(response.getStatus(), 302, "Unexpected response code.");
671  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
672 
673  if (response.getLocation() != null) {
674  try {
675  URI uri = new URI(response.getLocation().toString());
676  assertNotNull(uri.getFragment(), "Fragment is null");
677 
678  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
679 
680  assertNotNull(params.get("error"), "The error value is null");
681  assertNotNull(params.get("error_description"), "The errorDescription value is null");
682  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
683  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
684  } catch (URISyntaxException e) {
685  e.printStackTrace();
686  fail("Response URI is not well formed");
687  }
688  }
689  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ requestParameterMethodUserInfo()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodUserInfo ( final String  userInfoPath) throws Exception
inline
247  {
248  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request();
249 
250  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
251 
252  UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken1);
253  userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
254 
255  Response response = request
256  .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters())));
257  String entity = response.readEntity(String.class);
258 
259  showResponse("requestParameterMethodUserInfo", response, entity);
260 
261  assertEquals(response.getStatus(), 200, "Unexpected response code.");
262  assertTrue(
263  response.getHeaderString("Cache-Control") != null
264  && response.getHeaderString("Cache-Control").equals("no-store, private"),
265  "Unexpected result: " + response.getHeaderString("Cache-Control"));
266  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
267  "Unexpected result: " + response.getHeaderString("Pragma"));
268  assertNotNull(entity, "Unexpected result: " + entity);
269  try {
270  JSONObject jsonObj = new JSONObject(entity);
271  assertTrue(jsonObj.has(JwtClaimName.SUBJECT_IDENTIFIER));
272  assertTrue(jsonObj.has(JwtClaimName.NAME));
273  assertTrue(jsonObj.has(JwtClaimName.GIVEN_NAME));
274  assertTrue(jsonObj.has(JwtClaimName.FAMILY_NAME));
275  assertTrue(jsonObj.has(JwtClaimName.EMAIL));
276  } catch (JSONException e) {
277  e.printStackTrace();
278  fail(e.getMessage() + "\nResponse was: " + entity);
279  } catch (Exception e) {
280  e.printStackTrace();
281  fail(e.getMessage());
282  }
283  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String accessToken1
Definition: OpenIDRequestObjectEmbeddedTest.java:79
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ requestParameterMethodWithMaxAgeRestriction()

void org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.requestParameterMethodWithMaxAgeRestriction ( final String  authorizePath,
final String  userId,
final String  userSecret,
final String  redirectUri 
) throws Exception
inline
694  {
695 
696  final String state = UUID.randomUUID().toString();
697 
698  Builder request = null;
699  try {
700  List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
701  List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
702  String nonce = UUID.randomUUID().toString();
703 
704  AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes,
705  redirectUri, nonce);
706  authorizationRequest.setState(state);
707  authorizationRequest.getPrompts().add(Prompt.NONE);
708  authorizationRequest.setAuthUsername(userId);
709  authorizationRequest.setAuthPassword(userSecret);
710 
711  OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider();
712 
713  JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(authorizationRequest,
714  SignatureAlgorithm.HS256, clientSecret, cryptoProvider);
715  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
716  jwtAuthorizationRequest
717  .addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
718  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
719  jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
720  jwtAuthorizationRequest
721  .addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
722  jwtAuthorizationRequest
723  .addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
724  jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE,
725  ClaimValue.createValueList(new String[] { "2" })));
726  jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
727  String authJwt = jwtAuthorizationRequest.getEncodedJwt();
728  authorizationRequest.setRequest(authJwt);
729  System.out.println("Request JWT: " + authJwt);
730 
731  request = ResteasyClientBuilder.newClient()
732  .target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
733  request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
734  request.header("Accept", MediaType.TEXT_PLAIN);
735  } catch (Exception e) {
736  fail(e.getMessage(), e);
737  }
738 
739  Response response = request.get();
740  String entity = response.readEntity(String.class);
741 
742  showResponse("requestParameterMethodWithMaxAgeRestriction", response, entity);
743 
744  assertEquals(response.getStatus(), 302, "Unexpected response code.");
745  assertNotNull(response.getLocation(), "Unexpected result: " + response.getLocation());
746 
747  try {
748  URI uri = new URI(response.getLocation().toString());
749  assertNotNull(uri.getFragment(), "Query string is null");
750 
751  Map<String, String> params = QueryStringDecoder.decode(uri.getFragment());
752 
753  assertNotNull(params.get(AuthorizeResponseParam.ACCESS_TOKEN), "The accessToken is null");
754  assertNotNull(params.get(AuthorizeResponseParam.ID_TOKEN), "The idToken is null");
755  assertNotNull(params.get(AuthorizeResponseParam.SCOPE), "The scope is null");
756  assertNotNull(params.get(AuthorizeResponseParam.STATE), "The state is null");
757  assertEquals(params.get(AuthorizeResponseParam.STATE), state);
758  } catch (URISyntaxException e) {
759  e.printStackTrace();
760  fail("Response URI is not well formed");
761  } catch (Exception e) {
762  e.printStackTrace();
763  fail("Response URI is not well formed");
764  }
765  }
URI url
Definition: OpenIDRequestObjectEmbeddedTest.java:75
static String clientSecret
Definition: OpenIDRequestObjectEmbeddedTest.java:78
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientId
Definition: OpenIDRequestObjectEmbeddedTest.java:77

◆ 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

◆ 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

メンバ詳解

◆ accessToken1

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.accessToken1
staticprivate

◆ accessToken2

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.accessToken2
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

◆ clientId

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.clientId
staticprivate

◆ clientId1

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

◆ clientId2

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

◆ clientId3

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

◆ clientInfoEndpoint

String org.xdi.oxauth.BaseTest.clientInfoEndpoint
protectedinherited

◆ clientSecret

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.clientSecret
staticprivate

◆ clientSecret1

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.clientSecret1
staticprivate

◆ clientSecret2

String org.xdi.oxauth.ws.rs.OpenIDRequestObjectEmbeddedTest.clientSecret2
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

◆ 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.OpenIDRequestObjectEmbeddedTest.url
private

◆ userInfoEndpoint

String org.xdi.oxauth.BaseTest.userInfoEndpoint
protectedinherited

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