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; 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,20 +159,17 @@
<SSOConfiguration> <SSOConfiguration>
<Issuer>app-mgt</Issuer> <Issuer>app-mgt</Issuer>
</SSOConfiguration> </SSOConfiguration>
<LoginResponse> <ErrorCallback>
<SuccessCallback>/apps</SuccessCallback> <BadRequest>/pages/error/client-errors/400</BadRequest>
<FailureCallback> <Unauthorized>/pages/error/client-errors/401</Unauthorized>
<BadRequest>/pages/error/client-errors/400</BadRequest> <Forbidden>/pages/error/client-errors/403</Forbidden>
<Unauthorized>/pages/error/client-errors/401</Unauthorized> <NotFound>/pages/error/client-errors/404</NotFound>
<Forbidden>/pages/error/client-errors/403</Forbidden> <MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotFound>/pages/error/client-errors/404</NotFound> <NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed> <UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable> <InternalServerError>/pages/error/server-errors/500</InternalServerError>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType> <DefaultPage>/pages/error/default</DefaultPage>
<InternalServerError>/pages/error/server-errors/500</InternalServerError> </ErrorCallback>
<DefaultPage>/pages/error/default</DefaultPage>
</FailureCallback>
</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