Package com.atlassian.connect.play.java.auth.jwt

Source Code of com.atlassian.connect.play.java.auth.jwt.JwtAuthConfig

package com.atlassian.connect.play.java.auth.jwt;

import com.atlassian.jwt.core.http.auth.JwtAuthenticator;
import com.atlassian.jwt.core.reader.NimbusJwtReaderFactory;
import com.atlassian.jwt.core.writer.NimbusJwtWriterFactory;
import com.atlassian.jwt.reader.JwtReaderFactory;
import com.atlassian.jwt.writer.JwtWriterFactory;

import static play.mvc.Http.Request;
import static play.mvc.Http.Response;

// TODO: add spring DI or similar
public class JwtAuthConfig {
    private static ACPlayJwtIssuerService acPlayJwtIssuerService = new ACPlayJwtIssuerService();

    private static final PlayJwtAuthenticator jwtAuthenticator =
            new PlayJwtAuthenticator(new PlayJwtRequestExtractor(), new PlayAuthenticationResultHandler(),
                    createReaderFactory());

    private static JwtAuthorizationGenerator jwtAuthorizationGenerator =
            new JwtAuthorizationGenerator(createWriterFactory());

    private static JwtReaderFactory createReaderFactory() {
        return new NimbusJwtReaderFactory(acPlayJwtIssuerService, acPlayJwtIssuerService);
    }

    private static JwtWriterFactory createWriterFactory() {
        return new NimbusJwtWriterFactory();
    }

    public static JwtAuthenticator<Request, Response, JwtAuthenticationResult> getJwtAuthenticator() {
        return jwtAuthenticator;
    }

    public static JwtAuthorizationGenerator getJwtAuthorizationGenerator() {
        return jwtAuthorizationGenerator;
    }
}
TOP

Related Classes of com.atlassian.connect.play.java.auth.jwt.JwtAuthConfig

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.