Improve UI intercepter response

feature/appm-store/pbac
lasanthaDLPDS 6 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; import javax.xml.bind.annotation.XmlElement;
public class FailureCallback { public class ErrorCallback {
private String badRequest; private String badRequest;
private String unauthorized; 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 AppRegistration appRegistration;
private List<String> scopes; private List<String> scopes;
private boolean isSsoEnable; private boolean isSsoEnable;
private LoginResponse loginResponse; private ErrorCallback errorCallback;
@XmlElement(name = "AppRegistration", required=true) @XmlElement(name = "AppRegistration", required=true)
public AppRegistration getAppRegistration() { public AppRegistration getAppRegistration() {
@ -39,12 +39,8 @@ public class UIConfiguration {
isSsoEnable = ssoEnable; isSsoEnable = ssoEnable;
} }
public LoginResponse getLoginResponse() { @XmlElement(name = "ErrorCallback", required=true)
return loginResponse; public ErrorCallback getErrorCallback() { return errorCallback; }
}
@XmlElement(name = "LoginResponse", required=true) public void setErrorCallback(ErrorCallback errorCallback) { this.errorCallback = errorCallback; }
public void setLoginResponse(LoginResponse loginResponse) {
this.loginResponse = loginResponse;
}
} }

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

@ -32,8 +32,7 @@ public class HandlerConstants {
public static final String UI_CONFIG_KEY = "ui-config"; public static final String UI_CONFIG_KEY = "ui-config";
public static final String PLATFORM = "platform"; public static final String PLATFORM = "platform";
public static final String DEFAULT_ERROR_CALLBACK = "/pages/error/default"; public static final String DEFAULT_ERROR_CALLBACK = "/pages/error/default";
public static final String LOGIN_RESPONSE_KEY = "loginResponse"; public static final String ERROR_CALLBACK_KEY = "errorCallback";
public static final String FAILURE_CALLBACK_KEY = "failureCallback";
public static final String API_COMMON_CONTEXT = "/api"; public static final String API_COMMON_CONTEXT = "/api";
public static final String EXECUTOR_EXCEPTION_PREFIX = "ExecutorException-"; public static final String EXECUTOR_EXCEPTION_PREFIX = "ExecutorException-";
public static final String TOKEN_IS_EXPIRED = "ACCESS_TOKEN_IS_EXPIRED"; 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.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -171,8 +172,7 @@ public class HandlerUtil {
if (uiConfig == null){ if (uiConfig == null){
proxyResponse.setUrl(serverUrl + "/" + platform + HandlerConstants.DEFAULT_ERROR_CALLBACK); proxyResponse.setUrl(serverUrl + "/" + platform + HandlerConstants.DEFAULT_ERROR_CALLBACK);
} else{ } else{
proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.LOGIN_RESPONSE_KEY).getAsJsonObject() proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.ERROR_CALLBACK_KEY).getAsJsonObject()
.get(HandlerConstants.FAILURE_CALLBACK_KEY).getAsJsonObject()
.get(proxyResponse.getExecutorResponse().split(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)[1]) .get(proxyResponse.getExecutorResponse().split(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)[1])
.getAsString()); .getAsString());
} }

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

Loading…
Cancel
Save