diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
index 5ee7393cd10..d5af4494774 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml
@@ -66,7 +66,6 @@
generate-resources
${node.version}
- ${npm.version}
@@ -101,46 +100,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
index 785056802bd..5d7f53e1620 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml
@@ -69,7 +69,6 @@
generate-resources
${node.version}
- ${npm.version}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 02ded254dfe..60799bf5a27 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -2273,4 +2273,58 @@ public interface DeviceManagementService {
response = ErrorResponse.class)
})
Response getDeviceFilters();
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{clientId}/{clientSecret}/default-token")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting the default token",
+ notes = "Getting the default access token by using given client ID and the client secret value.",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:device:enroll")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully returned the default token details.",
+ response = Policy.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the default token.",
+ response = ErrorResponse.class)
+ }
+ )
+ Response getDefaultToken(
+ @ApiParam(
+ name = "client ID",
+ value = "Client Id.",
+ required = true)
+ @PathParam("clientId")
+ String clientId,
+ @ApiParam(
+ name = "client secret",
+ value = "Client Secret",
+ required = true)
+ @PathParam("clientSecret")
+ String clientSecret
+ );
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index 3600ffb3ab1..a4ca3f026d9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -38,11 +38,13 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import java.util.LinkedList;
import java.util.Queue;
+
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceFilters;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@@ -102,6 +104,10 @@ import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
+import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
+import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
+import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.user.api.UserStoreException;
@@ -1328,4 +1334,21 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
+
+ @GET
+ @Path("/{clientId}/{clientSecret}/default-token")
+ @Override
+ public Response getDefaultToken(@PathParam("clientId") String clientId, @PathParam("clientSecret") String clientSecret) {
+ JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService();
+ try {
+ JWTClient jwtClient = jwtClientManagerService.getJWTClient();
+ AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(clientId, clientSecret,
+ PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(), "default");
+ return Response.status(Response.Status.OK).entity(accessTokenInfo).build();
+ } catch (JWTClientException e) {
+ String msg = "Error occurred while getting default access token by using given client Id and client secret.";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index 7f7610126b4..1b402560b78 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -169,4 +169,13 @@ public final class DeviceManagementConstants {
public static final String DEVICE_INFO_PARAM = "device-info";
public static final String APP_USAGE_ENDPOINT = REPORTING_CONTEXT + "/app-usage";
}
+
+ public static final class Payload {
+ private Payload() {
+ throw new AssertionError();
+ }
+ public static final String DEVICE_INFO_DEVICE_NAME = "DEVICE_NAME";
+ public static final String DEVICE_INFO_IMEI = "IMEI";
+ public static final String DEVICE_INFO_IMSI = "IMSI";;
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
index 2e791f733d0..b152e65a84b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
@@ -134,6 +134,20 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceDetailsDAO.addDeviceProperties(injectableProps, device.getId(),
device.getEnrolmentInfo().getId());
}
+
+ if (deviceInfo.getDeviceDetailsMap().containsKey(DeviceManagementConstants
+ .Payload.DEVICE_INFO_DEVICE_NAME) &&
+ StringUtils.isNotEmpty(deviceInfo.getDeviceDetailsMap()
+ .get(DeviceManagementConstants.Payload.DEVICE_INFO_DEVICE_NAME))
+ && !device.getName().equals(deviceInfo.getDeviceDetailsMap()
+ .get(DeviceManagementConstants.Payload.DEVICE_INFO_DEVICE_NAME))) {
+ String name = deviceInfo.getDeviceDetailsMap()
+ .get(DeviceManagementConstants.Payload.DEVICE_INFO_DEVICE_NAME);
+ log.info("Device identifier " + device.getDeviceIdentifier() + ", Device name " +
+ "changed by user from " + device.getName() + " to " + name);
+ device.setName(name);
+ }
+
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
DeviceManagementDAOFactory.commitTransaction();
@@ -142,8 +156,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
Object[] metaData = {device.getDeviceIdentifier(), device.getType()};
Object[] payload = new Object[]{
Calendar.getInstance().getTimeInMillis(),
- deviceInfo.getDeviceDetailsMap().get("IMEI"),
- deviceInfo.getDeviceDetailsMap().get("IMSI"),
+ deviceInfo.getDeviceDetailsMap().get(DeviceManagementConstants.Payload
+ .DEVICE_INFO_IMEI),
+ deviceInfo.getDeviceDetailsMap().get(DeviceManagementConstants.Payload
+ .DEVICE_INFO_IMSI),
deviceInfo.getDeviceModel(),
deviceInfo.getVendor(),
deviceInfo.getOsVersion(),
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java
new file mode 100644
index 00000000000..1cff1d9d114
--- /dev/null
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java
@@ -0,0 +1,134 @@
+/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. licenses this file to you 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 io.entgra.ui.request.interceptor;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import io.entgra.ui.request.interceptor.beans.AuthData;
+import io.entgra.ui.request.interceptor.util.HandlerConstants;
+import io.entgra.ui.request.interceptor.util.HandlerUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.entity.ContentType;
+import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
+
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+@MultipartConfig
+@WebServlet("/default-credentials")
+public class DefaultTokenHandler extends HttpServlet {
+ private static final Log log = LogFactory.getLog(DefaultTokenHandler.class);
+
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ HttpSession httpSession = req.getSession(false);
+
+ if (httpSession != null) {
+ AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY);
+ if (authData == null) {
+ HandlerUtil.sendUnAuthorizeResponse(resp);
+ return;
+ }
+
+ AuthData defaultAuthData = (AuthData) httpSession
+ .getAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY);
+ if (defaultAuthData != null) {
+ HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultAuthData.getAccessToken()));
+ return;
+ }
+
+ String clientId = authData.getClientId();
+ String clientSecret = authData.getClientSecret();
+
+ String iotsCorePort = System.getProperty("iot.core.https.port");
+ if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
+ iotsCorePort = System.getProperty("iot.core.http.port");
+ }
+
+ String tokenUrl =
+ req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ + HandlerConstants.COLON + iotsCorePort + "/api/device-mgt/v1.0/devices/" + clientId
+ + "/" + clientSecret + "/default-token";
+
+ HttpGet defaultTokenRequest = new HttpGet(tokenUrl);
+ defaultTokenRequest
+ .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
+ defaultTokenRequest
+ .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());
+ ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest);
+
+ if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) {
+ log.error("Error occurred while invoking the API to get default token data.");
+ HandlerUtil.handleError(resp, tokenResultResponse);
+ return;
+ }
+ String tokenResult = tokenResultResponse.getData();
+ if (tokenResult == null) {
+ log.error("Invalid default token response is received.");
+ HandlerUtil.handleError(resp, tokenResultResponse);
+ return;
+ }
+
+ JsonParser jsonParser = new JsonParser();
+ JsonElement jTokenResult = jsonParser.parse(tokenResult);
+ if (jTokenResult.isJsonObject()) {
+ JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject();
+ AuthData newDefaultAuthData = new AuthData();
+ newDefaultAuthData.setClientId(clientId);
+ newDefaultAuthData.setClientSecret(clientSecret);
+
+ String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString();
+ newDefaultAuthData.setAccessToken(defaultToken);
+ newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString());
+ newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString());
+ httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData);
+
+ HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken));
+ }
+ } else {
+ HandlerUtil.sendUnAuthorizeResponse(resp);
+ }
+ } catch (IOException e) {
+ log.error("Error occurred when processing GET request to get default token.", e);
+ }
+ }
+
+ /**
+ * Get Success Proxy Response
+ * @param responseString Response String
+ * @return {@link ProxyResponse}
+ */
+ private ProxyResponse constructSuccessProxyResponse (String responseString) {
+ ProxyResponse proxyResponse = new ProxyResponse();
+ proxyResponse.setCode(HttpStatus.SC_OK);
+ proxyResponse.setData(responseString);
+ return proxyResponse;
+ }
+}
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java
index b9f5403accc..53faa63eda2 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java
@@ -72,7 +72,6 @@ public class LoginHandler extends HttpServlet {
httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT));
HttpGet uiConfigEndpoint = new HttpGet(uiConfigUrl);
- JsonParser jsonParser = new JsonParser();
ProxyResponse uiConfigResponse = HandlerUtil.execute(uiConfigEndpoint);
String executorResponse = uiConfigResponse.getExecutorResponse();
if (!StringUtils.isEmpty(executorResponse) && executorResponse
@@ -88,6 +87,7 @@ public class LoginHandler extends HttpServlet {
HandlerUtil.handleError(resp, null);
return;
}
+ JsonParser jsonParser = new JsonParser();
JsonElement uiConfigJsonElement = jsonParser.parse(uiConfigResponse.getData());
JsonObject uiConfigJsonObject = null;
if (uiConfigJsonElement.isJsonObject()) {
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LogoutHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LogoutHandler.java
index 771341cb41d..8ebacf1cb7b 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LogoutHandler.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LogoutHandler.java
@@ -18,7 +18,6 @@
package io.entgra.ui.request.interceptor;
-import io.entgra.ui.request.interceptor.util.HandlerConstants;
import io.entgra.ui.request.interceptor.util.HandlerUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java
index 0464488e56e..d35e4958352 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java
@@ -56,13 +56,13 @@ public class UserHandler extends HttpServlet {
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
HttpSession httpSession = req.getSession(false);
if (httpSession == null) {
- sendUnAuthorizeResponse(resp);
+ HandlerUtil.sendUnAuthorizeResponse(resp);
return;
}
AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY);
if (authData == null) {
- sendUnAuthorizeResponse(resp);
+ HandlerUtil.sendUnAuthorizeResponse(resp);
return;
}
@@ -91,7 +91,7 @@ public class UserHandler extends HttpServlet {
if (jTokenResult.isJsonObject()) {
JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject();
if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) {
- sendUnAuthorizeResponse(resp);
+ HandlerUtil.sendUnAuthorizeResponse(resp);
return;
}
ProxyResponse proxyResponse = new ProxyResponse();
@@ -106,18 +106,4 @@ public class UserHandler extends HttpServlet {
log.error("Error occurred while parsing the response. ", e);
}
}
-
- /**
- * Send UnAuthorized Response to the user
- *
- * @param resp HttpServletResponse object
- */
- private void sendUnAuthorizeResponse(HttpServletResponse resp)
- throws IOException {
- ProxyResponse proxyResponse = new ProxyResponse();
- proxyResponse.setCode(HttpStatus.SC_UNAUTHORIZED);
- proxyResponse.setExecutorResponse(
- HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + HandlerUtil.getStatusKey(HttpStatus.SC_UNAUTHORIZED));
- HandlerUtil.handleError(resp, proxyResponse);
- }
}
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
index 261a28bb4bd..a335f224c72 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
@@ -30,6 +30,7 @@ public class HandlerConstants {
public static final String TAGS_KEY = "tags";
public static final String APP_NAME_KEY = "applicationName";
public static final String SESSION_AUTH_DATA_KEY = "authInfo";
+ public static final String SESSION_DEFAULT_AUTH_DATA_KEY = "defaultAuthInfo";
public static final String UI_CONFIG_KEY = "ui-config";
public static final String PLATFORM = "platform";
public static final String USERNAME = "username";
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
index f35c0700eef..82685daa435 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
@@ -19,7 +19,6 @@
package io.entgra.ui.request.interceptor.util;
import com.google.gson.Gson;
-import com.google.gson.JsonObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,9 +34,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -232,4 +229,17 @@ public class HandlerUtil {
}
}
+ /**
+ * Send UnAuthorized Response to the user
+ *
+ * @param resp HttpServletResponse object
+ */
+ public static void sendUnAuthorizeResponse(HttpServletResponse resp)
+ throws IOException {
+ ProxyResponse proxyResponse = new ProxyResponse();
+ proxyResponse.setCode(HttpStatus.SC_UNAUTHORIZED);
+ proxyResponse.setExecutorResponse(
+ HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + HandlerUtil.getStatusKey(HttpStatus.SC_UNAUTHORIZED));
+ handleError(resp, proxyResponse);
+ }
}
diff --git a/pom.xml b/pom.xml
index eb0b4f8e534..d522b61dab6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2249,8 +2249,7 @@
1.21
2.6.5
1.7.6
- v10.15.3
- 6.9.0
+ v12.18.1
3.1.0