Fix subclasses that no longer need RestController

Original commit: elastic/x-pack-elasticsearch@d762c5f0bb
This commit is contained in:
Ryan Ernst 2016-07-14 19:04:09 -07:00
parent 5d42de803c
commit b562a83c0b
5 changed files with 18 additions and 20 deletions

View File

@ -33,8 +33,8 @@ public class ActiveDirectoryRealm extends AbstractLdapRealm {
private final ClientSSLService clientSSLService;
@Inject
public Factory(ResourceWatcherService watcherService, ClientSSLService clientSSLService, RestController restController) {
super(ActiveDirectoryRealm.TYPE, restController);
public Factory(ResourceWatcherService watcherService, ClientSSLService clientSSLService) {
super(ActiveDirectoryRealm.TYPE);
this.watcherService = watcherService;
this.clientSSLService = clientSSLService;
}

View File

@ -84,8 +84,8 @@ public class FileRealm extends CachingUsernamePasswordRealm {
private final ResourceWatcherService watcherService;
@Inject
public Factory(Settings settings, Environment env, ResourceWatcherService watcherService, RestController restController) {
super(TYPE, restController, true);
public Factory(Settings settings, Environment env, ResourceWatcherService watcherService) {
super(TYPE, true);
this.settings = settings;
this.env = env;
this.watcherService = watcherService;

View File

@ -43,8 +43,8 @@ public class LdapRealm extends AbstractLdapRealm {
private final ClientSSLService clientSSLService;
@Inject
public Factory(ResourceWatcherService watcherService, ClientSSLService clientSSLService, RestController restController) {
super(TYPE, restController);
public Factory(ResourceWatcherService watcherService, ClientSSLService clientSSLService) {
super(TYPE);
this.watcherService = watcherService;
this.clientSSLService = clientSSLService;
}

View File

@ -103,8 +103,8 @@ public abstract class AbstractLdapRealm extends CachingUsernamePasswordRealm {
public abstract static class Factory<R extends AbstractLdapRealm> extends UsernamePasswordRealm.Factory<R> {
public Factory(String type, RestController restController) {
super(type, restController, false);
public Factory(String type) {
super(type, false);
}
/**

View File

@ -73,7 +73,6 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
CryptoService cryptoService;
ThreadPool threadPool;
ThreadContext threadContext;
RestController controller;
@Before
public void init() throws Exception {
@ -109,11 +108,10 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
auditTrail = mock(AuditTrail.class);
threadPool = mock(ThreadPool.class);
threadContext = new ThreadContext(Settings.EMPTY);
controller = mock(RestController.class);
when(threadPool.getThreadContext()).thenReturn(threadContext);
when(cryptoService.sign(any(String.class))).thenReturn("_signed_auth");
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
}
@After
@ -312,7 +310,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
ThreadContext threadContext1 = new ThreadContext(Settings.EMPTY);
when(threadPool.getThreadContext()).thenReturn(threadContext1);
service = new InternalAuthenticationService(Settings.EMPTY, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
threadContext1.putTransient(Authentication.AUTHENTICATION_KEY, threadContext.getTransient(Authentication.AUTHENTICATION_KEY));
threadContext1.putHeader(Authentication.AUTHENTICATION_KEY, threadContext.getHeader(Authentication.AUTHENTICATION_KEY));
@ -326,7 +324,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
threadContext1 = new ThreadContext(Settings.EMPTY);
when(threadPool.getThreadContext()).thenReturn(threadContext1);
service = new InternalAuthenticationService(Settings.EMPTY, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
threadContext1.putHeader(Authentication.AUTHENTICATION_KEY, threadContext.getHeader(Authentication.AUTHENTICATION_KEY));
when(cryptoService.unsignAndVerify("_signed_auth")).thenReturn(authentication.encode());
@ -338,7 +336,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
when(threadPool.getThreadContext()).thenReturn(threadContext1);
service = new InternalAuthenticationService(Settings.EMPTY, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
Authentication result = service.authenticate("_action", new InternalMessage(), SystemUser.INSTANCE);
assertThat(result, notNullValue());
assertThat(result.getUser(), equalTo(user1));
@ -348,7 +346,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
public void testAuthenticateTransportContextAndHeaderNoSigning() throws Exception {
Settings settings = Settings.builder().put(InternalAuthenticationService.SIGN_USER_HEADER.getKey(), false).build();
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
User user1 = new User("username", "r1", "r2");
when(firstRealm.supports(token)).thenReturn(true);
@ -365,7 +363,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
ThreadContext threadContext1 = new ThreadContext(Settings.EMPTY);
when(threadPool.getThreadContext()).thenReturn(threadContext1);
service = new InternalAuthenticationService(Settings.EMPTY, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
threadContext1.putTransient(Authentication.AUTHENTICATION_KEY, threadContext.getTransient(Authentication.AUTHENTICATION_KEY));
threadContext1.putHeader(Authentication.AUTHENTICATION_KEY, threadContext.getHeader(Authentication.AUTHENTICATION_KEY));
Authentication ctxAuth = service.authenticate("_action", message1, SystemUser.INSTANCE);
@ -385,7 +383,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
when(threadPool.getThreadContext()).thenReturn(threadContext1);
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
Authentication result = service.authenticate("_action", new InternalMessage(), SystemUser.INSTANCE);
assertThat(result, notNullValue());
assertThat(result.getUser(), equalTo(user1));
@ -448,7 +446,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
Settings settings = builder.build();
AnonymousUser.initialize(settings);
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService, new DefaultAuthenticationFailureHandler(),
threadPool, controller);
threadPool);
RestRequest request = new FakeRestRequest();
Authentication result = service.authenticate(request);
@ -464,7 +462,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
.build();
AnonymousUser.initialize(settings);
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
InternalMessage message = new InternalMessage();
Authentication result = service.authenticate("_action", message, null);
@ -479,7 +477,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
.build();
AnonymousUser.initialize(settings);
service = new InternalAuthenticationService(settings, realms, auditTrail, cryptoService,
new DefaultAuthenticationFailureHandler(), threadPool, controller);
new DefaultAuthenticationFailureHandler(), threadPool);
InternalMessage message = new InternalMessage();