[36/50] incubator-eagle git commit: [EAGLE-621] set authentication disabled by default when no 'auth' is configured

2016-10-18 Thread hao
[EAGLE-621] set authentication disabled by default when no 'auth' is configured

Authentication settings are configured in configuration.yml file, starting with 
"auth" syntax. Now make the system see authentication as disabled when no auth 
related syntax is set.

Also, do some refactoring to make the code clearer.

Author: anyway1021 

Closes #514 from anyway1021/EAGLE-621.


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/b103e201
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/b103e201
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/b103e201

Branch: refs/heads/master
Commit: b103e201ebe7b1500ba3d0297bb7aa88e7aa811a
Parents: 33b9720
Author: anyway1021 
Authored: Mon Oct 17 10:44:36 2016 +0800
Committer: anyway1021 
Committed: Mon Oct 17 10:44:36 2016 +0800

--
 .../apache/eagle/server/ServerApplication.java  |   8 +-
 .../authentication/AuthenticationMode.java  |  51 -
 .../AuthenticationModeIdentifier.java   | 105 ---
 .../authentication/AuthenticationRegister.java  |  41 
 .../BasicAuthProviderBuilder.java   |  66 
 .../SwitchableBasicAuthProvider.java|  50 -
 .../AbstractSwitchableAuthenticator.java|  48 -
 .../authenticator/LdapBasicAuthenticator.java   |  11 +-
 .../authenticator/SimpleBasicAuthenticator.java |  12 +--
 9 files changed, 82 insertions(+), 310 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b103e201/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
--
diff --git 
a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java 
b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
index 2ae95a6..df1d7e7 100644
--- a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
+++ b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.eagle.server;
+
 import com.google.inject.Injector;
 import com.hubspot.dropwizard.guice.GuiceBundle;
 import com.sun.jersey.api.core.PackagesResourceConfig;
@@ -27,11 +28,10 @@ import io.swagger.jaxrs.config.BeanConfig;
 import io.swagger.jaxrs.listing.ApiListingResource;
 import org.apache.eagle.alert.coordinator.CoordinatorListener;
 import org.apache.eagle.alert.resource.SimpleCORSFiler;
-import org.apache.eagle.common.authentication.User;
 import org.apache.eagle.log.base.taggedlog.EntityJsonModule;
 import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
 import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
-import org.apache.eagle.server.authentication.AuthenticationRegister;
+import org.apache.eagle.server.authentication.BasicAuthProviderBuilder;
 import org.apache.eagle.server.managedtask.ApplicationTask;
 import org.apache.eagle.server.module.GuiceBundleLoader;
 
@@ -80,8 +80,8 @@ class ServerApplication extends Application {
 environment.servlets().addFilter(SimpleCORSFiler.class.getName(), new 
SimpleCORSFiler())
 .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), 
true, "/*");
 
-// add authentication filters
-new AuthenticationRegister<>(configuration, environment, 
User.class).register();
+// register authentication provider
+environment.jersey().register(new 
BasicAuthProviderBuilder(configuration.getAuth(), environment).build());
 
 // context listener
 environment.servlets().addServletListeners(new CoordinatorListener());

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b103e201/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
--
diff --git 
a/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
 
b/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
deleted file mode 100644
index 8a7208f..000
--- 
a/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * 

incubator-eagle git commit: [EAGLE-621] set authentication disabled by default when no 'auth' is configured

2016-10-16 Thread mw
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 33b972065 -> b103e201e


[EAGLE-621] set authentication disabled by default when no 'auth' is configured

Authentication settings are configured in configuration.yml file, starting with 
"auth" syntax. Now make the system see authentication as disabled when no auth 
related syntax is set.

Also, do some refactoring to make the code clearer.

Author: anyway1021 

Closes #514 from anyway1021/EAGLE-621.


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/b103e201
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/b103e201
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/b103e201

Branch: refs/heads/master
Commit: b103e201ebe7b1500ba3d0297bb7aa88e7aa811a
Parents: 33b9720
Author: anyway1021 
Authored: Mon Oct 17 10:44:36 2016 +0800
Committer: anyway1021 
Committed: Mon Oct 17 10:44:36 2016 +0800

--
 .../apache/eagle/server/ServerApplication.java  |   8 +-
 .../authentication/AuthenticationMode.java  |  51 -
 .../AuthenticationModeIdentifier.java   | 105 ---
 .../authentication/AuthenticationRegister.java  |  41 
 .../BasicAuthProviderBuilder.java   |  66 
 .../SwitchableBasicAuthProvider.java|  50 -
 .../AbstractSwitchableAuthenticator.java|  48 -
 .../authenticator/LdapBasicAuthenticator.java   |  11 +-
 .../authenticator/SimpleBasicAuthenticator.java |  12 +--
 9 files changed, 82 insertions(+), 310 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b103e201/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
--
diff --git 
a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java 
b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
index 2ae95a6..df1d7e7 100644
--- a/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
+++ b/eagle-server/src/main/java/org/apache/eagle/server/ServerApplication.java
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.eagle.server;
+
 import com.google.inject.Injector;
 import com.hubspot.dropwizard.guice.GuiceBundle;
 import com.sun.jersey.api.core.PackagesResourceConfig;
@@ -27,11 +28,10 @@ import io.swagger.jaxrs.config.BeanConfig;
 import io.swagger.jaxrs.listing.ApiListingResource;
 import org.apache.eagle.alert.coordinator.CoordinatorListener;
 import org.apache.eagle.alert.resource.SimpleCORSFiler;
-import org.apache.eagle.common.authentication.User;
 import org.apache.eagle.log.base.taggedlog.EntityJsonModule;
 import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
 import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
-import org.apache.eagle.server.authentication.AuthenticationRegister;
+import org.apache.eagle.server.authentication.BasicAuthProviderBuilder;
 import org.apache.eagle.server.managedtask.ApplicationTask;
 import org.apache.eagle.server.module.GuiceBundleLoader;
 
@@ -80,8 +80,8 @@ class ServerApplication extends Application {
 environment.servlets().addFilter(SimpleCORSFiler.class.getName(), new 
SimpleCORSFiler())
 .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), 
true, "/*");
 
-// add authentication filters
-new AuthenticationRegister<>(configuration, environment, 
User.class).register();
+// register authentication provider
+environment.jersey().register(new 
BasicAuthProviderBuilder(configuration.getAuth(), environment).build());
 
 // context listener
 environment.servlets().addServletListeners(new CoordinatorListener());

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b103e201/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
--
diff --git 
a/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
 
b/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
deleted file mode 100644
index 8a7208f..000
--- 
a/eagle-server/src/main/java/org/apache/eagle/server/authentication/AuthenticationMode.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in