use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ApplianceStatusAction method checkHealth.
public String checkHealth() {
GluuAppliance appliance = applianceService.getAppliance();
Date lastUpdateDateTime = appliance.getLastUpdate();
long lastUpdate = 0;
if (lastUpdateDateTime != null) {
lastUpdate = lastUpdateDateTime.getTime();
}
long currentTime = System.currentTimeMillis();
log.debug("lastUpdate: '{}', currentTime: '{}'", lastUpdate, currentTime);
long timeSinceLastUpdate = (currentTime - lastUpdate) / 1000;
if (timeSinceLastUpdate >= 0 && timeSinceLastUpdate < 100) {
this.setHealth("OK");
} else {
this.setHealth("FAIL");
}
log.debug("Set status '{}'", this.getHealth());
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class BaseScimWebService method getAuthorizedUser.
protected boolean getAuthorizedUser() {
try {
GluuCustomPerson authUser = (GluuCustomPerson) identity.getSessionMap().get(OxTrustConstants.CURRENT_PERSON);
if (authUser == null) {
return false;
}
GluuAppliance appliance = applianceService.getAppliance();
if (appliance == null) {
return false;
}
if (!(GluuBoolean.TRUE.equals(appliance.getScimEnabled()) || GluuBoolean.ENABLED.equals(appliance.getScimEnabled()))) {
return false;
}
return true;
} catch (Exception ex) {
log.error("Exception: ", ex);
return false;
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class InumService method containsAppliance.
public boolean containsAppliance(String inum, String gluuInum) {
GluuAppliance appliance = new GluuAppliance();
appliance.setBaseDn(String.format("inum=%s,ou=appliances,o=gluu", inum));
return ldapEntryManager.contains(appliance);
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class InumService method containsServer.
public boolean containsServer(String inum, String gluuInum) {
GluuAppliance appliance = new GluuAppliance();
appliance.setBaseDn(String.format("inum=%s,ou=servers,o=gluu", inum));
return ldapEntryManager.contains(appliance);
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ApplianceStatusTest method testIsApplianceStatus1.
@Test
public void testIsApplianceStatus1() throws Exception {
GluuAppliance appliance = applianceService.getAppliance();
Date currentDateTime = new Date();
appliance.setLastUpdate(currentDateTime);
applianceService.updateAppliance(appliance);
assertEquals(applianceStatusAction.checkHealth(), OxTrustConstants.RESULT_SUCCESS);
assertEquals(applianceStatusAction.getHealth(), "OK");
}
Aggregations