Fixed issues in DeviceAuthorization

4.x.x
harshanl 9 years ago
parent b9ca6705ae
commit cb02c9da80

@ -20,7 +20,7 @@ package org.wso2.carbon.device.mgt.core.authorization;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
@ -31,7 +31,6 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.HashMap;
import java.util.List;
@ -223,9 +222,9 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
}
private String getUserName() {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (username != null && username.isEmpty()) {
String tenantDomain = MultitenantUtils.getTenantDomain(username);
String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
if (username != null && !username.isEmpty()) {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
@ -235,7 +234,7 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
}
private int getTenantId() {
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
return CarbonContext.getThreadLocalCarbonContext().getTenantId();
}
private boolean addAdminPermissionToRegistry() throws PermissionManagementException {

@ -28,9 +28,7 @@ import org.wso2.carbon.tomcat.ext.valves.CompositeValve;
import org.wso2.carbon.webapp.authenticator.framework.authenticator.WebappAuthenticator;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
public class WebappAuthenticationValve extends CarbonTomcatValve {

Loading…
Cancel
Save