Improve UI intercepter response

feature/appm-store/pbac
lasanthaDLPDS 5 years ago
parent aa247bc1f2
commit 340d28c03b

@ -2,7 +2,7 @@ package org.wso2.carbon.device.application.mgt.common.config;
import javax.xml.bind.annotation.XmlElement;
public class FailureCallback {
public class ErrorCallback {
private String badRequest;
private String unauthorized;

@ -1,27 +0,0 @@
package org.wso2.carbon.device.application.mgt.common.config;
import javax.xml.bind.annotation.XmlElement;
public class LoginResponse {
private String successCallback;
private FailureCallback failureCallback;
@XmlElement(name = "SuccessCallback", required=true)
public String getSuccessCallback() {
return successCallback;
}
public void setSuccessCallback(String successCallback) {
this.successCallback = successCallback;
}
@XmlElement(name = "FailureCallback", required=true)
public FailureCallback getFailureCallback() {
return failureCallback;
}
public void setFailureCallback(FailureCallback failureCallback) {
this.failureCallback = failureCallback;
}
}

@ -9,7 +9,7 @@ public class UIConfiguration {
private AppRegistration appRegistration;
private List<String> scopes;
private boolean isSsoEnable;
private LoginResponse loginResponse;
private ErrorCallback errorCallback;
@XmlElement(name = "AppRegistration", required=true)
public AppRegistration getAppRegistration() {
@ -39,12 +39,8 @@ public class UIConfiguration {
isSsoEnable = ssoEnable;
}
public LoginResponse getLoginResponse() {
return loginResponse;
}
@XmlElement(name = "ErrorCallback", required=true)
public ErrorCallback getErrorCallback() { return errorCallback; }
@XmlElement(name = "LoginResponse", required=true)
public void setLoginResponse(LoginResponse loginResponse) {
this.loginResponse = loginResponse;
}
public void setErrorCallback(ErrorCallback errorCallback) { this.errorCallback = errorCallback; }
}

@ -131,8 +131,7 @@ public class LoginHandler extends HttpServlet {
clientAppResponse.getData(), scopes)) {
ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setCode(HttpStatus.SC_OK);
proxyResponse.setUrl(serverUrl + "/" + platform + uiConfigJsonObject.get(HandlerConstants.LOGIN_RESPONSE_KEY)
.getAsJsonObject().get("successCallback").getAsString());
proxyResponse.setUrl(serverUrl + "/" + platform);
HandlerUtil.handleSuccess(req, resp, serverUrl, platform, proxyResponse);
return;
}

@ -32,8 +32,7 @@ public class HandlerConstants {
public static final String UI_CONFIG_KEY = "ui-config";
public static final String PLATFORM = "platform";
public static final String DEFAULT_ERROR_CALLBACK = "/pages/error/default";
public static final String LOGIN_RESPONSE_KEY = "loginResponse";
public static final String FAILURE_CALLBACK_KEY = "failureCallback";
public static final String ERROR_CALLBACK_KEY = "errorCallback";
public static final String API_COMMON_CONTEXT = "/api";
public static final String EXECUTOR_EXCEPTION_PREFIX = "ExecutorException-";
public static final String TOKEN_IS_EXPIRED = "ACCESS_TOKEN_IS_EXPIRED";

@ -20,6 +20,7 @@ package io.entgra.ui.request.interceptor.util;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -171,8 +172,7 @@ public class HandlerUtil {
if (uiConfig == null){
proxyResponse.setUrl(serverUrl + "/" + platform + HandlerConstants.DEFAULT_ERROR_CALLBACK);
} else{
proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.LOGIN_RESPONSE_KEY).getAsJsonObject()
.get(HandlerConstants.FAILURE_CALLBACK_KEY).getAsJsonObject()
proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.ERROR_CALLBACK_KEY).getAsJsonObject()
.get(proxyResponse.getExecutorResponse().split(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)[1])
.getAsString());
}

@ -135,7 +135,6 @@
<UIConfigs>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>false</EnableSSO>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>
@ -160,20 +159,17 @@
<SSOConfiguration>
<Issuer>app-mgt</Issuer>
</SSOConfiguration>
<LoginResponse>
<SuccessCallback>/apps</SuccessCallback>
<FailureCallback>
<BadRequest>/pages/error/client-errors/400</BadRequest>
<Unauthorized>/pages/error/client-errors/401</Unauthorized>
<Forbidden>/pages/error/client-errors/403</Forbidden>
<NotFound>/pages/error/client-errors/404</NotFound>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<InternalServerError>/pages/error/server-errors/500</InternalServerError>
<DefaultPage>/pages/error/default</DefaultPage>
</FailureCallback>
</LoginResponse>
<ErrorCallback>
<BadRequest>/pages/error/client-errors/400</BadRequest>
<Unauthorized>/pages/error/client-errors/401</Unauthorized>
<Forbidden>/pages/error/client-errors/403</Forbidden>
<NotFound>/pages/error/client-errors/404</NotFound>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<InternalServerError>/pages/error/server-errors/500</InternalServerError>
<DefaultPage>/pages/error/default</DefaultPage>
</ErrorCallback>
</UIConfigs>
<ArtifactDownloadEndpoint>https://localhost:9443/api/application-mgt/v1.0/artifact</ArtifactDownloadEndpoint>

Loading…
Cancel
Save