diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-08-16 15:58:16 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-08-16 16:07:43 +0530 |
commit | 6e5f1c2fed28eecd2a749bcd6dd2748082de1b42 (patch) | |
tree | 72cfc0226fe382c71932480cb5bb7c4146020e20 /framework/src/main/java/org | |
parent | 5a0dadc2c7439719142db3c7e2200d12face4b45 (diff) |
Add auth mode in service
ONAP is using basic auth already for some services
and AAF is being used as well. so there are more than
one auth type being used across. to support it,
new property call auth is introduced in service section.
also no-auth is now migrated as auth: none
CLI-29
Change-Id: I151a4669151f67884f9875f47c8df396836ae25b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java/org')
5 files changed, 22 insertions, 17 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java index 13e67fc6..7e15fbab 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java @@ -255,7 +255,6 @@ public abstract class OnapCommand { } try { - // login OnapCredentials creds = OnapCommandUtils.fromParameters(this.getParameters()); boolean isAuthRequired = !this.onapService.isNoAuth() && "true".equals(paramMap.get(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH).getValue()); @@ -268,10 +267,8 @@ public abstract class OnapCommand { this.authClient.login(); } - // execute this.run(); - // logout if (isAuthRequired) { this.authClient.logout(); } diff --git a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java index f9d4a638..c770d17c 100644 --- a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java +++ b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java @@ -43,7 +43,7 @@ public class OnapService { */ private String mode = Constants.MODE_CATALOG; - private boolean noAuth = false; + private String authType = Constants.AUTH_BASIC; public String getMode() { return mode; @@ -57,12 +57,16 @@ public class OnapService { return this.getMode().equals(Constants.MODE_DIRECT); } - public boolean isNoAuth() { - return noAuth; + public String getAuthType() { + return this.authType; + } + + public void setAuthType(String auth) { + this.authType = auth; } - public void setNoAuth(boolean noAuth) { - this.noAuth = noAuth; + public boolean isNoAuth() { + return this.authType.equalsIgnoreCase(Constants.AUTH_NONE); } public String getName() { diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java index d711ba25..8eb88397 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java @@ -74,7 +74,9 @@ public class Constants { public static final String NAME = "name"; public static final String VERSION = "version"; public static final String BASE_PATH = "base_path"; - public static final String NO_AUTH = "no-auth"; + public static final String AUTH = "auth"; + public static final String AUTH_NONE = "none"; + public static final String AUTH_BASIC = "basic"; public static final String MODE = "mode"; public static final String MODE_DIRECT = "direct"; public static final String MODE_CATALOG = "catalog"; @@ -171,3 +173,4 @@ public class Constants { } } + diff --git a/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java b/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java index 28671521..1b0a2beb 100644 --- a/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java +++ b/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java @@ -74,7 +74,7 @@ public abstract class AbstractSchemaValidate implements SchemaValidate { protected static final List<String> TOP_LEVEL_MANDATORY_LIST = Arrays.asList(ONAP_CMD_SCHEMA_VERSION, NAME, DESCRIPTION); - protected static final List<String> SERVICE_PARAMS_LIST = Arrays.asList(NAME, VERSION, NO_AUTH); + protected static final List<String> SERVICE_PARAMS_LIST = Arrays.asList(NAME, VERSION, AUTH); protected static final List<String> SERVICE_PARAMS_MANDATORY_LIST = Arrays.asList(NAME, VERSION); @@ -363,14 +363,14 @@ public abstract class AbstractSchemaValidate implements SchemaValidate { // Validate specific parameters - if (serviceMap.containsKey(NO_AUTH)) { - Object obj = serviceMap.get(NO_AUTH); + if (serviceMap.containsKey(AUTH)) { + Object obj = serviceMap.get(AUTH); if (obj == null) { - schemaErrors.add(SchemaValidate.emptyValue(SERVICE, NO_AUTH)); + schemaErrors.add(SchemaValidate.emptyValue(SERVICE, AUTH)); } else { String value = String.valueOf(obj); - if (!validateBoolean(value)) { - schemaErrors.add(SchemaValidate.invalidBooleanValueMessage(SERVICE, NO_AUTH, value)); + if (validateBoolean(value)) { + schemaErrors.add(SchemaValidate.invalidBooleanValueMessage(SERVICE, AUTH, value)); } } } diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 9a425397..512d0b22 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -248,9 +248,10 @@ public class OnapCommandUtils { srv.setName(map.get(key1)); } else if (Constants.VERSION.equals(key1)) { srv.setVersion(map.get(key1)); - } else if (Constants.NO_AUTH.equals(key1)) { + } else if (Constants.AUTH.equals(key1)) { Object obj = map.get(key1); - srv.setNoAuth("true".equalsIgnoreCase(obj.toString())); + //TODO mrkanag Validate and raise exception for invalid case + srv.setAuthType(obj.toString()); } else if (Constants.MODE.equals(key1)) { Object obj = map.get(key1); //TODO mrkanag Validate and raise exception for invalid case |