*
* @param request
* HttpServletRequest
+ * @param appCredentials
+ * Map with app name, user name, password
* @return true if the request contains appropriate credentials, else false.
* @throws PortalAPIException
* If an unexpected error occurs while processing the request.
public interface IPortalRestCentralService {
+ public static final String CREDENTIALS_APP = "appName";
+ public static final String CREDENTIALS_USER = "username";
+ public static final String CREDENTIALS_PASS = "password";
+ public static final String CREDENTIALS_UEB = "uebkey";
+
/**
* Gets and returns the Map with username, password and appName of application .If any error
* occurs, the method should throw PortalApiException with an appropriate
* message. The FW library will catch the exception and send an appropriate
* response to Portal.
*
- * @return a map with keys username, password and appName
+ * @return a map with keys {@link IPortalRestCentralService#CREDENTIALS_APP},
+ * {@link IPortalRestCentralService#CREDENTIALS_USER}, and
+ * {@link IPortalRestCentralService#CREDENTIALS_PASS},
+ * @throws PortalAPIException
+ * If any error occurs
*/
public Map<String, String> getAppCredentials() throws PortalAPIException;
try {
Class<?> centralImplClass = Class.forName(centralClassName);
portalRestCentralService = (IPortalRestCentralService) (centralImplClass.getConstructor().newInstance());
- username = portalRestCentralService.getAppCredentials().get("username");
- password = portalRestCentralService.getAppCredentials().get("password");
- appName = portalRestCentralService.getAppCredentials().get("appName");
+ username = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_USER);
+ password = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_PASS);
+ appName = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_APP);
} catch (Exception e) {
throw new ClassCastException("Failed to find or instantiate class ");
}
public Map<String, String> getCredentials() throws PortalAPIException{
Map<String, String> credentialsMap = new HashMap<>();
- credentialsMap.put("username", username);
- credentialsMap.put("password", password);
- credentialsMap.put("appName", appName);
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username);
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password);
+ credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName);
return credentialsMap;
}
@WebServlet(urlPatterns = { PortalApiConstants.API_PREFIX + "/*" })
public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPIService {
-
+
private static final long serialVersionUID = 1L;
private static final String APPLICATION_JSON = "application/json";
private static IPortalRestAPIService portalRestApiServiceImpl;
private static final String isAccessCentralized = PortalApiProperties
.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED);
- private static final String errorMessage = "Access Management is not allowed for Centralized applications." ;
+ private static final String errorMessage = "Access Management is not allowed for Centralized applications.";
private static final String isCentralized = "remote";
-
public PortalRestAPIProxy() {
// Ensure that any additional fields sent by the Portal
// will be ignored when creating objects.
if (!isCentralized.equals(isAccessCentralized))
portalRestApiServiceImpl = (IPortalRestAPIService) (implClass.getConstructor().newInstance());
else {
- portalRestApiServiceImpl = new PortalRestAPICentralServiceImpl();
+ portalRestApiServiceImpl = new PortalRestAPICentralServiceImpl();
}
} catch (Exception ex) {
throw new ServletException("init: Failed to find or instantiate class " + className, ex);
response.getWriter().write(buildJsonResponse(false, "Misconfigured - no instance of service class"));
return;
}
-
-
+
String requestUri = request.getRequestURI();
String responseJson = "";
String storeAnalyticsContextPath = "/storeAnalytics";
for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
- if (entry.getKey().equalsIgnoreCase("username")) {
+ if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) {
appUserName = entry.getValue();
- } else if (entry.getKey().equalsIgnoreCase("password")) {
+ } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) {
appPassword = entry.getValue();
} else {
appName = entry.getValue();
}
}
-
+
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
String requestBody = readRequestBody(request);
// add user ID
bodyMap.put("userid", userId);
requestBody = mapper.writeValueAsString(bodyMap);
- logger.debug("doPost: StoreAnalytics requestbody: "+ requestBody);
+ logger.debug("doPost: StoreAnalytics requestbody: " + requestBody);
responseJson = RestWebServiceClient.getInstance().postPortalContent(storeAnalyticsContextPath,
userId, appName, null, appUserName, appPassword, "application/json", requestBody, true);
logger.debug("doPost: postPortalContent returns " + responseJson);
writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Not authorized"));
return;
}
-
try {
String requestBody = readRequestBody(request);
if (requestUri.endsWith(PortalApiConstants.API_PREFIX + "/user")) {
try {
EcompUser user = mapper.readValue(requestBody, EcompUser.class);
- logger.debug("doPost: create user requestbody: "+ requestBody);
+ logger.debug("doPost: create user requestbody: " + requestBody);
Set<EcompRole> userEcompRoles = getEcompRolesOfUser(user);
user.setRoles(userEcompRoles);
pushUser(user);
responseJson = buildJsonResponse(true, "user saved successfully");
response.setStatus(HttpServletResponse.SC_OK);
} catch (Exception ex) {
- responseJson = buildShortJsonResponse(ex);
+ responseJson = buildShortJsonResponse(ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doPost: pushUser: caught exception", ex);
}
} else
- // Example: /user/abc <-- edit user abc
+ // Example: /user/abc <-- edit user abc
if (requestUri.contains(PortalApiConstants.API_PREFIX + "/user/") && !(requestUri.endsWith("/roles"))) {
String loginId = requestUri.substring(requestUri.lastIndexOf('/') + 1);
try {
EcompUser user = mapper.readValue(requestBody, EcompUser.class);
- logger.debug("doPost: update user requestbody: "+ requestBody);
+ logger.debug("doPost: update user requestbody: " + requestBody);
Set<EcompRole> userEcompRoles = getEcompRolesOfUser(user);
user.setRoles(userEcompRoles);
editUser(loginId, user);
responseJson = buildJsonResponse(true, "user saved successfully");
response.setStatus(HttpServletResponse.SC_OK);
} catch (Exception ex) {
- responseJson = buildShortJsonResponse(ex);
+ responseJson = buildShortJsonResponse(ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doPost: editUser: caught exception", ex);
}
}
} else {
String msg = "doPost: no match for request " + requestUri;
- logger.warn( ESAPI.encoder().encodeForHTML(msg));
+ logger.warn(ESAPI.encoder().encodeForHTML(msg));
responseJson = buildJsonResponse(false, msg);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
buildJsonResponse(false, "Misconfigured - no instance of service class"));
return;
}
-
String requestUri = request.getRequestURI();
String contentType = APPLICATION_JSON;
for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
- if (entry.getKey().equalsIgnoreCase("username")) {
+ if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) {
appUserName = entry.getValue();
- } else if (entry.getKey().equalsIgnoreCase("password")) {
+ } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) {
appPassword = entry.getValue();
} else {
appName = entry.getValue();
responseString = RestWebServiceClient.getInstance().getPortalContent(webAnalyticsContextPath,
userId, appName, null, appUserName, appPassword, true);
-
+
if (logger.isDebugEnabled())
logger.debug("doGet: " + webAnalyticsContextPath + ": " + responseString);
response.setStatus(HttpServletResponse.SC_OK);
*/
if (requestUri.endsWith("/sessionTimeOuts")) {
- try {
+ try {
responseJson = getSessionTimeOuts();
logger.debug("doGet: got session timeouts");
response.setStatus(HttpServletResponse.SC_OK);
- } catch(Exception ex) {
+ } catch (Exception ex) {
String msg = "Failed to get session time outs";
logger.error("doGet: " + msg);
- responseJson = buildShortJsonResponse(ex);
+ responseJson = buildShortJsonResponse(ex);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else
if (logger.isDebugEnabled())
logger.debug("doGet: getAvailableRoles: " + responseJson);
} catch (Exception ex) {
- responseJson = buildShortJsonResponse(ex);
+ responseJson = buildShortJsonResponse(ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doGet: getAvailableRoles: caught exception", ex);
}
if (logger.isDebugEnabled())
logger.debug("doGet: getUser: " + responseJson);
} catch (Exception ex) {
- responseJson = buildShortJsonResponse(ex);
+ responseJson = buildShortJsonResponse(ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doGet: getUser: caught exception", ex);
}
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doGet: getUserRoles: caught exception", ex);
}
- }
- else {
+ } else {
logger.warn("doGet: no match found for request");
responseJson = buildJsonResponse(false, "No match for request");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
@Override
- public boolean isAppAuthenticated(HttpServletRequest request, Map<String,String> appCredentials) throws PortalAPIException {
+ public boolean isAppAuthenticated(HttpServletRequest request, Map<String, String> appCredentials)
+ throws PortalAPIException {
return portalRestApiServiceImpl.isAppAuthenticated(request, appCredentials);
}
String body = null;
StringBuilder stringBuilder = new StringBuilder();
- try(InputStream inputStream = request.getInputStream()) {
+ try (InputStream inputStream = request.getInputStream()) {
if (inputStream != null) {
- try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));){
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));) {
char[] charBuffer = new char[1024];
int bytesRead = -1;
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
stringBuilder.append(charBuffer, 0, bytesRead);
}
- } catch(IOException e) {
+ } catch (IOException e) {
logger.error("readRequestBody", e);
throw e;
}
} else {
stringBuilder.append("");
}
- } catch(IOException e) {
+ } catch (IOException e) {
logger.error("readRequestBody", e);
throw e;
}
* Builds JSON object with status + message response body.
*
* @param success
- * True to indicate success, false to signal failure.
+ * True to indicate success, false to signal failure.
* @param msg
- * Message to include in the response object; ignored if null.
+ * Message to include in the response object; ignored if
+ * null.
* @return
*
* <pre>
* for the specified throwable.
*
* @param t
- * Throwable with stack trace to use as message
+ * Throwable with stack trace to use as message
*
* @return
*
t.printStackTrace(pw);
return buildJsonResponse(false, sw.toString());
}
-
- private String buildShortJsonResponse(Throwable t)
- {
+
+ private String buildShortJsonResponse(Throwable t) {
String errorMessage = t.getMessage();
return buildJsonResponse(false, errorMessage);
}
public static void setPortalRestApiServiceImpl(IPortalRestAPIService portalRestApiServiceImpl) {
PortalRestAPIProxy.portalRestApiServiceImpl = portalRestApiServiceImpl;
}
-
+
@Override
- public Map<String, String> getCredentials() throws PortalAPIException {
+ public Map<String, String> getCredentials() throws PortalAPIException {
return portalRestApiServiceImpl.getCredentials();
}
- private Set<EcompRole> getEcompRolesOfUser(EcompUser user) throws JsonProcessingException
- {
-
+ private Set<EcompRole> getEcompRolesOfUser(EcompUser user) throws JsonProcessingException {
+
Set<EcompRole> userEcompRoles = new TreeSet<>();
Set<EcompRole> ecompRoles = user.getRoles();
for (EcompRole role : ecompRoles) {
Map<String, String> result = Arrays.stream(str1.split(",")).map(s -> s.split(":"))
.collect(Collectors.toMap(a -> a[0], // key
a -> a[1] // value
- ));
+ ));
EcompRoleFunction roleFunction = new EcompRoleFunction();
for (Map.Entry<String, String> set : result.entrySet()) {
con.setConnectTimeout(3000);
con.setReadTimeout(8000);
// add request header
- con.setRequestProperty("username", userName);
- con.setRequestProperty("password", password);
- con.setRequestProperty("uebkey", uebKey);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, userName);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, password);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, uebKey);
String encoding = Base64.getEncoder().encodeToString((userName + ":" + password).getBytes());
con.setRequestProperty("Authorization", "Basic " + encoding);
con.setReadTimeout(15000);
// add request header
- con.setRequestProperty("username", userName);
- con.setRequestProperty("password", password);
- con.setRequestProperty("uebkey", uebKey);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, userName);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, password);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, uebKey);
con.setRequestProperty("sessionMap", sessionTimeoutMap);
String encoding = Base64.getEncoder().encodeToString((userName + ":" + password).getBytes());
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
import org.owasp.esapi.ESAPI;
con.setRequestProperty("user-agent", appName);
con.setRequestProperty("X-ECOMP-RequestID", requestId);
logger.debug("Post: X-ECOMP-RequestID: "+ requestId);
- con.setRequestProperty("username", appUserName);
- con.setRequestProperty("password", appPassword);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword);
if (useBasicAuth) {
String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + appPassword).getBytes());
con.setRequestProperty("Authorization", "Basic " + encoding);
Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
// add request header
- con.setRequestProperty("uebkey", appUebKey);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, appUebKey);
if (appUserName != null)
- con.setRequestProperty("username", appUserName);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName);
if (appPassword != null)
- con.setRequestProperty("password", appPassword);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword);
con.setRequestProperty("LoginId", loginId);
con.setRequestProperty("user-agent", appName);
con.setRequestProperty("X-ECOMP-RequestID", requestId);
Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
// add request header
- con.setRequestProperty("uebkey", appUebKey);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, appUebKey);
if (appUserName != null)
- con.setRequestProperty("username", appUserName);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName);
if (appPassword != null)
- con.setRequestProperty("password", appPassword);
+ con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword);
con.setRequestProperty("LoginId", loginId);
con.setRequestProperty("user-agent", appName);
con.setRequestProperty("X-ECOMP-RequestID", requestId);
import org.onap.aaf.cadi.CadiWrap;
import org.onap.aaf.cadi.Permission;
import org.onap.aaf.cadi.aaf.AAFPermission;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
public class AuthUtil {
String appName = "";
for (Map.Entry<String, String> entry : appCredentials.entrySet()) {
- if (entry.getKey().equalsIgnoreCase("username")) {
+ if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) {
appUserName = entry.getValue();
- } else if (entry.getKey().equalsIgnoreCase("password")) {
+ } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) {
appPassword = entry.getValue();
} else {
appName = entry.getValue();
}
try {
- String appUser = request.getHeader("username");
- String password = request.getHeader("password");
+ String appUser = request.getHeader(IPortalRestCentralService.CREDENTIALS_USER);
+ String password = request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS);
if (password.equals(appPassword) && appUserName.equals(appUser)) {
isauthorized = true;
private static final Log logger = LogFactory.getLog(KeyProperties.class);
private static Properties properties;
- private static String propertyFileName = "key.properties";
+ public static final String PROPERTY_FILE_NAME = "key.properties";
private static final Object lockObject = new Object();
synchronized (lockObject) {
try {
if (!initialize()) {
- logger.error("Failed to read property file " + propertyFileName);
+ logger.error("Failed to read property file " + PROPERTY_FILE_NAME);
return null;
}
} catch (IOException e) {
- logger.error("Failed to read property file " + propertyFileName, e);
+ logger.error("Failed to read property file " + PROPERTY_FILE_NAME, e);
return null;
}
}
private static boolean initialize() throws IOException {
if (properties != null)
return true;
- InputStream in = KeyProperties.class.getClassLoader().getResourceAsStream(propertyFileName);
+ InputStream in = KeyProperties.class.getClassLoader().getResourceAsStream(PROPERTY_FILE_NAME);
if (in == null)
return false;
properties = new Properties();
private static final Log logger = LogFactory.getLog(PortalApiProperties.class);
private static Properties properties;
- private static String propertyFileName = "portal.properties";
+ public static final String PROPERTY_FILE_NAME = "portal.properties";
private static final Object lockObject = new Object();
synchronized (lockObject) {
try {
if (!initialize()) {
- logger.error("Failed to read property file " + propertyFileName);
+ logger.error("Failed to read property file " + PROPERTY_FILE_NAME);
return null;
}
} catch (IOException e) {
- logger.error("Failed to read property file " + propertyFileName, e);
+ logger.error("Failed to read property file " + PROPERTY_FILE_NAME, e);
return null;
}
}
public static boolean initialize() throws IOException {
if (properties != null)
return true;
- InputStream in = PortalApiProperties.class.getClassLoader().getResourceAsStream(propertyFileName);
+ InputStream in = PortalApiProperties.class.getClassLoader().getResourceAsStream(PROPERTY_FILE_NAME);
if (in == null)
return false;
properties = new Properties();
@Test
public void testDoPost_WhenRequestForStoreAnalytics() throws Exception {
Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test");
- Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}});
+ Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put(IPortalRestCentralService.CREDENTIALS_USER,"test");put(IPortalRestCentralService.CREDENTIALS_PASS,"test");}});
Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/storeAnalytics");
doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response});
}
@Test
public void testDoGet_WhenRequestForAnalytics() throws Exception {
Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test");
- Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}});
+ Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put(IPortalRestCentralService.CREDENTIALS_USER,"test");put(IPortalRestCentralService.CREDENTIALS_PASS,"test");}});
Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/analytics");
doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response});
}
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.onap.aaf.cadi.CadiWrap;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
public class AuthUtilTest {
@Test(expected = PortalAPIException.class)
public void isAccessAllowedExceptionTest() throws PortalAPIException {
Map<String, String> appCreds = new HashMap<>();
- appCreds.put("username", "test");
- appCreds.put("password", "test1");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test1");
AuthUtil.isAccessAllowed(request, "com.test", appCreds);
}
@Test
public void isAccessAllowedTest() throws PortalAPIException {
- Mockito.when(request.getHeader("username")).thenReturn("test");
- Mockito.when(request.getHeader("password")).thenReturn("test1");
+ Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_USER)).thenReturn("test");
+ Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS)).thenReturn("test1");
Map<String, String> appCreds = new HashMap<>();
- appCreds.put("username", "test");
- appCreds.put("password", "test1");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test1");
assertTrue(AuthUtil.isAccessAllowed(request, "com.test", appCreds));
}
@Test
public void isAccessAllowedFalseTest() throws PortalAPIException {
- Mockito.when(request.getHeader("username")).thenReturn("test");
- Mockito.when(request.getHeader("password")).thenReturn("test1");
+ Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_USER)).thenReturn("test");
+ Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS)).thenReturn("test1");
Map<String, String> appCreds = new HashMap<>();
- appCreds.put("username", "test");
- appCreds.put("password", "test123");
- appCreds.put("appName", "testApp");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test123");
+ appCreds.put(IPortalRestCentralService.CREDENTIALS_APP, "testApp");
assertFalse(AuthUtil.isAccessAllowed(request, "com.test", appCreds));
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.crossapi.SessionCommunicationService;
import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler.SessionCommInf;
public static class RestResource {
@POST
@Produces(MediaType.APPLICATION_JSON)
- public String get( @HeaderParam("username") String username,
- @HeaderParam("password") String password, @HeaderParam("uebkey") String uebkey) {
+ public String get( @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_UEB) String uebkey) {
return "{ 'post-session' : '" + username + "' }";
}
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
public static class RestResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public String get(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username,
- @HeaderParam("password") String password) {
+ public String get(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) {
return "{ 'get' : '" + loginId + "' }";
}
@POST
- public String post(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username,
- @HeaderParam("password") String password) {
+ public String post(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) {
return "{ 'post' : '" + loginId + "' }";
}
@DELETE
- public String delete(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username,
- @HeaderParam("password") String password) {
+ public String delete(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) {
return "{ 'delete' : '" + loginId + "' }";
}
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.crossapi.SessionCommunicationService;
import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler.SessionCommInf;
public static class RestResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public String get( @HeaderParam("username") String username,
- @HeaderParam("password") String password, @HeaderParam("uebkey") String uebkey) {
+ public String get( @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password,
+ @HeaderParam(IPortalRestCentralService.CREDENTIALS_UEB) String uebkey) {
// Expects only an integer, not even a POJO/JSON model.
return timeoutValue;
}