|
|
|
@ -244,6 +244,9 @@ public class SsoLoginHandler extends HttpServlet {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HandlerUtil.handleError(resp, null);
|
|
|
|
|
|
|
|
|
|
// Enables BackChannelLogout
|
|
|
|
|
enableBackChannelLogout();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("Error occurred while sending the response into the socket. ", e);
|
|
|
|
|
} catch (JsonSyntaxException e) {
|
|
|
|
@ -311,10 +314,14 @@ public class SsoLoginHandler extends HttpServlet {
|
|
|
|
|
String logoutRedirect = "";
|
|
|
|
|
if (applicationName.equals("entgra")) {
|
|
|
|
|
logoutRedirect = iotsCoreUrl + "/endpoint-mgt";
|
|
|
|
|
} else {
|
|
|
|
|
} else if (applicationName.equals("publisher")) {
|
|
|
|
|
logoutRedirect = iotsCoreUrl + "/app-publisher";
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
logoutRedirect = (iotsCoreUrl + "/" + applicationName);
|
|
|
|
|
}
|
|
|
|
|
jsonObject.put(HandlerConstants.CALLBACK_URL_KEY, "regexp=(" + iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK + "|" + logoutRedirect + ")");
|
|
|
|
|
jsonObject.put(HandlerConstants.CALLBACK_URL_KEY, "regexp=(" + iotsCoreUrl + baseContextPath
|
|
|
|
|
+ HandlerConstants.SSO_LOGIN_CALLBACK + "|" + logoutRedirect + ")");
|
|
|
|
|
String payload = jsonObject.toString();
|
|
|
|
|
return new StringEntity(payload, ContentType.APPLICATION_JSON);
|
|
|
|
|
}
|
|
|
|
@ -470,4 +477,24 @@ public class SsoLoginHandler extends HttpServlet {
|
|
|
|
|
|
|
|
|
|
HandlerUtil.execute(updateApplicationEndpoint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* Enables Backchannel Logout
|
|
|
|
|
* This Invokes the Identity server and updates its specific application with logoutCallBackHandler URL
|
|
|
|
|
*/
|
|
|
|
|
private void enableBackChannelLogout() throws IOException {
|
|
|
|
|
String apiUpdateOAuth = iotsCoreUrl + HandlerConstants.IDENTITY_DCR_ENDPOINT + oAuthApp.getClientId();
|
|
|
|
|
HttpPut setBackChannelLogout = new HttpPut(apiUpdateOAuth);
|
|
|
|
|
setBackChannelLogout.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC +
|
|
|
|
|
encodedAdminCredentials);
|
|
|
|
|
setBackChannelLogout.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
|
|
|
|
|
JsonObject jsonObject = new JsonObject();
|
|
|
|
|
jsonObject.addProperty(HandlerConstants.BACKCHANNEL_LOGOUT_URI, iotsCoreUrl + baseContextPath
|
|
|
|
|
+ HandlerConstants.SSO_LOGOUT_CALLBACK);
|
|
|
|
|
jsonObject.addProperty(HandlerConstants.BACKCHANNEL_LOGOUT_SESSION_REQUIRED, true);
|
|
|
|
|
String payload = jsonObject.toString();
|
|
|
|
|
setBackChannelLogout.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
|
|
HandlerUtil.execute(setBackChannelLogout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|