summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-fw/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/main')
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java)139
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java67
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java76
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java)77
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java)74
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java64
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java64
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java)50
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java)87
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java72
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserSessionListener.java)46
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FavoritesClient.java)50
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FunctionalMenuClient.java)50
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java)415
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java174
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java)44
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java)58
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java)51
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java83
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompRole.java)48
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompUser.java)54
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java76
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java (renamed from ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/SharedContext.java)70
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java47
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java58
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/exception/PortalAPIException.java46
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserContextListener.java54
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java125
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java46
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/PortalTimeoutVO.java63
30 files changed, 1499 insertions, 929 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
index b2d5ef3d..182d2675 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
@@ -1,31 +1,49 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.crossapi;
+package org.onap.portalsdk.core.onboarding.crossapi;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.openecomp.portalsdk.core.restful.domain.EcompRole;
-import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
/**
* Defines the REST API Interface that an on-boarding application must implement
@@ -37,32 +55,32 @@ public interface IPortalRestAPIService {
// EcompUser Interface
/**
- * Creates a user with the specified details. If any error occurs, for
- * example the user exists, the method should throw PortalApiException with
- * an appropriate message. The FW library will catch the exception and send
- * an appropriate response to Portal.
+ * Creates a user with the specified details. If any error occurs, for example
+ * the user exists, the method should throw PortalApiException with an
+ * appropriate message. The FW library will catch the exception and send an
+ * appropriate response to Portal.
*
* @param user
* Model object with attributes of user to be created.
* @throws PortalAPIException
- * If any error occurs while processing the request; for
- * example, user exists.
+ * If any error occurs while processing the request; for example,
+ * user exists.
*/
public void pushUser(EcompUser user) throws PortalAPIException;
/**
- * Updates details about the user with the specified loginId. For example,
- * mark user as inactive. 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.
+ * Updates details about the user with the specified loginId. For example, mark
+ * user as inactive. 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.
*
* @param loginId
* EcompUser ID to be updated.
* @param user
* Model object with attributes of user to be updated.
* @throws PortalAPIException
- * If any error occurs while processing the request; for
- * example, unknown user.
+ * If any error occurs while processing the request; for example,
+ * unknown user.
*/
public void editUser(String loginId, EcompUser user) throws PortalAPIException;
@@ -76,19 +94,17 @@ public interface IPortalRestAPIService {
* EcompUser ID to be fetched
* @return Model object with user attributes.
* @throws PortalAPIException
- * If any error occurs while processing the request; for
- * example, unknown user.
+ * If any error occurs while processing the request; for example,
+ * unknown user.
*/
public EcompUser getUser(String loginId) throws PortalAPIException;
/**
* Gets and returns a list of active users. 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.
+ * should throw PortalApiException with an appropriate message. The FW library
+ * will catch the exception and send an appropriate response to Portal.
*
- * @return List of user attribute model objects; empty list if none are
- * found.
+ * @return List of user attribute model objects; empty list if none are found.
* @throws PortalAPIException
* If any error occurs while processing the request.
*/
@@ -98,12 +114,11 @@ public interface IPortalRestAPIService {
/**
* Gets and returns a list of active roles. 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.
+ * should throw PortalApiException with an appropriate message. The FW library
+ * will catch the exception and send an appropriate response to Portal.
*
- * @param requestedLoginId
- * requested userloginId to fetch available roles
+ * @param requestedLoginId
+ * requested userloginId to fetch available roles
* @return List of role attribute objects; empty list if none are found.
* @throws PortalAPIException
* If an unexpected error occurs while processing the request.
@@ -111,15 +126,14 @@ public interface IPortalRestAPIService {
public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
/**
- * Updates roles for the user with the specified loginId to the list of
- * roles provided as the second argument. After this operation, the should
- * have ONLY the roles provided in the list above. For example, if user had
- * roles r1, r2 and r3; and a call was made to pushUserRole with a list
- * containing only roles r3 and r4, this method should leave the user with
- * roles r3 and r4 since those were the ONLY roles provided in second
- * argument. 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.
+ * Updates roles for the user with the specified loginId to the list of roles
+ * provided as the second argument. After this operation, the should have ONLY
+ * the roles provided in the list above. For example, if user had roles r1, r2
+ * and r3; and a call was made to pushUserRole with a list containing only roles
+ * r3 and r4, this method should leave the user with roles r3 and r4 since those
+ * were the ONLY roles provided in second argument. 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.
*
* @param loginId
* EcompUser ID to be updated.
@@ -131,30 +145,32 @@ public interface IPortalRestAPIService {
public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
/**
- * Gets and returns a list of roles for the user with the specified loginId.
- * If any error occurs, the method should throw PortalApiException with an
+ * Gets and returns a list of roles for the user with the specified loginId. 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.
*
* @param loginId
+ * Organization user ID
* @return List of model objects; empty if no roles are found.
* @throws PortalAPIException
- * If any error occurs while processing the request; e.g., user
- * not found.
+ * If any error occurs while processing the request; e.g., user not
+ * found.
*/
public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
// Security Interface
/**
- * Should return true if the call should be allowed and false if not.
- * Currently Portal sends two headers of username and password in each
- * request which the app should check. If match, return true; else return
- * false. 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.
+ * Should return true if the call should be allowed and false if not. Currently
+ * Portal sends two headers of username and password in each request which the
+ * app should check. If match, return true; else return false. 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.
*
* @param request
+ * HttpServletRequest
* @return true if the request contains appropriate credentials, else false.
* @throws PortalAPIException
* If an unexpected error occurs while processing the request.
@@ -162,12 +178,13 @@ public interface IPortalRestAPIService {
public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
/**
- * Gets and returns the userId for the logged-in user based on the request.
- * If any error occurs, the method should throw PortalApiException with an
+ * Gets and returns the userId for the logged-in user based on the request. 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.
*
* @param request
+ * HttpServletRequest
* @return true if the request contains appropriate credentials, else false.
* @throws PortalAPIException
* If an unexpected error occurs while processing the request.
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java
new file mode 100644
index 00000000..aa11aafe
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java
@@ -0,0 +1,67 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.crossapi;
+
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+
+/**
+ * UEB API Interface for all the onboarding third party applications.
+ */
+
+public interface IPortalUebAPIService {
+ // User Interface
+ public String pushUser(String userJson) throws PortalAPIException;
+
+ public String editUser(String loginId, String userJson) throws PortalAPIException;
+
+ public String getUser(String loginId) throws PortalAPIException;
+
+ public String getUsers() throws PortalAPIException;
+
+ // Roles Interface
+ public String getAvailableRoles() throws PortalAPIException;
+
+ public String getAvailableFullRoles() throws PortalAPIException;
+
+ public String pushUserRole(String loginId, String rolesJson) throws PortalAPIException;
+
+ public String getUserRoles(String loginId) throws PortalAPIException;
+
+ // Security Interface
+ public boolean isAppAuthenticated(String appUserName, String appPassword) throws PortalAPIException;
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java
new file mode 100644
index 00000000..6ae2cdd8
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java
@@ -0,0 +1,76 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.crossapi;
+
+/**
+ * This bean holds a response that is returned by the role and user-management
+ * REST API.
+ */
+public class PortalAPIResponse {
+
+ /**
+ * Either "ok" or "error"
+ */
+ private String status;
+ /**
+ * Optional if status is ok
+ */
+ private String message;
+
+ public PortalAPIResponse(boolean isOk, String msg) {
+ status = (isOk? "ok" : "error");
+ message = msg;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
index 01337f78..869500f2 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.crossapi;
+package org.onap.portalsdk.core.onboarding.crossapi;
import java.io.BufferedReader;
import java.io.IOException;
@@ -36,13 +54,13 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
-import org.openecomp.portalsdk.core.onboarding.rest.RestWebServiceClient;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
-import org.openecomp.portalsdk.core.restful.domain.EcompRole;
-import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
+import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -320,9 +338,9 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
contentType = "text/javascript";
-
+
responseString = RestWebServiceClient.getInstance().getPortalContent(webAnalyticsContextPath,
- userId, credential, null, credential, credential,true);
+ userId, credential, null, credential, credential, true);
if (logger.isDebugEnabled())
logger.debug("doGet: " + webAnalyticsContextPath + ": " + responseString);
response.setStatus(HttpServletResponse.SC_OK);
@@ -398,7 +416,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
}
} else
// Example: /roles <-- get all roles
-
+
if (requestUri.endsWith(PortalApiConstants.API_PREFIX + "/roles")) {
try {
List<EcompRole> roles = getAvailableRoles(getUserId(request));
@@ -452,15 +470,15 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
writeAndFlush(response, contentTypeAppJson, responseJson);
}
- public String getSessionTimeOuts() throws Exception {
+ public String getSessionTimeOuts() {
return PortalTimeoutHandler.gatherSessionExtensions();
}
- public boolean timeoutSession(String portalJSessionId) throws Exception {
+ public boolean timeoutSession(String portalJSessionId) {
return PortalTimeoutHandler.invalidateSession(portalJSessionId);
}
- public boolean updateSessionTimeOuts(String sessionMap) throws Exception {
+ public boolean updateSessionTimeOuts(String sessionMap) {
return PortalTimeoutHandler.updateSessionExtensions(sessionMap);
}
@@ -524,8 +542,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
* Reads the request body and closes the input stream.
*
* @param request
- * @return String read from the request, the empty string if nothing is
- * read.
+ * @return String read from the request, the empty string if nothing is read.
* @throws IOException
*/
private static String readRequestBody(HttpServletRequest request) throws IOException {
@@ -584,8 +601,8 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
}
/**
- * Builds JSON object with status of error and message containing stack
- * trace for the specified throwable.
+ * Builds JSON object with status of error and message containing stack trace
+ * for the specified throwable.
*
* @param t
* Throwable with stack trace to use as message
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
index be3a7d54..1f9bfd07 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.crossapi;
+package org.onap.portalsdk.core.onboarding.crossapi;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -35,6 +53,7 @@ public class SessionCommunicationService {
* Calls the ECOMP Portal to retrieve the session slot check interval.
*
* @param ecompRestURL
+ * Remote system URL
* @param userName
* application user name used for authentication at Portal
* @param password
@@ -68,16 +87,14 @@ public class SessionCommunicationService {
logger.debug("getSessionSlotCheckInterval: Response Code : " + responseCode);
}
- StringBuffer response = new StringBuffer();
-
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
+ StringBuffer response = new StringBuffer();
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"))) {
String inputLine;
while ((inputLine = in.readLine()) != null)
response.append(inputLine);
- } finally {
- in.close();
+ }
+ catch (Exception ex) {
+ logger.error("getSessionSlotCheckInterval failed to read stream", ex);
}
return response.toString();
} catch (Exception e) {
@@ -91,6 +108,7 @@ public class SessionCommunicationService {
* Calls the ECOMP Portal to request an extension of the current session.
*
* @param ecompRestURL
+ * Remote system URL
* @param userName
* application user name used for authentication at Portal
* @param password
@@ -99,19 +117,15 @@ public class SessionCommunicationService {
* application UEB key (basically application ID) used for
* authentication at Portal
* @param sessionTimeoutMap
+ * Session timeout map
* @return Content read from the remote REST endpoint
- * @throws Exception
*/
public static String requestPortalSessionTimeoutExtension(String ecompRestURL, String userName, String password,
- String uebKey, String sessionTimeoutMap) throws Exception {
+ String uebKey, String sessionTimeoutMap) {
try {
String url = ecompRestURL + "/extendSessionTimeOuts";
- // String decreptedPwd =
- // app.appPassword;//CipherUtil.decrypt(encriptedPwdDB,
- // SystemProperties.getProperty(SystemProperties.SECRET_KEY));
-
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
@@ -140,15 +154,13 @@ public class SessionCommunicationService {
}
StringBuffer response = new StringBuffer();
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
- } finally {
- in.close();
+ } catch (Exception ex) {
+ logger.error("requestPortalSessionTimeoutExtension failed", ex);
}
return response.toString();
} catch (Exception e) {
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java
new file mode 100644
index 00000000..a1109abe
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java
@@ -0,0 +1,64 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.exception;
+
+public class CipherUtilException extends Exception {
+
+ private static final long serialVersionUID = -4163367786939629691L;
+
+ public CipherUtilException() {
+ super();
+ }
+
+ public CipherUtilException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public CipherUtilException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CipherUtilException(String message) {
+ super(message);
+ }
+
+ public CipherUtilException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java
new file mode 100644
index 00000000..ccfb95b2
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java
@@ -0,0 +1,64 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.exception;
+
+public class PortalAPIException extends Exception{
+
+ private static final long serialVersionUID = 4854048794984375707L;
+
+ public PortalAPIException() {
+ super();
+ }
+
+ public PortalAPIException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public PortalAPIException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PortalAPIException(String message) {
+ super(message);
+ }
+
+ public PortalAPIException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java
index 4a6b43bc..f700f261 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.listener;
+package org.onap.portalsdk.core.onboarding.listener;
import java.io.Serializable;
@@ -27,13 +45,13 @@ import javax.servlet.http.HttpSessionBindingListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
public class PortalTimeoutBindingListener implements HttpSessionBindingListener, Serializable {
- private final Log logger = LogFactory.getLog(getClass());
+ private static final long serialVersionUID = -8036365986695276137L;
- private static final long serialVersionUID = 1L;
+ private final Log logger = LogFactory.getLog(getClass());
@Override
public void valueBound(HttpSessionBindingEvent event) {
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java
index 90a9121c..649fb747 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.listener;
+package org.onap.portalsdk.core.onboarding.listener;
import java.util.Calendar;
import java.util.Hashtable;
@@ -28,9 +46,9 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.crossapi.SessionCommunicationService;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.restful.domain.PortalTimeoutVO;
+import org.onap.portalsdk.core.onboarding.crossapi.SessionCommunicationService;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.restful.domain.PortalTimeoutVO;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -45,13 +63,13 @@ public class PortalTimeoutHandler {
protected static final SessionCommInf sessionComm = new SessionComm();
public interface SessionCommInf {
- public Integer fetchSessionSlotCheckInterval(String... params) throws Exception;
+ public Integer fetchSessionSlotCheckInterval(String... params);
- public void extendSessionTimeOuts(String... sessionMap) throws Exception;
+ public void extendSessionTimeOuts(String... sessionMap);
}
public static class SessionComm implements SessionCommInf {
- public Integer fetchSessionSlotCheckInterval(String... params) throws Exception {
+ public Integer fetchSessionSlotCheckInterval(String... params) {
String ecompRestURL = params[0];
String userName = params[1];
@@ -65,7 +83,7 @@ public class PortalTimeoutHandler {
return Integer.parseInt(sessionSlot);
}
- public void extendSessionTimeOuts(String... params) throws Exception {
+ public void extendSessionTimeOuts(String... params) {
String ecompRestURL = params[0];
String userName = params[1];
@@ -95,8 +113,11 @@ public class PortalTimeoutHandler {
* TODO: remove static
*
* @param portalJSessionId
+ * Portal (remote) session ID
* @param jSessionId
+ * Local session ID
* @param session
+ * HttpSession
*/
public static void sessionCreated(String portalJSessionId, String jSessionId, HttpSession session) {
@@ -139,6 +160,7 @@ public class PortalTimeoutHandler {
* TODO: remove static
*
* @param session
+ * HttpSession
*/
public static void sessionDestroyed(HttpSession session) {
try {
@@ -154,6 +176,7 @@ public class PortalTimeoutHandler {
* TODO: remove static
*
* @param portalJSessionId
+ * Portal session ID
* @return true on success, false if the session cannot be found, etc.
*/
public static boolean invalidateSession(String portalJSessionId) {
@@ -223,10 +246,10 @@ public class PortalTimeoutHandler {
* TODO: remove static
*
* @param sessionTimeoutMapStr
+ * Session timeout map as string
* @return true on success, false otherwise
- * @throws Exception
*/
- public static boolean updateSessionExtensions(String sessionTimeoutMapStr) throws Exception {
+ public static boolean updateSessionExtensions(String sessionTimeoutMapStr) {
logger.debug("Session Management: updateSessionExtensions");
// Map<String,Object> sessionTimeoutMap =
// mapper.readValue(sessionTimeoutMapStr, Map.class);
@@ -279,10 +302,17 @@ public class PortalTimeoutHandler {
* TODO: Remove static
*
* @param request
+ * HttpServletRequest
* @param userName
+ * User name
* @param pwd
+ * Password
+ * @param uebKey
+ * UEB key (application ID)
* @param ecompRestURL
+ * Remote system URL
* @param _sessionComm
+ * Session communication information
*/
public static void handleSessionUpdatesNative(HttpServletRequest request, String userName, String pwd,
String uebKey, String ecompRestURL, SessionCommInf _sessionComm) {
@@ -302,16 +332,22 @@ public class PortalTimeoutHandler {
* TODO: remove Static
*
* @param request
+ * HttpServletRequest
* @param ecompRestURL
+ * Remote URL
* @param userName
+ * user name
* @param pwd
+ * password
+ * @param uebKey
+ * UEB key
* @param _sessionComm
+ * session information
* @throws JsonProcessingException
- * @throws Exception
+ * On failure to serialize
*/
public static void synchronizeSessionForLastMinuteRequests(HttpServletRequest request, String ecompRestURL,
- String userName, String pwd, String uebKey, SessionCommInf _sessionComm)
- throws JsonProcessingException, Exception {
+ String userName, String pwd, String uebKey, SessionCommInf _sessionComm) throws JsonProcessingException {
HttpSession session = request.getSession(false);
if (session == null)
@@ -363,6 +399,7 @@ public class PortalTimeoutHandler {
* TODO: remove static
*
* @param request
+ * HttpServletRequest
*/
public static void resetSessionMaxIdleTimeOut(HttpServletRequest request) {
try {
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java
new file mode 100644
index 00000000..8599a67c
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java
@@ -0,0 +1,72 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.listener;
+
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.http.HttpSession;
+
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+
+@WebListener
+public class UserContextListener implements ServletContextListener {
+
+ public void contextInitialized(ServletContextEvent event) {
+ ServletContext context = event.getServletContext();
+ //
+ // create a map to store references to all the active
+ // sessions and bind it to context scope.
+ //
+ HashMap<String, HttpSession> activeUsers = new HashMap<String, HttpSession>();
+ context.setAttribute(PortalApiConstants.ACTIVE_USERS_NAME, activeUsers);
+ }
+
+ /**
+ * Needed for the ServletContextListener interface.
+ */
+ public void contextDestroyed(ServletContextEvent event) {
+ // To overcome the problem with losing the session references
+ // during server restarts, put code here to serialize the
+ // activeUsers HashMap. Then put code in the contextInitialized
+ // method that reads and reloads it if it exists...
+ }
+} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserSessionListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java
index 88934282..95b2d44e 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserSessionListener.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.listener;
+package org.onap.portalsdk.core.onboarding.listener;
import java.util.HashMap;
import java.util.Hashtable;
@@ -32,7 +50,7 @@ import javax.servlet.http.HttpSessionListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
/**
* Listens to session-create and session-destroy events.
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FavoritesClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java
index eed49f2a..92ea75a8 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FavoritesClient.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java
@@ -1,23 +1,43 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.rest;
+package org.onap.portalsdk.core.onboarding.rest;
+
+import java.io.IOException;
/**
* Provides a convenience method for fetching the favorites for a user from the
@@ -40,11 +60,11 @@ public class FavoritesClient {
* @param appPassword
* REST API decrypted password
* @return JSON with favorites
- * @throws Exception
+ * @throws IOException
* on any failure
*/
public static String getFavorites(String userId, String appName, String requestId, String appUserName,
- String appPassword) throws Exception {
+ String appPassword) throws IOException {
return RestWebServiceClient.getInstance().getPortalContent("/getFavorites", userId, appName, requestId, appUserName,
appPassword,true);
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FunctionalMenuClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
index 90cbdcb4..7fc98c67 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
@@ -1,23 +1,43 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.rest;
+package org.onap.portalsdk.core.onboarding.rest;
+
+import java.io.IOException;
/**
* Provides a convenience method for fetching the functional menu for a user
@@ -42,11 +62,11 @@ public class FunctionalMenuClient {
* REST API password (in the clear, not encrypted), used by
* Portal to authenticate the request
* @return JSON with functional menu
- * @throws Exception
+ * @throws IOException
* on any failure
*/
public static String getFunctionalMenu(String userId, String appName, String requestId, String appUserName,
- String appPassword) throws Exception {
+ String appPassword) throws IOException {
return RestWebServiceClient.getInstance().getPortalContent("/functionalMenuItemsForUser", userId, appName,
requestId, appUserName, appPassword,true);
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java
index 44177466..7c9f72a1 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java
@@ -1,26 +1,44 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.rest;
+package org.onap.portalsdk.core.onboarding.rest;
-import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -29,12 +47,12 @@ import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
/**
- * Simple REST client for GET-ing content from and POST-ing content , Delete to the
- * Portal application.
+ * Simple REST client for GET, POST and DELETE operations against the Portal
+ * application.
*/
public class RestWebServiceClient {
@@ -46,15 +64,14 @@ public class RestWebServiceClient {
private static RestWebServiceClient instance = null;
/**
- * Constructor is private. Clients should obtain an instance via
- * getInstance().
+ * Constructor is private. Clients should obtain an instance via getInstance().
*/
private RestWebServiceClient() {
}
/**
- * Gets the static instance of RestWebServiceClient; creates it if
- * necessary. Synchronized to be thread safe.
+ * Gets the static instance of RestWebServiceClient; creates it if necessary.
+ * Synchronized to be thread safe.
*
* @return Static instance of RestWebServiceClient.
*/
@@ -65,8 +82,8 @@ public class RestWebServiceClient {
}
/**
- * Convenience method that fetches the URL for the Portal REST API endpoint
- * and the application UEB key, then calls
+ * Convenience method that fetches the URL for the Portal REST API endpoint and
+ * the application UEB key, then calls
* {@link #get(String, String, String, String, String, String, String)} to
* access the Portal's REST endpoint.
*
@@ -83,37 +100,33 @@ public class RestWebServiceClient {
* @param appPassword
* REST API password (in the clear, not encrypted) for Portal to
* authenticate the request
+ * @param isBasicAuth
+ * If true, send credentials as HTTP Basic Authentication
* @return Content from REST endpoint
- * @throws Exception
+ * @throws IOException
* on any failure
*/
- public String getPortalContent(String restPath,String userId, String appName, String requestId, String appUserName, String appPassword, boolean isBasicAuth) throws Exception {
- String restURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
-
+ public String getPortalContent(String restPath, String userId, String appName, String requestId, String appUserName,
+ String appPassword, boolean isBasicAuth) throws IOException {
+ String restURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
if (restURL == null) {
- // should never happen
String msg = "getPortalContent: failed to get property " + PortalApiConstants.ECOMP_REST_URL;
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
String appUebKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
-
if (appUebKey == null) {
- // should never happen
- String msg = "getPortalContent: failed to get property " + PortalApiConstants.UEB_APP_KEY;
-
+ String msg = "getPortalContent: failed to get property " + PortalApiConstants.UEB_APP_KEY;
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
final String restEndpointUrl = restURL + restPath;
- if(isBasicAuth)
- {
- return get(restEndpointUrl, userId,appName, requestId, appUebKey, appUserName, appPassword,isBasicAuth);
+ if (isBasicAuth) {
+ return get(restEndpointUrl, userId, appName, requestId, appUebKey, appUserName, appPassword, isBasicAuth);
}
- return get(restEndpointUrl, userId,appName, requestId, appUebKey, appUserName, appPassword);
+ return get(restEndpointUrl, userId, appName, requestId, appUebKey, appUserName, appPassword);
}
-
/**
* Makes a call to a Portal REST API using the specified URL and parameters.
*
@@ -125,26 +138,24 @@ public class RestWebServiceClient {
* Application name for logging; if null or empty, defaulted to
* Unknown.
* @param requestId
- * 128-bit UUID value to uniquely identify the transaction; if
- * null or empty, one is generated.
+ * 128-bit UUID value to uniquely identify the transaction; if null
+ * or empty, one is generated.
* @param appUebKey
- * Unique key for the application, used by Portal to authenticate
- * the request
+ * Unique key for the application, used by Portal to authenticate the
+ * request
* @param appUserName
* REST API user name, used by Portal to authenticate the request
* @param appPassword
* REST API password, used by Portal to authenticate the request
* @return Content from REST endpoint
- * @throws Exception
+ * @throws IOException
* On any failure; e.g., unknown host.
*/
-
public String get(String url, String loginId, String appName, String requestId, String appUebKey,
- String appUserName, String appPassword) throws Exception {
- return get(url, loginId, appName,requestId, appUebKey, appUserName, appPassword, false);
+ String appUserName, String appPassword) throws IOException {
+ return get(url, loginId, appName, requestId, appUebKey, appUserName, appPassword, false);
}
-
-
+
/**
* Makes a call to a Portal REST API using the specified URL and parameters.
*
@@ -156,21 +167,23 @@ public class RestWebServiceClient {
* Application name for logging; if null or empty, defaulted to
* Unknown.
* @param requestId
- * 128-bit UUID value to uniquely identify the transaction; if
- * null or empty, one is generated.
+ * 128-bit UUID value to uniquely identify the transaction; if null
+ * or empty, one is generated.
* @param appUebKey
- * Unique key for the application, used by Portal to authenticate
- * the request
+ * Unique key for the application, used by Portal to authenticate the
+ * request
* @param appUserName
* REST API user name, used by Portal to authenticate the request
* @param appPassword
* REST API password, used by Portal to authenticate the request
+ * @param useBasicAuth
+ * If true, send credentials as HTTP Basic Authentication
* @return Content from REST endpoint
- * @throws Exception
+ * @throws IOException
* On any failure; e.g., unknown host.
*/
public String get(String url, String loginId, String appName, String requestId, String appUebKey,
- String appUserName, String appPassword, Boolean useBasicAuth) throws Exception {
+ String appUserName, String appPassword, Boolean useBasicAuth) throws IOException {
logger.debug("RestWebServiceClient.get (" + url + ") operation is started.");
@@ -183,16 +196,16 @@ public class RestWebServiceClient {
// Create the connection object
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
-
+ // if the portal property is set then gets the timeout value from portal
+ // properties
con.setConnectTimeout(3000);
- // if the portal property is set then gets the timeout value from portal properties
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){
- con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
- }
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT) != null)
+ con.setConnectTimeout(Integer
+ .parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
con.setReadTimeout(8000);
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){
- con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
- }
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT) != null)
+ con.setReadTimeout(
+ Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
// add request header
con.setRequestProperty("uebkey", appUebKey);
@@ -201,42 +214,25 @@ public class RestWebServiceClient {
con.setRequestProperty("X-ECOMP-RequestID", requestId);
con.setRequestProperty("username", appUserName);
con.setRequestProperty("password", appPassword);
-
- if(useBasicAuth){
+ if (useBasicAuth) {
String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + appPassword).getBytes());
- con.setRequestProperty("Authorization", "Basic "+ encoding);
- }
-
+ con.setRequestProperty("Authorization", "Basic " + encoding);
+ }
+
int responseCode = con.getResponseCode();
logger.debug("get: received response code '" + responseCode + "' while getting the '" + url + "' for user: "
+ loginId);
- StringBuffer sb = new StringBuffer();
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
- String inputLine = null;
- while ((inputLine = in.readLine()) != null)
- sb.append(inputLine);
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException ex) {
- logger.error("get: failed to close reader", ex);
- }
- }
-
- final String response = sb.toString();
+ final String response = readAndCloseStream(con.getInputStream());
if (logger.isDebugEnabled())
logger.debug("get: url " + url + " yielded " + response);
return response;
}
-
+
/**
- * Convenience method that fetches the URL for the Portal REST API endpoint
- * and the application UEB key, then calls
- * {@link #post(String, String, String, String, String, String, String, String, String)}
+ * Convenience method that fetches the URL for the Portal REST API endpoint and
+ * the application UEB key, then calls
+ * {@link #post(String, String, String, String, String, String, String, String, String, boolean)}
* to access the Portal's REST endpoint.
*
* @param restPath
@@ -248,8 +244,8 @@ public class RestWebServiceClient {
* @param requestId
* 128-bit UUID value to uniquely identify the transaction.
* @param appUserName
- * REST API user name for Portal to authenticate the request;
- * ignored if null
+ * REST API user name for Portal to authenticate the request; ignored
+ * if null
* @param appPassword
* REST API password (in the clear, not encrypted) for Portal to
* authenticate the request; ignored if null
@@ -257,35 +253,32 @@ public class RestWebServiceClient {
* content type for header
* @param content
* String to post
+ * @param isBasicAuth
+ * If true, use HTTP Basic Authentication
* @return Content from REST endpoint
- * @throws Exception
+ * @throws IOException
* on any failure
*/
public String postPortalContent(String restPath, String userId, String appName, String requestId,
- String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth) throws Exception {
+ String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth)
+ throws IOException {
String restURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
-
if (restURL == null) {
- // should never happen
String msg = "getPortalContent: failed to get property " + PortalApiConstants.ECOMP_REST_URL;
-
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
String appUebKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
-
if (appUebKey == null) {
- // should never happen
String msg = "getPortalContent: failed to get property " + PortalApiConstants.UEB_APP_KEY;
-
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
final String separator = restURL.endsWith("/") || restPath.startsWith("/") ? "" : "/";
final String restEndpointUrl = restURL + separator + restPath;
return post(restEndpointUrl, userId, appName, requestId, appUebKey, appUserName, appPassword, contentType,
- content,isBasicAuth);
+ content, isBasicAuth);
}
/**
@@ -300,11 +293,11 @@ public class RestWebServiceClient {
* Application name for logging; if null or empty, defaulted to
* Unknown.
* @param requestId
- * 128-bit UUID value to uniquely identify the transaction; if
- * null or empty, one is generated.
+ * 128-bit UUID value to uniquely identify the transaction; if null
+ * or empty, one is generated.
* @param appUebKey
- * Unique key for the application, used by Portal to authenticate
- * the request
+ * Unique key for the application, used by Portal to authenticate the
+ * request
* @param appUserName
* REST API user name used by Portal to authenticate the request;
* ignored if null
@@ -315,12 +308,15 @@ public class RestWebServiceClient {
* MIME header
* @param content
* Content to POST
+ * @param isBasicAuth
+ * If true, use HTTP Basic Authentication
* @return Any content read from the endpoint
- * @throws Exception
+ * @throws IOException
* On any error
*/
public String post(String url, String loginId, String appName, String requestId, String appUebKey,
- String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth) throws Exception {
+ String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth)
+ throws IOException {
if (logger.isDebugEnabled())
logger.debug("RestWebServiceClient.post to URL " + url);
@@ -333,17 +329,18 @@ public class RestWebServiceClient {
// Create the connection object
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
-
+
con.setConnectTimeout(3000);
- // if the portal property is set then gets the timeout value from portal properties
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){
- con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
- }
+ // if the portal property is set then gets the timeout value from portal
+ // properties
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT) != null)
+ con.setConnectTimeout(Integer
+ .parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
con.setReadTimeout(15000);
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){
- con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
- }
-
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT) != null)
+ con.setReadTimeout(
+ Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
+
// add request header
con.setRequestProperty("uebkey", appUebKey);
if (appUserName != null)
@@ -354,72 +351,114 @@ public class RestWebServiceClient {
con.setRequestProperty("user-agent", appName);
con.setRequestProperty("X-ECOMP-RequestID", requestId);
con.setRequestProperty("Content-Type", contentType);
- if(isBasicAuth){
+ if (isBasicAuth) {
String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + appPassword).getBytes());
- con.setRequestProperty("Authorization", "Basic "+ encoding);
- }
+ con.setRequestProperty("Authorization", "Basic " + encoding);
+ }
con.setDoInput(true);
con.setDoOutput(true);
- if( content != null)
- {
- con.getOutputStream().write(content.getBytes());
+ if (content != null) {
+ con.getOutputStream().write(content.getBytes());
}
con.getOutputStream().flush();
con.getOutputStream().close();
int responseCode = con.getResponseCode();
logger.debug("Response Code : " + responseCode);
-
- StringBuffer sb = new StringBuffer();
- InputStreamReader in = null;
- char[] buf = new char[8196];
- int bytes;
- try {
- in = new InputStreamReader(con.getInputStream(), "UTF-8");
- while ((bytes = in.read(buf)) > 0)
- sb.append(new String(buf, 0, bytes));
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException ex) {
- logger.warn("get: failed to close reader", ex);
- }
- }
-
- return sb.toString();
+ final String response = readAndCloseStream(con.getInputStream());
+ return response;
}
-
-
+
+ /**
+ * Convenience method that fetches the URL for the Portal REST API endpoint and
+ * the application UEB key, then calls
+ * {@link #delete(String, String, String, String, String, String, String, String, String, boolean)}
+ * to access the Portal's REST endpoint.
+ *
+ * @param restPath
+ * Complete URL of the REST endpoint.
+ * @param userId
+ * User who is fetching the data
+ * @param appName
+ * Application name for logging; if null or empty, defaulted to
+ * Unknown.
+ * @param requestId
+ * 128-bit UUID value to uniquely identify the transaction; if null
+ * or empty, one is generated.
+ * @param appUserName
+ * REST API user name used by Portal to authenticate the request;
+ * ignored if null
+ * @param appPassword
+ * REST API password used by Portal to authenticate the request;
+ * ignored if null
+ * @param contentType
+ * MIME header
+ * @param content
+ * Content
+ * @param isBasicAuth
+ * If true, use HTTP Basic Authentication
+ * @return Any content read from the endpoint
+ * @throws IOException
+ * On any error
+ */
public String deletePortalContent(String restPath, String userId, String appName, String requestId,
- String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth) throws Exception {
+ String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth)
+ throws IOException {
String restURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
-
if (restURL == null) {
- // should never happen
- String msg = "getPortalContent: failed to get property " + PortalApiConstants.ECOMP_REST_URL;
-
+ String msg = "deletePortalContent: failed to get property " + PortalApiConstants.ECOMP_REST_URL;
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
String appUebKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
-
if (appUebKey == null) {
- // should never happen
- String msg = "getPortalContent: failed to get property " + PortalApiConstants.UEB_APP_KEY;
-
+ String msg = "deletePortalContent: failed to get property " + PortalApiConstants.UEB_APP_KEY;
logger.error(msg);
- throw new Exception(msg);
+ throw new IOException(msg);
}
final String separator = restURL.endsWith("/") || restPath.startsWith("/") ? "" : "/";
final String restEndpointUrl = restURL + separator + restPath;
return delete(restEndpointUrl, userId, appName, requestId, appUebKey, appUserName, appPassword, contentType,
- content,isBasicAuth);
+ content, isBasicAuth);
}
-
+
+ /**
+ * Makes a DELETE call to a Portal REST API using the specified URL and
+ * parameters.
+ *
+ * @param url
+ * Complete URL of the REST endpoint.
+ * @param loginId
+ * User who is fetching the data
+ * @param appName
+ * Application name for logging; if null or empty, defaulted to
+ * Unknown.
+ * @param requestId
+ * 128-bit UUID value to uniquely identify the transaction; if null
+ * or empty, one is generated.
+ * @param appUebKey
+ * Unique key for the application, used by Portal to authenticate the
+ * request
+ * @param appUserName
+ * REST API user name used by Portal to authenticate the request;
+ * ignored if null
+ * @param appPassword
+ * REST API password used by Portal to authenticate the request;
+ * ignored if null
+ * @param contentType
+ * MIME header
+ * @param content
+ * Content
+ * @param isBasicAuth
+ * If true, use HTTP Basic Authentication
+ * @return Any content read from the endpoint
+ * @throws IOException
+ * On any error
+ */
public String delete(String url, String loginId, String appName, String requestId, String appUebKey,
- String appUserName, String appPassword, String contentType, String content,boolean isBasicAuth) throws Exception {
+ String appUserName, String appPassword, String contentType, String content, boolean isBasicAuth)
+ throws IOException {
if (logger.isDebugEnabled())
logger.debug("RestWebServiceClient.post to URL " + url);
@@ -433,14 +472,16 @@ public class RestWebServiceClient {
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
con.setConnectTimeout(3000);
- // if the portal property is set then gets the timeout value from portal properties
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){
- con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
- }
+ // if the portal property is set then gets the timeout value from portal
+ // properties
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT) != null)
+ con.setConnectTimeout(Integer
+ .parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)));
con.setReadTimeout(15000);
- if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){
- con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
- }
+ if (PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT) != null)
+ con.setReadTimeout(
+ Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)));
+
// add request header
con.setRequestProperty("uebkey", appUebKey);
if (appUserName != null)
@@ -451,52 +492,58 @@ public class RestWebServiceClient {
con.setRequestProperty("user-agent", appName);
con.setRequestProperty("X-ECOMP-RequestID", requestId);
con.setRequestProperty("Content-Type", contentType);
- if(isBasicAuth){
+ if (isBasicAuth) {
String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + appPassword).getBytes());
- con.setRequestProperty("Authorization", "Basic "+ encoding);
- }
+ con.setRequestProperty("Authorization", "Basic " + encoding);
+ }
con.setDoInput(true);
con.setDoOutput(true);
- if( content != null)
- {
- con.getOutputStream().write(content.getBytes());
- }
+ if (content != null)
+ con.getOutputStream().write(content.getBytes());
con.getOutputStream().flush();
con.getOutputStream().close();
int responseCode = con.getResponseCode();
logger.debug("Response Code : " + responseCode);
+ final String response = readAndCloseStream(con.getInputStream());
+ return response;
+ }
+ /**
+ * Reads content of string to a StringBuffer, decoded as UTF-8, and returns as
+ * string.
+ *
+ * @param inputStream
+ * Stream to read
+ * @return String read
+ * @throws IOException
+ */
+ private String readAndCloseStream(InputStream inputStream) throws IOException {
StringBuffer sb = new StringBuffer();
InputStreamReader in = null;
char[] buf = new char[8196];
int bytes;
try {
- in = new InputStreamReader(con.getInputStream(), "UTF-8");
+ in = new InputStreamReader(inputStream, "UTF-8");
while ((bytes = in.read(buf)) > 0)
sb.append(new String(buf, 0, bytes));
} finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException ex) {
- logger.warn("get: failed to close reader", ex);
- }
+ if (in != null)
+ in.close();
}
-
return sb.toString();
}
-
/**
* Basic unit test for the client to call Portal app on localhost.
*
* @param args
* Ignored
- * @throws Exception
+ * @throws IOException
+ * On failure
*/
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) throws IOException {
RestWebServiceClient client = RestWebServiceClient.getInstance();
final String getUrl = "http://www.ecomp.openecomp.org:8080/ecompportal/auxapi/analytics";
String get = client.get(getUrl, "userId", "appName", null, "appUebKey", "appUserName", "appPassword", null);
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java
new file mode 100644
index 00000000..f3125f03
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java
@@ -0,0 +1,174 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.util;
+
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
+
+public class CipherUtil {
+
+ private static final Log logger = LogFactory.getLog(CipherUtil.class);
+
+ /**
+ * Default key.
+ */
+ private final static String key = "AGLDdG4D04BKm2IxIWEr8o==!";
+
+ /**
+ * Encrypts the text using the specified secret key.
+ *
+ * @param plainText
+ * Text to encrypt
+ * @param secretKey
+ * Key to use for encryption
+ * @return encrypted version of plain text.
+ * @throws CipherUtilException
+ * if any encryption step fails
+ */
+ public static String encrypt(String plainText, String secretKey) throws CipherUtilException {
+ String encryptedString = null;
+ try {
+ byte[] encryptText = plainText.getBytes("UTF-8");
+ byte[] rawKey = Base64.decodeBase64(secretKey);
+ SecretKeySpec sKeySpec = new SecretKeySpec(rawKey, "AES");
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.ENCRYPT_MODE, sKeySpec);
+ encryptedString = Base64.encodeBase64String(cipher.doFinal(encryptText));
+ } catch (BadPaddingException | IllegalBlockSizeException | InvalidKeyException | NoSuchAlgorithmException
+ | NoSuchPaddingException | UnsupportedEncodingException ex) {
+ logger.error("encrypt failed", ex);
+ throw new CipherUtilException(ex);
+ }
+ return encryptedString;
+ }
+
+ /**
+ * Encrypts the text using a default secret key.
+ *
+ * @param plainText
+ * Text to encrypt
+ * @return Encrypted Text
+ * @throws CipherUtilException
+ * if any decryption step fails
+ */
+ public static String encrypt(String plainText) throws CipherUtilException {
+ return CipherUtil.encrypt(plainText, key);
+ }
+
+ /**
+ * Decrypts the text using the specified secret key.
+ *
+ * @param encryptedText
+ * Text to decrypt
+ * @param secretKey
+ * Key to use for decryption
+ * @return plain text version of encrypted text
+ * @throws CipherUtilException
+ * if any decryption step fails
+ */
+ public static String decrypt(String encryptedText, String secretKey) throws CipherUtilException {
+ String encryptedString = null;
+ try {
+ byte[] rawKey = Base64.decodeBase64(secretKey);
+ SecretKeySpec sKeySpec = new SecretKeySpec(rawKey, "AES");
+ byte[] encryptText = Base64.decodeBase64(encryptedText.getBytes("UTF-8"));
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.DECRYPT_MODE, sKeySpec);
+ encryptedString = new String(cipher.doFinal(encryptText));
+ } catch (BadPaddingException | IllegalBlockSizeException | InvalidKeyException | NoSuchAlgorithmException
+ | NoSuchPaddingException | UnsupportedEncodingException ex) {
+ logger.error("decrypt failed", ex);
+ throw new CipherUtilException(ex);
+ }
+ return encryptedString;
+ }
+
+ /**
+ * Decrypts the text using a default secret key.
+ *
+ * @param encryptedText
+ * Text to decrypt
+ * @return Decrypted text
+ * @throws CipherUtilException
+ * if any decryption step fails
+ */
+ public static String decrypt(String encryptedText) throws CipherUtilException {
+ return CipherUtil.decrypt(encryptedText, key);
+ }
+
+ public static void main(String[] args) throws CipherUtilException {
+
+ String password = "Welcome123";
+ String encrypted;
+ String decrypted;
+
+ if (args.length != 2) {
+ System.out.println("Default password testing... ");
+ System.out.println("Plain password: " + password);
+ encrypted = encrypt(password);
+ System.out.println("Encrypted password: " + encrypted);
+ decrypted = decrypt(encrypted);
+ System.out.println("Decrypted password: " + decrypted);
+ } else {
+ String whatToDo = args[0];
+ if (whatToDo.equalsIgnoreCase("d")) {
+ encrypted = args[1];
+ System.out.println("Encrypted Text: " + encrypted);
+ decrypted = decrypt(encrypted);
+ System.out.println("Decrypted Text: " + decrypted);
+ } else {
+ decrypted = args[1];
+ System.out.println("Plain Text: " + decrypted);
+ encrypted = encrypt(decrypted);
+ System.out.println("Encrypted Text" + encrypted);
+ }
+ }
+ }
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java
index 087d03d5..1419851a 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.util;
+package org.onap.portalsdk.core.onboarding.util;
public interface PortalApiConstants {
public static final String API_PREFIX = "/api/v2";
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java
index 93572ee9..3d5ddae8 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.util;
+package org.onap.portalsdk.core.onboarding.util;
import java.io.IOException;
import java.io.InputStream;
@@ -42,6 +60,8 @@ public class PortalApiProperties {
private static Properties properties;
private static String propertyFileName = "portal.properties";
+ private static final Object lockObject = new Object();
+
/**
* Constructor is private.
*/
@@ -49,16 +69,17 @@ public class PortalApiProperties {
}
/**
- * Gets the property value for the specified key. If a value is found,
- * leading and trailing space is trimmed.
+ * Gets the property value for the specified key. If a value is found, leading
+ * and trailing space is trimmed.
*
* @param property
+ * Property key
* @return Value for the named property; null if the property file was not
* loaded or the key was not found.
*/
public static String getProperty(String property) {
if (properties == null) {
- synchronized (propertyFileName) {
+ synchronized (lockObject) {
try {
if (!initialize()) {
logger.error("Failed to read property file " + propertyFileName);
@@ -79,11 +100,12 @@ public class PortalApiProperties {
/**
* Reads properties from a portal.properties file on the classpath.
*
- * Clients do NOT need to call this method. Clients MAY call this method to
- * test whether the properties file can be loaded successfully.
+ * Clients do NOT need to call this method. Clients MAY call this method to test
+ * whether the properties file can be loaded successfully.
*
* @return True if properties were successfully loaded, else false.
* @throws IOException
+ * On failure
*/
public static boolean initialize() throws IOException {
if (properties != null)
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java
index 1d8a9620..00afecaf 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java
@@ -1,24 +1,42 @@
-/* ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
- *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.onboarding.util;
+package org.onap.portalsdk.core.onboarding.util;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -31,8 +49,8 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
public class SSOFilter implements Filter {
@@ -48,7 +66,8 @@ public class SSOFilter implements Filter {
(((HttpServletRequest) request).getRequestURI()
.substring(((HttpServletRequest) request).getContextPath().length() + 1)
+ (((HttpServletRequest) request).getQueryString() != null
- ? ("?" + ((HttpServletRequest) request).getQueryString()) : "")));
+ ? ("?" + ((HttpServletRequest) request).getQueryString())
+ : "")));
((HttpServletResponse) response).sendRedirect(redirectURL);
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java
new file mode 100644
index 00000000..9a5428f4
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java
@@ -0,0 +1,83 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.onboarding.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class SSOUtil {
+
+ private static final Log logger = LogFactory.getLog(SSOUtil.class);
+
+ /**
+ * Constructs a path for this server, this app's context, etc.
+ *
+ * @param request
+ * HttpServletRequest
+ * @param response
+ * HttpServletResponse
+ * @param forwardPath
+ * Path to forward user
+ * @return Redirect URL
+ */
+ public static String getECOMPSSORedirectURL(HttpServletRequest request, HttpServletResponse response,
+ String forwardPath) {
+ String appURL = (request.isSecure() ? "https://" : "http://") + request.getServerName() + ":"
+ + request.getServerPort() + request.getContextPath() + "/" + forwardPath;
+ String encodedAppURL = null;
+ try {
+ encodedAppURL = URLEncoder.encode(appURL, "UTF-8");
+ } catch (UnsupportedEncodingException ex) {
+ logger.error("getECOMPSSORedirectURL: Failed to encode app URL " + appURL);
+ }
+ String portalURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
+ if (portalURL == null || portalURL.length() == 0) {
+ logger.error("getECOMPSSORedirectURL: Failed to get property " + PortalApiConstants.ECOMP_REDIRECT_URL);
+ return null;
+ }
+ String redirectURL = portalURL + "?redirectUrl=" + encodedAppURL;
+ return redirectURL;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompRole.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java
index 28b74a86..5d757de7 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompRole.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.restful.domain;
+package org.onap.portalsdk.core.restful.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -27,7 +45,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public class EcompRole implements Comparable<EcompRole>{
+public class EcompRole implements Comparable<EcompRole> {
protected Long id;
private String name;
@@ -46,7 +64,7 @@ public class EcompRole implements Comparable<EcompRole>{
public void setName(String name) {
this.name = name;
- }
+ }
@Override
public int hashCode() {
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompUser.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java
index dde16df8..7c9ab8b3 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/EcompUser.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java
@@ -1,23 +1,41 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.restful.domain;
+package org.onap.portalsdk.core.restful.domain;
import java.util.Set;
@@ -29,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public class EcompUser implements Comparable<EcompUser>{
+public class EcompUser implements Comparable<EcompUser> {
private Long orgId;
private String managerId;
@@ -45,8 +63,7 @@ public class EcompUser implements Comparable<EcompUser>{
private String jobTitle;
private String loginId;
private boolean active;
-
-
+
private Set<EcompRole> roles;
public Long getOrgId() {
@@ -160,7 +177,7 @@ public class EcompUser implements Comparable<EcompUser>{
public void setRoles(Set<EcompRole> roles) {
this.roles = roles;
}
-
+
public String getManagerId() {
return managerId;
}
@@ -189,9 +206,8 @@ public class EcompUser implements Comparable<EcompUser>{
}
@Override
- public int compareTo(EcompUser o) {
+ public int compareTo(EcompUser o) {
return this.loginId.compareTo(o.loginId);
}
-
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java
new file mode 100644
index 00000000..ee075cf4
--- /dev/null
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java
@@ -0,0 +1,76 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.core.restful.domain;
+
+public class PortalTimeoutVO implements Comparable<PortalTimeoutVO> {
+
+ private String jSessionId;
+ private Long sessionTimOutMilliSec;
+
+ public PortalTimeoutVO() {
+
+ }
+
+ public PortalTimeoutVO(String _jSessionId, Long _sessionTimOutMilliSec) {
+ setjSessionId(_jSessionId);
+ setSessionTimOutMilliSec(_sessionTimOutMilliSec);
+
+ }
+
+ public String getjSessionId() {
+ return jSessionId;
+ }
+
+ public void setjSessionId(String jSessionId) {
+ this.jSessionId = jSessionId;
+ }
+
+ public Long getSessionTimOutMilliSec() {
+ return sessionTimOutMilliSec;
+ }
+
+ public void setSessionTimOutMilliSec(Long sessionTimOutMilliSec) {
+ this.sessionTimOutMilliSec = sessionTimOutMilliSec;
+ }
+
+ @Override
+ public int compareTo(PortalTimeoutVO o) {
+ return sessionTimOutMilliSec.compareTo(o.sessionTimOutMilliSec);
+ }
+
+} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/SharedContext.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java
index 80ed4859..c8087e7b 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/SharedContext.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java
@@ -1,23 +1,43 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.openecomp.portalsdk.core.restful.domain;
+package org.onap.portalsdk.core.restful.domain;
+
+import java.util.Objects;
/**
* Bean that represents shared-context data transferred in JSON objects. This is
@@ -73,6 +93,7 @@ public class SharedContext {
* Sets the database row ID.
*
* @param id
+ * Row ID
*/
public void setId(final Long id) {
this.id = id;
@@ -91,6 +112,7 @@ public class SharedContext {
* Sets the creation time
*
* @param create_time
+ * Creation time
*/
public void setCreate_time(final Long create_time) {
this.create_time = create_time;
@@ -109,14 +131,15 @@ public class SharedContext {
* Sets the context ID
*
* @param context_id
+ * Context ID
*/
public void setContext_id(final String context_id) {
this.context_id = context_id;
}
/**
- * Gets the key of the key-value pair. Called ckey because "key" is a
- * reserved word in Mysql.
+ * Gets the key of the key-value pair. Called ckey because "key" is a reserved
+ * word in Mysql.
*
* @return The key
*/
@@ -128,6 +151,7 @@ public class SharedContext {
* Sets the key of the key-value pair.
*
* @param ckey
+ * Context key
*/
public void setCkey(final String ckey) {
this.ckey = ckey;
@@ -147,6 +171,7 @@ public class SharedContext {
* Sets the value of the key-value pair.
*
* @param cvalue
+ * Context value
*/
public void setCvalue(final String cvalue) {
this.cvalue = cvalue;
@@ -165,6 +190,7 @@ public class SharedContext {
* Sets the created value.
*
* @param created
+ * Created value
*/
public void setCreated(String created) {
this.created = created;
@@ -183,6 +209,7 @@ public class SharedContext {
* Sets the modified value.
*
* @param modified
+ * Modified value
*/
public void setModified(String modified) {
this.modified = modified;
@@ -201,6 +228,7 @@ public class SharedContext {
* Sets the createdId value.
*
* @param createdId
+ * Created ID
*/
public void setCreatedId(String createdId) {
this.createdId = createdId;
@@ -219,6 +247,7 @@ public class SharedContext {
* Sets the modifiedId value.
*
* @param modifiedId
+ * Modified ID
*/
public void setModifiedId(String modifiedId) {
this.modifiedId = modifiedId;
@@ -237,6 +266,7 @@ public class SharedContext {
* Sets the audit user ID value.
*
* @param auditUserId
+ * Audit user ID
*/
public void setAuditUserId(String auditUserId) {
this.auditUserId = auditUserId;
@@ -255,6 +285,7 @@ public class SharedContext {
* Sets the audit trail value.
*
* @param auditTrail
+ * Audit trail
*/
public void setAuditTrail(String auditTrail) {
this.auditTrail = auditTrail;
@@ -273,6 +304,7 @@ public class SharedContext {
* Sets the row num value.
*
* @param rowNum
+ * row number
*/
public void setRowNum(String rowNum) {
this.rowNum = rowNum;
@@ -280,14 +312,16 @@ public class SharedContext {
@Override
public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof SharedContext))
+ return false;
SharedContext other = (SharedContext) obj;
- return this.id == other.id && this.context_id.equals(other.context_id) && this.ckey.equals(other.ckey)
- && this.cvalue.equals(other.cvalue);
+ return Objects.equals(id, other.id) && Objects.equals(context_id, other.context_id) && Objects.equals(ckey, other.ckey)
+ && Objects.equals(cvalue, other.cvalue);
}
@Override
public int hashCode() {
- return (int) (id + context_id.hashCode() + ckey.hashCode() + cvalue.hashCode());
+ return Objects.hash(id, context_id, ckey, cvalue);
}
@Override
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java
deleted file mode 100644
index b6e0150e..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.onboarding.crossapi;
-
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-
-/**
- *
- * @author Ikram Ikramullah
- *
- * UEB API Interface for all the onboarding third party applications.
- *
- */
-
-public interface IPortalUebAPIService {
- //User Interface
- public String pushUser(String userJson) throws PortalAPIException;
- public String editUser(String loginId, String userJson) throws PortalAPIException;
- public String getUser(String loginId) throws PortalAPIException;
- public String getUsers() throws PortalAPIException;
-
- //Roles Interface
- public String getAvailableRoles() throws PortalAPIException;
- public String getAvailableFullRoles() throws PortalAPIException;
- public String pushUserRole(String loginId, String rolesJson) throws PortalAPIException;
- public String getUserRoles(String loginId) throws PortalAPIException;
-
- //Security Interface
- public boolean isAppAuthenticated(String appUserName, String appPassword) throws PortalAPIException;
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java
deleted file mode 100644
index ad1eae8d..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.onboarding.crossapi;
-
-/**
- * This bean holds a response that is returned by the role and user-management
- * REST API.
- */
-public class PortalAPIResponse {
-
- /**
- * Either "ok" or "error"
- */
- private String status;
- /**
- * Optional if status is ok
- */
- private String message;
-
- public PortalAPIResponse(boolean isOk, String msg) {
- status = (isOk? "ok" : "error");
- message = msg;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/exception/PortalAPIException.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/exception/PortalAPIException.java
deleted file mode 100644
index ea9b1c66..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/exception/PortalAPIException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.onboarding.exception;
-
-public class PortalAPIException extends Exception{
-
- private static final long serialVersionUID = 4854048794984375707L;
-
- public PortalAPIException() {
- super();
- }
-
- public PortalAPIException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
- public PortalAPIException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public PortalAPIException(String message) {
- super(message);
- }
-
- public PortalAPIException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserContextListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserContextListener.java
deleted file mode 100644
index d4793d27..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/listener/UserContextListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.onboarding.listener;
-
-import java.util.HashMap;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.annotation.WebListener;
-import javax.servlet.http.HttpSession;
-
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-
-@WebListener
-public class UserContextListener implements ServletContextListener{
-
- public void contextInitialized(ServletContextEvent event){
- ServletContext context = event.getServletContext();
- //
- // instanciate a map to store references to all the active
- // sessions and bind it to context scope.
- //
- HashMap<String, HttpSession> activeUsers = new HashMap<String, HttpSession>();
- context.setAttribute(PortalApiConstants.ACTIVE_USERS_NAME, activeUsers);
- }
-
- /**
- * Needed for the ServletContextListener interface.
- */
- public void contextDestroyed(ServletContextEvent event){
- // To overcome the problem with losing the session references
- // during server restarts, put code here to serialize the
- // activeUsers HashMap. Then put code in the contextInitialized
- // method that reads and reloads it if it exists...
- }
-} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java
deleted file mode 100644
index e376cd4c..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.onboarding.util;
-
-import javax.crypto.Cipher;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.commons.codec.binary.Base64;
-
-public class CipherUtil {
-
- private final static String key = "AGLDdG4D04BKm2IxIWEr8o==!";
-
- /**
- * @param plainText
- * @param secretKey
- * @return encrypted version of plain text.
- * @throws Exception
- */
- public static String encrypt(String plainText, String secretKey) throws Exception{
- byte[] rawKey;
- String encryptedString;
- SecretKeySpec sKeySpec;
- byte[] encryptText = plainText.getBytes("UTF-8");
- Cipher cipher;
- rawKey = Base64.decodeBase64(secretKey);
- sKeySpec = new SecretKeySpec(rawKey, "AES");
- cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.ENCRYPT_MODE, sKeySpec);
- encryptedString = Base64.encodeBase64String(cipher.doFinal(encryptText));
-
- return encryptedString;
- }
-
- /**
- *
- * @param plainText
- * @return Encrypted Text
- * @throws Exception
- */
- public static String encrypt(String plainText) throws Exception
- {
- return CipherUtil.encrypt(plainText,key);
- }
-
- /**
- * @param encryptedText
- * @param secretKey
- * @return plain text version of encrypted text
- * @throws Exception
- */
- public static String decrypt(String encryptedText, String secretKey) throws Exception {
- Cipher cipher;
- String encryptedString;
- byte[] encryptText = null;
- byte[] rawKey;
- SecretKeySpec sKeySpec;
-
- rawKey = Base64.decodeBase64(secretKey);
- sKeySpec = new SecretKeySpec(rawKey, "AES");
- encryptText = Base64.decodeBase64(encryptedText.getBytes("UTF-8"));
- cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.DECRYPT_MODE, sKeySpec);
- encryptedString = new String(cipher.doFinal(encryptText));
-
- return encryptedString;
- }
-
- /**
- * @param encryptedText
- * @return Decrypted Text
- * @throws Exception
- */
- public static String decrypt(String encryptedText) throws Exception
- {
- return CipherUtil.decrypt(encryptedText,key);
- }
-
-
- public static void main(String[] args) throws Exception {
-
- String password = "Welcome123";
- String encrypted;
- String decrypted;
-
- if (args.length != 2) {
- System.out.println("Default password testing... ");
- System.out.println("Plain password: " + password);
- encrypted = encrypt(password);
- System.out.println("Encrypted password: " + encrypted);
- decrypted = decrypt(encrypted);
- System.out.println("Decrypted password: " + decrypted);
- } else {
- String whatToDo = args[0];
- if (whatToDo.equalsIgnoreCase("d")) {
- encrypted = args[1];
- System.out.println("Encrypted Text: " + encrypted);
- decrypted = decrypt(encrypted);
- System.out.println("Decrypted Text: " + decrypted);
- } else {
- decrypted = args[1];
- System.out.println("Plain Text: " + decrypted);
- encrypted = encrypt(decrypted);
- System.out.println("Encrypted Text" + encrypted);
- }
- }
- }
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java
deleted file mode 100644
index 87134d3c..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.openecomp.portalsdk.core.onboarding.util;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class SSOUtil {
-
- private static final Log logger = LogFactory.getLog(SSOUtil.class);
-
- /**
- * Constructs a path for this server, this app's context, etc.
- *
- * @param request
- * HttpServletRequest
- * @param response
- * HttpServletResponse
- * @param forwardPath
- * Path to forward user
- * @return Redirect URL
- */
- public static String getECOMPSSORedirectURL(HttpServletRequest request, HttpServletResponse response,
- String forwardPath) {
- String appURL = (request.isSecure() ? "https://" : "http://") + request.getServerName() + ":"
- + request.getServerPort() + request.getContextPath() + "/" + forwardPath;
- String encodedAppURL = null;
- try {
- encodedAppURL = URLEncoder.encode(appURL, "UTF-8");
- } catch (UnsupportedEncodingException ex) {
- logger.error("getECOMPSSORedirectURL: Failed to encode app URL " + appURL);
- }
- String portalURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
- if (portalURL == null || portalURL.length() == 0) {
- logger.error("getECOMPSSORedirectURL: Failed to get property " + PortalApiConstants.ECOMP_REDIRECT_URL);
- return null;
- }
- String redirectURL = portalURL + "?redirectUrl=" + encodedAppURL;
- return redirectURL;
- }
-
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/PortalTimeoutVO.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/PortalTimeoutVO.java
deleted file mode 100644
index a8e100e5..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/restful/domain/PortalTimeoutVO.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.core.restful.domain;
-
-public class PortalTimeoutVO implements Comparable<PortalTimeoutVO>{
-
- private String jSessionId;
- private Long sessionTimOutMilliSec;
-
- public PortalTimeoutVO(){
-
- }
-
- public PortalTimeoutVO(String _jSessionId, Long _sessionTimOutMilliSec) {
- setjSessionId(_jSessionId);
- setSessionTimOutMilliSec(_sessionTimOutMilliSec);
-
- }
-
- public String getjSessionId() {
- return jSessionId;
- }
-
- public void setjSessionId(String jSessionId) {
- this.jSessionId = jSessionId;
- }
-
- public Long getSessionTimOutMilliSec() {
- return sessionTimOutMilliSec;
- }
-
- public void setSessionTimOutMilliSec(Long sessionTimOutMilliSec) {
- this.sessionTimOutMilliSec = sessionTimOutMilliSec;
- }
-
- @Override
- public int compareTo(PortalTimeoutVO o) {
- return sessionTimOutMilliSec.compareTo(o.sessionTimOutMilliSec);
- }
-
-
-
-
-
-
-} \ No newline at end of file