mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
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.yadav@shapeblue.com>
This commit is contained in:
parent
550762a0dc
commit
33a249e77a
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user