io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl Java Examples

The following examples show how to use io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthenticationUtilsTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void getUserFailsIfTokenDoesNotHaveExpiryClaim() {
  final AuthenticationService authenticationService = mock(AuthenticationService.class);
  final JWTAuth jwtAuth = new JWTAuthProviderImpl(null, new JWTAuthOptions());
  final StubUserHandler handler = new StubUserHandler();
  when(authenticationService.getJwtAuthProvider()).thenReturn(jwtAuth);

  AuthenticationUtils.getUser(
      Optional.of(authenticationService), INVALID_TOKEN_WITHOUT_EXP, handler);

  assertThat(handler.getEvent()).isEmpty();
}
 
Example #2
Source File: AuthenticationUtilsTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void getUserSucceedsWithValidToken() {
  final AuthenticationService authenticationService = mock(AuthenticationService.class);
  final JWTAuth jwtAuth = new JWTAuthProviderImpl(null, new JWTAuthOptions());
  final StubUserHandler handler = new StubUserHandler();
  when(authenticationService.getJwtAuthProvider()).thenReturn(jwtAuth);

  AuthenticationUtils.getUser(Optional.of(authenticationService), VALID_TOKEN, handler);

  assertThat(handler.getEvent().get().principal())
      .isEqualTo(new JsonObject(VALID_TOKEN_DECODED_PAYLOAD));
}
 
Example #3
Source File: JWTAuth.java    From vertx-auth with Apache License 2.0 2 votes vote down vote up
/**
 * Create a JWT auth provider
 *
 * @param vertx the Vertx instance
 * @param config  the config
 * @return the auth provider
 */
static JWTAuth create(Vertx vertx, JWTAuthOptions config) {
  return new JWTAuthProviderImpl(vertx, config);
}