Repository: cloudstack Updated Branches: refs/heads/master 550762a0d -> 33a249e77
CLOUDSTACK-7455: Fix possible case for NPE NPE can happen if Spring fails to inject api authenticator, so better check and set list of commands if the authenticator is not null or returning null cmds 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/33a249e7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/33a249e7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/33a249e7 Branch: refs/heads/master Commit: 33a249e77aeaaaecccf355938890a63d2dce18cd Parents: 550762a Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Sun Aug 31 14:42:18 2014 +0200 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Sun Aug 31 14:42:18 2014 +0200 ---------------------------------------------------------------------- .../cloudstack/api/command/GetServiceProviderMetaDataCmd.java | 2 +- .../cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java | 2 +- .../api/command/SAML2LogoutAPIAuthenticatorCmd.java | 2 +- .../src/com/cloud/api/auth/APIAuthenticationManagerImpl.java | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33a249e7/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java ---------------------------------------------------------------------- diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java index 16ee088..437f4a3 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java @@ -191,7 +191,7 @@ public class GetServiceProviderMetaDataCmd extends BaseCmd implements APIAuthent @Override public void setAuthenticators(List<PluggableAPIAuthenticator> authenticators) { for (PluggableAPIAuthenticator authManager: authenticators) { - if (authManager instanceof SAML2AuthManager) { + if (authManager != null && authManager instanceof SAML2AuthManager) { _samlAuthManager = (SAML2AuthManager) authManager; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33a249e7/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java ---------------------------------------------------------------------- diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java index 07cfa39..b279977 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java @@ -292,7 +292,7 @@ public class SAML2LoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthent @Override public void setAuthenticators(List<PluggableAPIAuthenticator> authenticators) { for (PluggableAPIAuthenticator authManager: authenticators) { - if (authManager instanceof SAML2AuthManager) { + if (authManager != null && authManager instanceof SAML2AuthManager) { _samlAuthManager = (SAML2AuthManager) authManager; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33a249e7/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java ---------------------------------------------------------------------- diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java index 4fa7fb3..cdc24e0 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java @@ -158,7 +158,7 @@ public class SAML2LogoutAPIAuthenticatorCmd extends BaseCmd implements APIAuthen @Override public void setAuthenticators(List<PluggableAPIAuthenticator> authenticators) { for (PluggableAPIAuthenticator authManager: authenticators) { - if (authManager instanceof SAML2AuthManager) { + if (authManager != null && authManager instanceof SAML2AuthManager) { _samlAuthManager = (SAML2AuthManager) authManager; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33a249e7/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 24ccbeb..fc21b19 100644 --- a/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java +++ b/server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java @@ -69,7 +69,12 @@ public class APIAuthenticationManagerImpl extends ManagerBase implements APIAuth cmdList.add(DefaultLoginAPIAuthenticatorCmd.class); cmdList.add(DefaultLogoutAPIAuthenticatorCmd.class); for (PluggableAPIAuthenticator apiAuthenticator: _apiAuthenticators) { - cmdList.addAll(apiAuthenticator.getAuthCommands()); + List<Class<?>> commands = apiAuthenticator.getAuthCommands(); + if (commands != null) { + cmdList.addAll(commands); + } else { + s_logger.warn("API Authenticator returned null api commands:" + apiAuthenticator.getName()); + } } return cmdList; }