Search in sources :

Example 1 with GluuAppliance

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;
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) Date(java.util.Date)

Example 2 with GluuAppliance

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;
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 3 with GluuAppliance

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);
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 4 with GluuAppliance

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);
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 5 with GluuAppliance

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");
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) Date(java.util.Date) Test(org.testng.annotations.Test) BaseTest(org.gluu.oxtrust.action.test.BaseTest)

Aggregations

GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)27 Date (java.util.Date)8 IOException (java.io.IOException)4 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 BaseTest (org.gluu.oxtrust.action.test.BaseTest)3 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)3 Test (org.testng.annotations.Test)3 SimpleDateFormat (java.text.SimpleDateFormat)2 PasswordResetRequest (org.gluu.oxtrust.model.PasswordResetRequest)2 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)2 GluuBoolean (org.gluu.persist.model.base.GluuBoolean)2 AppConfiguration (org.xdi.config.oxtrust.AppConfiguration)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1 RequestScoped (javax.enterprise.context.RequestScoped)1 Produces (javax.enterprise.inject.Produces)1 ExternalContext (javax.faces.context.ExternalContext)1