Compare commits

Invalid templates have been ignored

1 invalid template(s) found pull_request_template.md: frontmatter must start with a separator line

...

3 Commits

Author SHA1 Message Date
Deenath Geeganage 0c26899a62 fixed comment issues in traccar device update functionality
2 years ago
Deenath Geeganage 9fb3b2533b minor code consistency fixes
2 years ago
Deenath Geeganage 995c59da24 Add BackChannel during DCR
2 years ago

@ -491,9 +491,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return false;
}
boolean status = deviceManager.modifyEnrollment(device);
int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
try {
int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
DeviceManagementDAOFactory.beginTransaction();
device.setId(currentDevice.getId());
if (device.getEnrolmentInfo().getId() == 0) {
@ -530,7 +530,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
//enroll Traccar device
if (HttpReportingUtil.isTrackerEnabled()) {
try {
int tenantId = this.getTenantId();
DeviceManagementDataHolder.getInstance().getDeviceAPIClientService().modifyDevice(device, tenantId);
} catch (ExecutionException e) {
log.error("ExecutionException : " + e);

@ -54,6 +54,7 @@ public interface DeviceAPIClientService {
* Updates device Traccar configuration records (like device name)
*
* @params device to be modifies
* @param tenantId of the user
* @throws TrackerManagementDAOException errors thrown while modifing a traccar device
*/
void modifyDevice(Device device, int tenantId) throws ExecutionException, InterruptedException;

@ -474,6 +474,7 @@ public class TraccarClientFactory {
*
* @param traccarDevice with DeviceName UniqueId, Status, Disabled LastUpdate, PositionId, GroupId
* Model, Contact, Category, fenceIds
* @param tenantId tentantId of the user
* @throws TrackerManagementDAOException Failed while add Traccar Device the operation
*/
public void modifyDevice(TraccarDevice traccarDevice, int tenantId) throws TrackerManagementDAOException, ExecutionException, InterruptedException {
@ -511,8 +512,7 @@ public class TraccarClientFactory {
try {
addDevice(traccarDevice, tenantId);
} catch (TrackerAlreadyExistException e) {
String msg = "The device already exist";
log.error(msg, e);
log.error("The device already exist", e);
}
}
}

@ -68,8 +68,7 @@ public class DeviceAPIClientServiceImpl implements DeviceAPIClientService {
try {
client.modifyDevice(traccarDevice, tenantId);
} catch (TrackerManagementDAOException e) {
String msg = "Error occurred while mapping with deviceId";
log.error(msg, e);
log.error("Error occurred while mapping with deviceId", e);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
* Copyright (c) 2023, 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

@ -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);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
* Copyright (c) 2023, 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

@ -51,7 +51,10 @@ public class SsoLogoutHandler 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);
}
@ -68,6 +71,9 @@ public class SsoLogoutHandler extends HttpServlet {
resp.sendRedirect(redirect);
} catch (IOException e) {
log.error("Error occured while redirecting");
} catch (NullPointerException e) {
log.error("Invalid Session");
resp.setStatus(401);
}
}
}

@ -30,6 +30,10 @@ public class HandlerConstants {
public static final String IDENTITY_APP_MGT_ENDPOINT = "/services/IdentityApplicationManagementService.IdentityApplicationManagementServiceHttpsSoap11Endpoint";
public static final String LOGIN_PAGE = "/login";
public static final String SSO_LOGIN_CALLBACK = "/ssoLoginCallback";
public static final String SSO_LOGOUT_CALLBACK = "/ssoLogoutCallback";
public static final String IDENTITY_DCR_ENDPOINT = "/api/identity/oauth2/dcr/v1.1/register/";
public static final String BACKCHANNEL_LOGOUT_URI = "backchannel_logout_uri";
public static final String BACKCHANNEL_LOGOUT_SESSION_REQUIRED= "backchannel_logout_session_required";
public static final String BASIC = "Basic ";
public static final String BEARER = "Bearer ";
public static final String X_FRAME_OPTIONS = "X-Frame-Options";

Loading…
Cancel
Save