2 * Copyright 2016 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process;
19 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import net.sf.json.JSONException;
24 import net.sf.json.JSONObject;
27 * Provide function for authInfo.
31 * @version VFC 1.0 Aug 24, 2016
33 public class AuthMgr {
35 private static final Logger LOG = LoggerFactory.getLogger(AuthMgr.class);
38 * Provide function for add authInfo.
45 public JSONObject authToken(JSONObject params) {
46 JSONObject restJson = new JSONObject();
47 restJson.put(Constant.RETCODE, Constant.REST_FAIL);
49 String userName = params.getString("userName");
51 restJson = getStatusResult(userName);
52 } catch(JSONException e) {
53 LOG.error("function=login, msg=Params error occurs, e={}.", e);
54 restJson.put("data", "JSONException");
60 private JSONObject getStatusResult(String userName) {
61 JSONObject restJson = new JSONObject();
62 JSONObject authResult = new JSONObject();
63 JSONObject addInfo = new JSONObject();
64 authResult.put("accessSession", "1234");
65 authResult.put("roaRand", "RoaRand");
66 authResult.put("expires", 1800);
67 addInfo.put("expires", 10);
68 addInfo.put("passwdStatus", "expiring");
69 authResult.put("additionalInfo", addInfo);
70 restJson.put("retCode", Constant.REST_SUCCESS);
71 restJson.put("data", authResult);