diff options
author | luxin <luxin7@huawei.com> | 2017-09-22 16:48:02 +0800 |
---|---|---|
committer | luxin <luxin7@huawei.com> | 2017-09-22 16:48:02 +0800 |
commit | fa6df1c6d811b40b7be7ebff7db7cf3ec4a8ef34 (patch) | |
tree | 15907a95cc7d586f8b6582d14b54cfa294e40608 /huawei | |
parent | 161d708c81d6379c6c311c5a999dfa6c4b8fffee (diff) |
Define constants instead of userName and password
Change-Id: I9878dd7dbcf182ff13a8fa40d29fc60484c4ac02
Issue-Id:VFC-425
Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'huawei')
6 files changed, 20 insertions, 16 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java index 2f38cf2c..6ee1ff28 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java @@ -167,7 +167,7 @@ public final class ResultRequestUtil { String token = mgrVcmm.getAccessSession(); String roaRand = mgrVcmm.getRoaRand(); String vnfmUrl = vnfmObject.getString("url"); - String user = vnfmObject.getString("userName"); + String user = vnfmObject.getString(Constant.USERNAME); removeTokens(vnfmUrl, token, roaRand, user); } catch(IOException e) { LOG.info("function=call, msg=IOException, e is {}", e); @@ -266,7 +266,7 @@ public final class ResultRequestUtil { // logout delete tokens String token = mgrVcmm.getAccessSession(); - String user = vnfmObject.getString("userName"); + String user = vnfmObject.getString(Constant.USERNAME); removeV3Tokens(newUrl, token, user); } catch(IOException e) { LOG.info("function=call, msg=IOException, e is {}", e); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java index b1bffc23..6b33750c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java @@ -148,16 +148,16 @@ public class AdapterResourceManager implements IResourceManager { LOG.info("get Vnfm Connection Info successful.", vnfmObject.get(Constant.RETCODE)); String vnfmUrl = vnfmObject.getString("url"); - String userName = vnfmObject.getString("userName"); - String password = vnfmObject.getString("password"); + String userName = vnfmObject.getString(Constant.USERNAME); + String password = vnfmObject.getString(Constant.PASSWORD); // build VNFM connection and get token ConnectMgrVnfm mgrVcmm = new ConnectMgrVnfm(); JSONObject connObject = new JSONObject(); connObject.put("url", vnfmUrl); - connObject.put("userName", userName); - connObject.put("password", password); + connObject.put(Constant.USERNAME, userName); + connObject.put(Constant.PASSWORD, password); if(Constant.HTTP_OK != mgrVcmm.connect(vnfmObject, Constant.CERTIFICATE)) { LOG.error("get Access Session fail."); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java index efc515c2..77c0fcc3 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java @@ -150,6 +150,10 @@ public class Constant { public static final String FILE_SEPARATOR = "file.separator"; + public static final String PASSWORD = "password"; + + public static final String USERNAME = "userName"; + private Constant() { // private constructor } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java index 4c2383a5..c2c6d5c0 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java @@ -73,8 +73,8 @@ public class ConnectMgrVnfm { public int connect(JSONObject vnfmObj, String authModel) { LOG.info("function=connect, msg=enter connect function."); - ConnectInfo info = new ConnectInfo(vnfmObj.getString("url"), vnfmObj.getString("userName"), - vnfmObj.getString("password"), authModel); + ConnectInfo info = new ConnectInfo(vnfmObj.getString("url"), vnfmObj.getString(Constant.USERNAME), + vnfmObj.getString(Constant.PASSWORD), authModel); HttpMethod httpMethod = null; int statusCode = Constant.INTERNAL_EXCEPTION; @@ -127,8 +127,8 @@ public class ConnectMgrVnfm { String oldUrl = vnfmObj.getString("url").trim(); String newUrl = oldUrl.replaceAll("30001", "30000"); LOG.info("function=connectSouth, url={}.", newUrl); - ConnectInfo info = - new ConnectInfo(newUrl, vnfmObj.getString("userName"), vnfmObj.getString("password"), authModel); + ConnectInfo info = new ConnectInfo(newUrl, vnfmObj.getString(Constant.USERNAME), + vnfmObj.getString(Constant.PASSWORD), authModel); HttpMethod httpMethod = null; int statusCode = Constant.INTERNAL_EXCEPTION; @@ -179,8 +179,8 @@ public class ConnectMgrVnfm { public int connect(JSONObject vnfmObj) { LOG.info("function=connect, msg=enter connect function."); - ConnectInfo info = new ConnectInfo(vnfmObj.getString("url"), vnfmObj.getString("userName"), - vnfmObj.getString("password"), Constant.ANONYMOUS); + ConnectInfo info = new ConnectInfo(vnfmObj.getString("url"), vnfmObj.getString(Constant.USERNAME), + vnfmObj.getString(Constant.PASSWORD), Constant.ANONYMOUS); HttpMethod httpMethod = null; int statusCode = Constant.INTERNAL_EXCEPTION; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java index 2a4ac49d..d0a06a25 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java @@ -46,7 +46,7 @@ public class AuthMgr { JSONObject restJson = new JSONObject(); restJson.put(Constant.RETCODE, Constant.REST_FAIL); try { - String userName = params.getString("userName"); + String userName = params.getString(Constant.USERNAME); restJson = getStatusResult(userName); } catch(JSONException e) { diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java index afcf1235..d88cf789 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java @@ -92,8 +92,8 @@ public class AuthRoa { resp.setStatus(Constant.HTTP_OK); // resp.setHeader("accessSession", data.getString("accessSession")); return data.toString();// String.format(ParamConstants.GET_TOKEN_SUC_RESP, - // data.getString("userName"), - // data.getString("userName"), data.getString("roaRand")); + // data.getString(Constant.USERNAME), + // data.getString(Constant.USERNAME), data.getString("roaRand")); } else if(authResult.getInt(Constant.RETCODE) == Constant.HTTP_INNERERROR) { Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(authResult.getString("data")).build(); @@ -117,7 +117,7 @@ public class AuthRoa { */ @DELETE @Path("/auth/tokens/{userName}/{roarand}") - public String delAuthToken(@Context HttpServletRequest context, @PathParam("userName") String userName, + public String delAuthToken(@Context HttpServletRequest context, @PathParam(Constant.USERNAME) String userName, @PathParam("roarand") String roarand, @Context HttpServletResponse resp) { LOG.warn("function=logout, msg=enter to logout"); JSONObject resultJson = new JSONObject(); |