Search in sources :

Example 11 with GluuAppliance

use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.

the class UpdateOrganizationAction method modifyOrganization.

private String modifyOrganization() {
    if (this.organization != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuOrganization tmpOrganization = organizationService.getOrganization();
        this.organization = new GluuOrganization();
        // Clone shared instance
        try {
            PropertyUtils.copyProperties(this.organization, tmpOrganization);
        } catch (Exception ex) {
            log.error("Failed to load organization", ex);
            this.organization = null;
        }
    } catch (LdapMappingException ex) {
        log.error("Failed to load organization", ex);
    }
    if (this.organization == null) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    initLogoImage();
    initFaviconImage();
    this.loginPageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_LOGIN_PAGE);
    this.welcomePageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_WELCOME_PAGE);
    this.welcomeTitleText = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_TITLE_TEXT);
    appliances = new ArrayList<GluuAppliance>();
    try {
        appliances.addAll(applianceService.getAppliances());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) MessagingException(javax.mail.MessagingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) AuthenticationFailedException(javax.mail.AuthenticationFailedException) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 12 with GluuAppliance

use of org.gluu.oxtrust.model.GluuAppliance 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(GluuUserRole.MANAGER.getValue()) || identity.hasRole(GluuUserRole.USER.getValue())) {
        if (StringHelper.equals("profile_management", action)) {
            GluuAppliance appliance = applianceService.getAppliance();
            GluuAppliance targetAppliance = (GluuAppliance) target;
            if (((appliance.getProfileManagment() != null) && appliance.getProfileManagment().isBooleanValue()) && StringHelper.equals(applianceService.getAppliance().getInum(), targetAppliance.getInum())) {
                return true;
            } else {
                return false;
            }
        }
        if (StringHelper.equals("whitePagesEnabled", action)) {
            GluuAppliance appliance = applianceService.getAppliance();
            GluuAppliance targetAppliance = (GluuAppliance) target;
            if (((appliance.getWhitePagesEnabled() != null) && appliance.getWhitePagesEnabled().isBooleanValue()) && StringHelper.equals(applianceService.getAppliance().getInum(), targetAppliance.getInum())) {
                return true;
            } else {
                return false;
            }
        }
    }
    if (identity.hasRole(GluuUserRole.MANAGER.getValue())) {
        for (String[] managerAction : managerActions) {
            String targetString = (String) target;
            if (StringHelper.equals(managerAction[0], targetString) && StringHelper.equals(managerAction[1], action)) {
                return true;
            }
        }
    }
    return false;
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 13 with GluuAppliance

use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.

the class StatusCheckerDaily method processInt.

/**
	 * Gather periodically site and server status
	 * 
	 * @param when
	 *            Date
	 * @param interval
	 *            Interval
	 */
private void processInt() {
    log.debug("Starting daily status checker");
    AppConfiguration appConfiguration = configurationFactory.getAppConfiguration();
    if (!appConfiguration.isUpdateApplianceStatus()) {
        return;
    }
    GluuAppliance appliance;
    try {
        appliance = applianceService.getAppliance();
    } catch (LdapMappingException ex) {
        log.error("Failed to load current appliance", ex);
        return;
    }
    // Set LDAP attributes
    setLdapAttributes(appliance);
    Date currentDateTime = new Date();
    appliance.setLastUpdate(currentDateTime);
    try {
        applianceService.updateAppliance(appliance);
    } catch (LdapMappingException ex) {
        log.error("Failed to update current appliance", ex);
        return;
    }
    if (centralLdapService.isUseCentralServer()) {
        try {
            GluuAppliance tmpAppliance = new GluuAppliance();
            tmpAppliance.setDn(appliance.getDn());
            boolean existAppliance = centralLdapService.containsAppliance(tmpAppliance);
            if (existAppliance) {
                centralLdapService.updateAppliance(appliance);
            } else {
                centralLdapService.addAppliance(appliance);
            }
        } catch (LdapMappingException ex) {
            log.error("Failed to update appliance at central server", ex);
            return;
        }
    }
    log.debug("Daily Appliance status update finished");
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) AppConfiguration(org.xdi.config.oxtrust.AppConfiguration) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) Date(java.util.Date)

