|
|
@ -19,12 +19,12 @@ package org.wso2.carbon.certificate.mgt.core.scep;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
import org.wso2.carbon.certificate.mgt.core.internal.CertificateManagementDataHolder;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.core.service.RealmService;
|
|
|
|
import org.wso2.carbon.user.core.service.RealmService;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
|
@ -33,19 +33,18 @@ import java.sql.SQLException;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
|
|
public class SCEPManagerImpl implements SCEPManager {
|
|
|
|
public class SCEPManagerImpl implements SCEPManager {
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(SCEPManagerImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(SCEPManagerImpl.class);
|
|
|
|
|
|
|
|
DeviceManagementProviderService dms;
|
|
|
|
|
|
|
|
|
|
|
|
public SCEPManagerImpl() {
|
|
|
|
public SCEPManagerImpl() {
|
|
|
|
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.dms = CertificateManagementDataHolder.getInstance().getDeviceManagementService();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public TenantedDeviceWrapper getValidatedDevice(DeviceIdentifier deviceIdentifier) throws SCEPException {
|
|
|
|
public TenantedDeviceWrapper getValidatedDevice(DeviceIdentifier deviceIdentifier) throws SCEPException {
|
|
|
|
TenantedDeviceWrapper tenantedDeviceWrapper = new TenantedDeviceWrapper();
|
|
|
|
TenantedDeviceWrapper tenantedDeviceWrapper = new TenantedDeviceWrapper();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
HashMap<Integer, Device> deviceHashMap = dms.getTenantedDevice(deviceIdentifier);
|
|
|
|
HashMap<Integer, Device> deviceHashMap = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
Object[] keySet = deviceHashMap.keySet().toArray();
|
|
|
|
Object[] keySet = deviceHashMap.keySet().toArray();
|
|
|
|
|
|
|
|
|
|
|
|
if (keySet == null || keySet.length == 0) {
|
|
|
|
if (keySet == null || keySet.length == 0) {
|
|
|
@ -71,15 +70,12 @@ public class SCEPManagerImpl implements SCEPManager {
|
|
|
|
|
|
|
|
|
|
|
|
String tenantDomain = realmService.getTenantManager().getDomain(tenantId);
|
|
|
|
String tenantDomain = realmService.getTenantManager().getDomain(tenantId);
|
|
|
|
tenantedDeviceWrapper.setTenantDomain(tenantDomain);
|
|
|
|
tenantedDeviceWrapper.setTenantDomain(tenantDomain);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new SCEPException("Error occurred while getting the datasource connection.", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new SCEPException("Error occurred while reading the device dao.", e);
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new SCEPException("Error occurred while getting the tenant domain.", e);
|
|
|
|
throw new SCEPException("Error occurred while getting the tenant domain.", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
throw new SCEPException("Error occurred while getting device '" + deviceIdentifier + "'.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tenantedDeviceWrapper;
|
|
|
|
return tenantedDeviceWrapper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|