use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class ConfigurationStatusTest method testIsConfigurationStatus3.
@Test(dependsOnMethods = { "testIsConfigurationStatus2" })
@Parameters({ "test.login.user.admin.uid" })
public void testIsConfigurationStatus3(String userUid) {
loginUuser(userUid);
GluuConfiguration configuration = configurationService.getConfiguration();
long currentTime = System.currentTimeMillis() - 101 * 1000;
Date currentDateTime = new Date(currentTime);
configuration.setLastUpdate(currentDateTime);
configurationService.updateConfiguration(configuration);
assertEquals(configurationStatusAction.checkHealth(), OxTrustConstants.RESULT_SUCCESS);
assertEquals(configurationStatusAction.getHealth(), "FAIL");
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class ConfigurationStatusTest method testIsConfigurationStatus1.
@Test
@Parameters({ "test.login.user.admin.uid" })
public void testIsConfigurationStatus1(String userUid) {
loginUuser(userUid);
GluuConfiguration configuration = configurationService.getConfiguration();
Date currentDateTime = new Date();
configuration.setLastUpdate(currentDateTime);
configurationService.updateConfiguration(configuration);
assertEquals(configurationStatusAction.checkHealth(), OxTrustConstants.RESULT_SUCCESS);
assertEquals(configurationStatusAction.getHealth(), "OK");
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class ConfigurationStatusTest method testIsConfigurationStatus2.
@Test(dependsOnMethods = { "testIsConfigurationStatus1" })
@Parameters({ "test.login.user.admin.uid" })
public void testIsConfigurationStatus2(String userUid) {
loginUuser(userUid);
GluuConfiguration configuration = configurationService.getConfiguration();
long currentTime = System.currentTimeMillis() - 50 * 1000;
Date currentDateTime = new Date(currentTime);
configuration.setLastUpdate(currentDateTime);
configurationService.updateConfiguration(configuration);
assertEquals(configurationStatusAction.checkHealth(), OxTrustConstants.RESULT_SUCCESS);
assertEquals(configurationStatusAction.getHealth(), "OK");
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class LogDir method processInt.
/**
* Gather periodically site and server status
*/
private void processInt() {
GluuConfiguration configuration = configurationService.getConfiguration();
long maxSize = configuration.getMaxLogSize();
;
log.debug("Max Log Size: " + maxSize);
if (maxSize > 0) {
log.debug("Max Log Size: " + maxSize);
long maxSizeInByte = maxSize * 1024 * 1024;
long currentSize = 0;
Date today = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = sdf.format(today);
log.debug("Getting the tomcat home directory");
String filePath = ConfigurationFactory.DIR + ConfigurationFactory.LOG_ROTATION_CONFIGURATION;
log.debug("FilePath: " + filePath);
List<LogDir> logDirs = readConfig(filePath);
List<FileData> fDataList = new ArrayList<FileData>();
for (LogDir logDir : logDirs) {
File file = new File(logDir.getLocation());
File[] files = file.listFiles();
long totalSize = 0;
if (files != null && files.length > 0) {
for (File singleFile : files) {
if (singleFile.getName().startsWith(logDir.getPrefix()) && singleFile.getName().endsWith(logDir.getExtension())) {
totalSize += singleFile.length();
FileData fData = new FileData(singleFile.getName(), logDir.getLocation(), singleFile.lastModified(), singleFile.length());
fDataList.add(fData);
}
}
}
currentSize += totalSize;
logDir.setLength(totalSize);
}
Collections.sort(fDataList);
if (currentSize > maxSizeInByte) {
// empty 15% space
maxSizeInByte -= (maxSizeInByte * 15) / 100;
// less of the
// maximum
// allocated
}
for (FileData fileData : fDataList) {
if (currentSize < maxSizeInByte) {
break;
}
Date date = new Date(fileData.getLastModified());
String dateStr = sdf.format(date);
if (todayStr.equals(dateStr)) {
log.debug("--Skipped Active File: " + fileData.getName() + " Date: " + sdf.format(date) + " Size: " + fileData.getSize());
continue;
}
File singleFile = new File(fileData.getFilePath() + "/" + fileData.getName());
if (!singleFile.delete()) {
log.error("Failed to delete the file.");
} else {
currentSize -= fileData.getSize();
log.debug("--Deleted File Name: " + fileData.getName() + " Date: " + sdf.format(date) + " Size: " + fileData.getSize());
}
}
}
}
use of org.gluu.oxtrust.model.GluuConfiguration in project oxTrust by GluuFederation.
the class PermissionService method hasPermission.
public boolean hasPermission(Object target, String action) {
log.trace("Checking permissions for target '{}' an 'action'. Identity: {}", target, action, identity);
if (!identity.isLoggedIn()) {
return false;
}
if (identity.hasRole(UserRole.MANAGER.getValue()) || identity.hasRole(UserRole.USER.getValue())) {
if (StringHelper.equalsIgnoreCase("profile_management", action)) {
GluuConfiguration configuration = configurationService.getConfiguration();
GluuConfiguration targetConfiguration = (GluuConfiguration) target;
if (configuration.isProfileManagment() && StringHelper.equals(configurationService.getConfiguration().getInum(), targetConfiguration.getInum())) {
return true;
} else {
return false;
}
}
}
if (identity.hasRole(UserRole.MANAGER.getValue())) {
for (String[] managerAction : managerActions) {
String targetString = (String) target;
if (StringHelper.equals(managerAction[0], targetString) && StringHelper.equals(managerAction[1], action)) {
return true;
}
}
}
if (identity.hasRole(UserRole.USER.getValue())) {
for (String[] managerAction : managerActions) {
String targetString = (String) target;
if (StringHelper.equals("profile", targetString) && StringHelper.equals(managerAction[0], targetString) && StringHelper.equals(managerAction[1], action)) {
return true;
}
}
}
return false;
}
Aggregations