com.auth0.jwk.JwkProviderBuilder Java Examples

The following examples show how to use com.auth0.jwk.JwkProviderBuilder. 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: AuthenticationControllerProvider.java    From auth0-servlet-sample with MIT License 5 votes vote down vote up
public static AuthenticationController getInstance(ServletConfig config) throws UnsupportedEncodingException {
    String domain = config.getServletContext().getInitParameter("com.auth0.domain");
    String clientId = config.getServletContext().getInitParameter("com.auth0.clientId");
    String clientSecret = config.getServletContext().getInitParameter("com.auth0.clientSecret");

    if (domain == null || clientId == null || clientSecret == null) {
        throw new IllegalArgumentException("Missing domain, clientId, or clientSecret. Did you update src/main/webapp/WEB-INF/web.xml?");
    }

    // JwkProvider required for RS256 tokens. If using HS256, do not use.
    JwkProvider jwkProvider = new JwkProviderBuilder(domain).build();
    return AuthenticationController.newBuilder(domain, clientId, clientSecret)
            .withJwkProvider(jwkProvider)
            .build();
}
 
Example #2
Source File: AppConfig.java    From auth0-spring-security-mvc-sample with MIT License 5 votes vote down vote up
@Bean
public AuthenticationController authenticationController() throws UnsupportedEncodingException {
    JwkProvider jwkProvider = new JwkProviderBuilder(domain).build();
    return AuthenticationController.newBuilder(domain, clientId, clientSecret)
            .withJwkProvider(jwkProvider)
            .build();
}
 
Example #3
Source File: AuthConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public AuthenticationController authenticationController() throws UnsupportedEncodingException {
    JwkProvider jwkProvider = new JwkProviderBuilder(domain).build();
    return AuthenticationController.newBuilder(domain, clientId, clientSecret)
        .withJwkProvider(jwkProvider)
        .build();
}
 
Example #4
Source File: JwtWebSecurityConfigurer.java    From auth0-spring-security-api with MIT License 2 votes vote down vote up
/**
 * Configures application authorization for JWT signed with RS256.
 * Will try to validate the token using the public key downloaded from "$issuer/.well-known/jwks.json"
 * and matched by the value of {@code kid} of the JWT header
 * @param audience identifier of the API and must match the {@code aud} value in the token
 * @param issuers array of allowed issuers of the token for this API and one of the entries must match the {@code iss} value in the token
 * @return JwtWebSecurityConfigurer for further configuration
 */
@SuppressWarnings({"WeakerAccess", "SameParameterValue"})
public static JwtWebSecurityConfigurer forRS256(String audience, String[] issuers) {
    final JwkProvider jwkProvider = new JwkProviderBuilder(issuers[0]).build(); // we use the first issuer for getting the jwkProvider
    return new JwtWebSecurityConfigurer(audience, issuers, new JwtAuthenticationProvider(jwkProvider, issuers, audience));
}