Example 14 with GluuAppliance

use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method modify.

public String modify() {
    if (this.initialized) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuAppliance appliance = applianceService.getAppliance();
        if (appliance == null) {
            return OxTrustConstants.RESULT_FAILURE;
        }
        passportEnable = appliance.getPassportEnabled();
        log.info("passport enabled value  : '{}'", passportEnable);
        this.customScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION), "displayName", "oxLevel", "gluuStatus");
        OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
        if (idpConf != null) {
            this.ldapConfig = mapLdapConfig(idpConf.getConfig());
        }
        this.existLdapConfigIdpAuthConf = this.ldapConfig != null;
        if (this.ldapConfig == null) {
            this.ldapConfig = new GluuLdapConfiguration();
        }
        this.authenticationMode = appliance.getAuthenticationMode();
        this.oxTrustAuthenticationMode = appliance.getOxTrustAuthenticationMode();
        ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
        if (ldapOxPassportConfiguration == null) {
            ldapOxPassportConfiguration = new LdapOxPassportConfiguration();
        }
        this.ldapPassportConfigurations = ldapOxPassportConfiguration.getPassportConfigurations();
    } catch (Exception ex) {
        log.error("Failed to load appliance configuration", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 15 with GluuAppliance

use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method save.

public String save() {
    try {
        // Reload entry to include latest changes
        GluuAppliance appliance = applianceService.getAppliance();
        boolean updateAuthenticationMode = false;
        boolean updateOxTrustAuthenticationMode = false;
        OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
        if (idpConf != null && idpConf.getName() != null) {
            if (idpConf.getName().equals(this.authenticationMode)) {
                updateAuthenticationMode = true;
            }
            if (idpConf.getName().equals(this.oxTrustAuthenticationMode)) {
                updateOxTrustAuthenticationMode = true;
            }
        }
        this.ldapConfig.updateStringsLists();
        updateAuthConf(appliance);
        String updatedAuthMode = updateAuthenticationMode ? this.ldapConfig.getConfigId() : this.authenticationMode;
        String updatedOxTrustAuthMode = updateOxTrustAuthenticationMode ? this.ldapConfig.getConfigId() : this.oxTrustAuthenticationMode;
        appliance.setAuthenticationMode(updatedAuthMode);
        appliance.setOxTrustAuthenticationMode(updatedOxTrustAuthMode);
        appliance.setPassportEnabled(passportEnable);
        applianceService.updateAppliance(appliance);
        ldapOxPassportConfiguration.setPassportConfigurations(ldapPassportConfigurations);
        passportService.updateLdapOxPassportConfiguration(ldapOxPassportConfiguration);
    } catch (LdapMappingException ex) {
        log.error("Failed to update appliance configuration", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update appliance");
        return OxTrustConstants.RESULT_FAILURE;
    }
    reset();
    return modify();
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf)

Aggregations

GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)36 Date (java.util.Date)8 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)7 IOException (java.io.IOException)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)4 File (java.io.File)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3 BaseTest (org.gluu.oxtrust.action.test.BaseTest)3 PasswordResetRequest (org.gluu.oxtrust.model.PasswordResetRequest)3 TrustStoreCertificate (org.gluu.oxtrust.model.cert.TrustStoreCertificate)3 Test (org.testng.annotations.Test)3 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 AuthenticationFailedException (javax.mail.AuthenticationFailedException)2 MessagingException (javax.mail.MessagingException)2 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)2 TrustStoreConfiguration (org.gluu.oxtrust.model.cert.TrustStoreConfiguration)2 MailUtils (org.gluu.oxtrust.util.MailUtils)2