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);
}
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;
}
Aggregations