server: fix server package after auth plugin refactor

- Have opensaml dependency to get version from root pom
- add com.cloud.api.auth.APIAuthenticationManagerImpl to spring ctx manager
- Fix getCommands() in APIAuthenticationManagerImpl
- Fix imports in resources, test and src classes

Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


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

Branch: refs/heads/saml2
Commit: ca5c3657697cf275c79b8ee6a9be1b1ae47fc41a
Parents: 67c0f1b
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Sun Aug 24 15:59:10 2014 +0200
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Mon Aug 25 17:33:27 2014 +0200

----------------------------------------------------------------------
 server/pom.xml                                  |  2 +-
 .../spring-server-core-managers-context.xml     |  5 +++-
 server/src/com/cloud/api/ApiServlet.java        |  7 ++---
 .../api/auth/APIAuthenticationManagerImpl.java  | 27 ++++++++++++++------
 .../auth/DefaultLoginAPIAuthenticatorCmd.java   |  4 ++-
 .../auth/DefaultLogoutAPIAuthenticatorCmd.java  |  2 ++
 server/test/com/cloud/api/ApiServletTest.java   |  6 ++---
 7 files changed, 36 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 04c25af..0e517f7 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -136,7 +136,7 @@
     <dependency>
       <groupId>org.opensaml</groupId>
       <artifactId>opensaml</artifactId>
-      <version>2.6.1</version>
+      <version>${cs.opensaml.version}</version>
     </dependency>
   </dependencies>
   <build>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git 
a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
 
b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index 17681f7..e2d4d27 100644
--- 
a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ 
b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -32,7 +32,10 @@
                       
http://www.springframework.org/schema/util/spring-util-3.0.xsd";
                       >
 
-    <bean id="authenticationManagerImpl" 
class="com.cloud.api.auth.APIAuthenticationManagerImpl" />
+    <bean id="authenticationManagerImpl" 
class="com.cloud.api.auth.APIAuthenticationManagerImpl">
+        <property name="apiAuthenticators"
+                  value="#{pluggableAPIAuthenticatorsRegistry.registered}" />
+    </bean>
 
     <bean id="accountManagerImpl" class="com.cloud.user.AccountManagerImpl">
         <property name="userAuthenticators"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java 
b/server/src/com/cloud/api/ApiServlet.java
index 8dff6eb..454fc8b 100644
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -16,9 +16,9 @@
 // under the License.
 package com.cloud.api;
 
-import com.cloud.api.auth.APIAuthenticationManager;
-import com.cloud.api.auth.APIAuthenticationType;
-import com.cloud.api.auth.APIAuthenticator;
+import org.apache.cloudstack.api.auth.APIAuthenticationManager;
+import org.apache.cloudstack.api.auth.APIAuthenticationType;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
 import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.User;
@@ -26,6 +26,7 @@ import com.cloud.utils.HttpUtils;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.db.EntityManager;
 import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiServerService;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.managed.context.ManagedContext;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java 
b/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java
index ece2e03..790b6d9 100644
--- a/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java
+++ b/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java
@@ -19,6 +19,9 @@ package com.cloud.api.auth;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.ManagerBase;
 import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.auth.APIAuthenticationManager;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
+import org.apache.cloudstack.api.auth.PluggableAPIAuthenticator;
 import org.apache.log4j.Logger;
 
 import javax.ejb.Local;
@@ -32,12 +35,21 @@ import java.util.Map;
 public class APIAuthenticationManagerImpl extends ManagerBase implements 
APIAuthenticationManager {
     public static final Logger s_logger = 
Logger.getLogger(APIAuthenticationManagerImpl.class.getName());
 
+    private List<PluggableAPIAuthenticator> _apiAuthenticators;
+
     private static Map<String, Class<?>> s_authenticators = null;
-    private static List<Class<?>> s_commandList = null;
 
     public APIAuthenticationManagerImpl() {
     }
 
+    public List<PluggableAPIAuthenticator> getApiAuthenticators() {
+        return _apiAuthenticators;
+    }
+
+    public void setApiAuthenticators(List<PluggableAPIAuthenticator> 
authenticators) {
+        _apiAuthenticators = authenticators;
+    }
+
     @Override
     public boolean start() {
         s_authenticators = new HashMap<String, Class<?>>();
@@ -53,14 +65,13 @@ public class APIAuthenticationManagerImpl extends 
ManagerBase implements APIAuth
 
     @Override
     public List<Class<?>> getCommands() {
-        if (s_commandList == null) {
-            s_commandList = new ArrayList<Class<?>>();
-            s_commandList.add(DefaultLoginAPIAuthenticatorCmd.class);
-            s_commandList.add(DefaultLogoutAPIAuthenticatorCmd.class);
-            s_commandList.add(SAML2LoginAPIAuthenticatorCmd.class);
-            s_commandList.add(SAML2LogoutAPIAuthenticatorCmd.class);
+        List<Class<?>> cmdList = new ArrayList<Class<?>>();
+        cmdList.add(DefaultLoginAPIAuthenticatorCmd.class);
+        cmdList.add(DefaultLogoutAPIAuthenticatorCmd.class);
+        for (PluggableAPIAuthenticator apiAuthenticator: _apiAuthenticators) {
+            cmdList.addAll(apiAuthenticator.getAuthCommands());
         }
-        return s_commandList;
+        return cmdList;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java 
b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java
index 243ad9b..2fb3f56 100644
--- a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java
+++ b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java
@@ -16,7 +16,7 @@
 // under the License.
 package com.cloud.api.auth;
 
-import com.cloud.api.ApiServerService;
+import org.apache.cloudstack.api.ApiServerService;
 import com.cloud.api.response.ApiResponseSerializer;
 import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.user.Account;
@@ -26,6 +26,8 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.auth.APIAuthenticationType;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
 import org.apache.cloudstack.api.response.LoginCmdResponse;
 import org.apache.log4j.Logger;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java 
b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java
index a5802bf..999cefd 100644
--- a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java
+++ b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java
@@ -22,6 +22,8 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.auth.APIAuthenticationType;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
 import org.apache.cloudstack.api.response.LogoutCmdResponse;
 import org.apache.log4j.Logger;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca5c3657/server/test/com/cloud/api/ApiServletTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/ApiServletTest.java 
b/server/test/com/cloud/api/ApiServletTest.java
index 0a90296..1a9c13d 100644
--- a/server/test/com/cloud/api/ApiServletTest.java
+++ b/server/test/com/cloud/api/ApiServletTest.java
@@ -16,9 +16,9 @@
 // under the License.
 package com.cloud.api;
 
-import com.cloud.api.auth.APIAuthenticationManager;
-import com.cloud.api.auth.APIAuthenticationType;
-import com.cloud.api.auth.APIAuthenticator;
+import org.apache.cloudstack.api.auth.APIAuthenticationManager;
+import org.apache.cloudstack.api.auth.APIAuthenticationType;
+import org.apache.cloudstack.api.auth.APIAuthenticator;
 import com.cloud.server.ManagementServer;
 import com.cloud.user.Account;
 import com.cloud.user.AccountService;

Reply via email to