Search in sources :

Example 1 with Authenticator

use of com.google.api.server.spi.config.Authenticator in project endpoints-java by cloudendpoints.

the class ApiMethodAnnotationConfigTest method setUp.

@Before
public void setUp() throws Exception {
    serializationConfig = new ApiSerializationConfig();
    Mockito.when(apiClassConfig.getApiConfig()).thenReturn(apiConfig);
    Mockito.when(apiClassConfig.getAuthLevel()).thenReturn(AuthLevel.NONE);
    Mockito.when(apiClassConfig.getScopeExpression()).thenReturn(defaultScopeExpression);
    Mockito.when(apiClassConfig.getAudiences()).thenReturn(defaultAudiences);
    Mockito.when(apiClassConfig.getClientIds()).thenReturn(defaultClientIds);
    Mockito.<List<Class<? extends Authenticator>>>when(apiClassConfig.getAuthenticators()).thenReturn(defaultAuthenticators);
    Mockito.<List<Class<? extends PeerAuthenticator>>>when(apiClassConfig.getPeerAuthenticators()).thenReturn(defaultPeerAuthenticators);
    Mockito.when(apiClassConfig.getApiClassJavaSimpleName()).thenReturn(TestEndpoint.class.getSimpleName());
    Mockito.when(apiConfig.getSerializationConfig()).thenReturn(serializationConfig);
    EndpointMethod method = EndpointMethod.create(TestEndpoint.class, TestEndpoint.class.getMethod("overrideMethod1"));
    config = new ApiMethodConfig(method, new TypeLoader(), apiClassConfig);
    annotationConfig = new ApiMethodAnnotationConfig(config);
}
Also used : TestEndpoint(com.google.api.server.spi.testing.TestEndpoint) ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) EndpointsPeerAuthenticator(com.google.api.server.spi.auth.EndpointsPeerAuthenticator) PassPeerAuthenticator(com.google.api.server.spi.testing.PassPeerAuthenticator) PeerAuthenticator(com.google.api.server.spi.config.PeerAuthenticator) EndpointMethod(com.google.api.server.spi.EndpointMethod) TypeLoader(com.google.api.server.spi.TypeLoader) ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig) EndpointsPeerAuthenticator(com.google.api.server.spi.auth.EndpointsPeerAuthenticator) PassAuthenticator(com.google.api.server.spi.testing.PassAuthenticator) PassPeerAuthenticator(com.google.api.server.spi.testing.PassPeerAuthenticator) Authenticator(com.google.api.server.spi.config.Authenticator) EndpointsAuthenticator(com.google.api.server.spi.auth.EndpointsAuthenticator) PeerAuthenticator(com.google.api.server.spi.config.PeerAuthenticator) Before(org.junit.Before)

Example 2 with Authenticator

use of com.google.api.server.spi.config.Authenticator in project endpoints-java by cloudendpoints.

the class Auth method authenticate.

/**
 * Authenticate the request and retrieve a {@code User}. Should only run once per request.
 */
User authenticate() throws ServiceException {
    Iterable<Authenticator> authenticators = getAuthenticatorInstances();
    User user = null;
    if (authenticators != null) {
        for (Authenticator authenticator : authenticators) {
            user = authenticator.authenticate(request);
            if (user != null) {
                break;
            }
        }
    }
    return user;
}
Also used : User(com.google.api.server.spi.auth.common.User) Authenticator(com.google.api.server.spi.config.Authenticator) EndpointsAuthenticator(com.google.api.server.spi.auth.EndpointsAuthenticator)

Aggregations

EndpointsAuthenticator (com.google.api.server.spi.auth.EndpointsAuthenticator)2 Authenticator (com.google.api.server.spi.config.Authenticator)2 EndpointMethod (com.google.api.server.spi.EndpointMethod)1 TypeLoader (com.google.api.server.spi.TypeLoader)1 EndpointsPeerAuthenticator (com.google.api.server.spi.auth.EndpointsPeerAuthenticator)1 User (com.google.api.server.spi.auth.common.User)1 PeerAuthenticator (com.google.api.server.spi.config.PeerAuthenticator)1 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)1 ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)1 PassAuthenticator (com.google.api.server.spi.testing.PassAuthenticator)1 PassPeerAuthenticator (com.google.api.server.spi.testing.PassPeerAuthenticator)1 TestEndpoint (com.google.api.server.spi.testing.TestEndpoint)1 Before (org.junit.Before)1