Search in sources :

Example 11 with LdapMappingException

use of org.gluu.site.ldap.persistence.exception.LdapMappingException 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 12 with LdapMappingException

use of org.gluu.site.ldap.persistence.exception.LdapMappingException 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)

Example 13 with LdapMappingException

use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.

the class CacheRefreshTimer method removeTargetEntries.

private Pair<List<String>, List<String>> removeTargetEntries(LdapServerConnection inumDbServerConnection, LdapEntryManager targetLdapEntryManager, List<GluuSimplePerson> removedPersons, HashMap<String, GluuInumMap> inumInumMap) {
    String runDate = ldapEntryManager.encodeGeneralizedTime(new Date(this.lastFinishedTime));
    LdapEntryManager inumDbLdapEntryManager = inumDbServerConnection.getLdapEntryManager();
    List<String> result1 = new ArrayList<String>();
    List<String> result2 = new ArrayList<String>();
    for (GluuSimplePerson removedPerson : removedPersons) {
        String inum = removedPerson.getAttribute(OxTrustConstants.inum);
        // Update GluuInumMap if it exist
        GluuInumMap currentInumMap = inumInumMap.get(inum);
        if (currentInumMap == null) {
            log.warn("Can't find inum entry of person with DN: {}", removedPerson.getDn());
        } else {
            GluuInumMap removedInumMap = getMarkInumMapEntryAsRemoved(currentInumMap, runDate);
            try {
                inumDbLdapEntryManager.merge(removedInumMap);
                result2.add(removedInumMap.getInum());
            } catch (LdapMappingException ex) {
                log.error("Failed to update entry with inum '{}' and DN: {}", ex, currentInumMap.getInum(), currentInumMap.getDn());
                continue;
            }
        }
        // Remove person from target server
        try {
            targetLdapEntryManager.removeWithSubtree(removedPerson.getDn());
            result1.add(inum);
        } catch (LdapMappingException ex) {
            log.error("Failed to remove person entry with inum '{}' and DN: {}", ex, inum, removedPerson.getDn());
            continue;
        }
        log.debug("Person with DN: '{}' removed from target server", removedPerson.getDn());
    }
    return new Pair<List<String>, List<String>>(result1, result2);
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) GluuInumMap(org.gluu.oxtrust.ldap.cache.model.GluuInumMap) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) ArrayList(java.util.ArrayList) Date(java.util.Date) Pair(org.xdi.util.Pair)

Example 14 with LdapMappingException

use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.

the class ScopeDescriptionDownloadAction method getScopeDescription.

private ScopeDescription getScopeDescription() {
    try {
        scopeDescriptionService.prepareScopeDescriptionBranch();
    } catch (Exception ex) {
        log.error("Failed to initialize download action", ex);
        return null;
    }
    log.debug("Loading UMA scope description '{}'", this.scopeId);
    ScopeDescription scopeDescription;
    try {
        List<ScopeDescription> scopeDescriptions = scopeDescriptionService.findScopeDescriptionsById(this.scopeId);
        if (scopeDescriptions.size() != 1) {
            log.error("Failed to find scope description '{}'. Found: '{}'", this.scopeId, scopeDescriptions.size());
            return null;
        }
        scopeDescription = scopeDescriptions.get(0);
    } catch (LdapMappingException ex) {
        log.error("Failed to find scope description '{}'", ex, this.scopeId);
        return null;
    }
    return scopeDescription;
}
Also used : LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) ScopeDescription(org.xdi.oxauth.model.uma.persistence.ScopeDescription)

Example 15 with LdapMappingException

use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.

the class StatusCheckerTimer method processInt.

/**
	 * Gather periodically site and server status
	 * 
	 * @param when
	 *            Date
	 * @param interval
	 *            Interval
	 */
private void processInt() {
    log.debug("Starting update of appliance status");
    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;
    }
    // Execute facter and update appliance attributes
    setFactorAttributes(appliance);
    // Execute df and update appliance attributes
    setDfAttributes(appliance);
    // Set HTTPD attributes
    setHttpdAttributes(appliance);
    try {
        setCertificateExpiryAttributes(appliance);
    } catch (Exception ex) {
        log.error("Failed to check certificate expiration", ex);
    }
    //		setVDSAttributes(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("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) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) ParseException(java.text.ParseException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Date(java.util.Date)

Aggregations

LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)27 ArrayList (java.util.ArrayList)6 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)5 IOException (java.io.IOException)4 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)4 Date (java.util.Date)3 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)3 CustomScript (org.xdi.model.custom.script.model.CustomScript)3 ParseException (java.text.ParseException)2 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)2 AppConfiguration (org.xdi.config.oxtrust.AppConfiguration)2 SelectableEntity (org.xdi.model.SelectableEntity)2 ScopeDescription (org.xdi.oxauth.model.uma.persistence.ScopeDescription)2 Filter (com.unboundid.ldap.sdk.Filter)1 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)1 LDIFWriter (com.unboundid.ldif.LDIFWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1