use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxAuth by GluuFederation.
the class AppInitializer method loadAppliance.
private GluuAppliance loadAppliance(LdapEntryManager localLdapEntryManager, String... ldapReturnAttributes) {
String baseDn = configurationFactory.getBaseDn().getAppliance();
String applianceInum = configurationFactory.getAppConfiguration().getApplianceInum();
if (StringHelper.isEmpty(baseDn) || StringHelper.isEmpty(applianceInum)) {
return null;
}
String applianceDn = String.format("inum=%s,%s", applianceInum, baseDn);
GluuAppliance appliance = null;
try {
appliance = localLdapEntryManager.find(GluuAppliance.class, applianceDn, ldapReturnAttributes);
} catch (LdapMappingException ex) {
log.error("Failed to load appliance entry from Ldap", ex);
return null;
}
return appliance;
}
use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.
the class LdifService method exportLDIFFile.
public void exportLDIFFile(List<String> checkedItems, OutputStream output) throws LDAPException {
List<SearchResultEntry> result = null;
LDAPConnection connection = ldapEntryManager.getLdapOperationService().getConnection();
try {
LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
result = ldifDataUtility.getAttributeResultEntryLDIF(connection, checkedItems, attributeService.getDnForAttribute(null));
} catch (Exception ex) {
log.error("Failed to export ldif file: ", ex);
} finally {
ldapEntryManager.getLdapOperationService().releaseConnection(connection);
}
if (result != null && result.size() > 0) {
// Write all of the matching entries to LDIF.
LDIFWriter ldifWriter;
try {
ldifWriter = new LDIFWriter(output);
for (SearchResultEntry entry : result) {
ldifWriter.writeEntry(entry);
}
ldifWriter.close();
} catch (IOException e) {
throw new LdapMappingException("Error writing to file, try again", e);
}
}
}
use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.
the class JsonConfigurationService method loadOxAuthConfig.
private LdapOxAuthConfiguration loadOxAuthConfig(String configurationDn) {
try {
configurationDn = configurationDn.replace("ou=oxtrust", "ou=oxauth");
LdapOxAuthConfiguration conf = ldapEntryManager.find(LdapOxAuthConfiguration.class, configurationDn);
return conf;
} catch (LdapMappingException ex) {
log.error("Failed to load configuration from LDAP");
}
return null;
}
use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method save.
public String save() {
synchronized (svnSyncTimer) {
if (StringHelper.isEmpty(this.trustRelationship.getInum())) {
this.inum = trustService.generateInumForNewTrustRelationship();
this.trustRelationship.setInum(this.inum);
} else {
this.inum = this.trustRelationship.getInum();
if (this.trustRelationship.getSpMetaDataFN() == null)
update = true;
}
boolean updateShib3Configuration = appConfiguration.isConfigGeneration();
switch(trustRelationship.getSpMetaDataSourceType()) {
case GENERATE:
String certificate = getCertForGeneratedSP();
GluuStatus status = StringHelper.isNotEmpty(certificate) ? GluuStatus.ACTIVE : GluuStatus.INACTIVE;
this.trustRelationship.setStatus(status);
if (generateSpMetaDataFile(certificate)) {
setEntityId();
} else {
log.error("Failed to generate SP meta-data file");
return OxTrustConstants.RESULT_FAILURE;
}
break;
case FILE:
if (saveSpMetaDataFileSourceTypeFile()) {
//update = true;
updateSpMetaDataCert(certWrapper);
// setEntityId();
if (!update) {
this.trustRelationship.setStatus(GluuStatus.ACTIVE);
}
} else {
log.error("Failed to save SP meta-data file {}", fileWrapper);
return OxTrustConstants.RESULT_FAILURE;
}
break;
case URI:
try {
//if (saveSpMetaDataFileSourceTypeURI()) {
// setEntityId();
boolean result = shibboleth3ConfService.existsResourceUri(trustRelationship.getSpMetaDataURL());
if (result) {
newThreadSaveSpMetaDataFileSourceTypeURI();
} else {
log.info("There is no resource found Uri : {}", trustRelationship.getSpMetaDataURL());
}
if (!update) {
this.trustRelationship.setStatus(GluuStatus.ACTIVE);
}
/*} else {
log.error("Failed to save SP meta-data file {}", fileWrapper);
return OxTrustConstants.RESULT_FAILURE;
}*/
} catch (Exception e) {
return "unable_download_metadata";
}
break;
case FEDERATION:
if (!update) {
this.trustRelationship.setStatus(GluuStatus.ACTIVE);
}
if (this.trustRelationship.getEntityId() == null) {
return "invalid_entity_id";
}
break;
default:
break;
}
trustService.updateReleasedAttributes(this.trustRelationship);
boolean federation = shibboleth3ConfService.isFederation(this.trustRelationship);
this.trustRelationship.setFederation(federation);
trustContactsAction.saveContacts();
if (update) {
try {
saveTR(update);
} catch (LdapMappingException ex) {
log.error("Failed to update trust relationship {}", ex, inum);
return OxTrustConstants.RESULT_FAILURE;
}
} else {
String dn = trustService.getDnForTrustRelationShip(this.inum);
// Save trustRelationship
this.trustRelationship.setDn(dn);
try {
saveTR(update);
} catch (LdapMappingException ex) {
log.error("Failed to add new trust relationship {}", ex, this.trustRelationship.getInum());
return OxTrustConstants.RESULT_FAILURE;
}
this.update = true;
}
if (updateShib3Configuration) {
List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
updateShibboleth3Configuration(trustRelationships);
}
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.site.ldap.persistence.exception.LdapMappingException in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method delete.
public String delete() {
String result = OxTrustConstants.RESULT_FAILURE;
if (update) {
// Remove trust relationship
try {
synchronized (svnSyncTimer) {
for (GluuSAMLTrustRelationship trust : trustService.getDeconstructedTrustRelationships(this.trustRelationship)) {
if (GluuStatus.ACTIVE.equals(trust.getStatus())) {
log.error("Failed to remove federation trust relationship {}, there are still active federated Trust Relationships left.", this.trustRelationship.getInum());
return result;
}
}
for (GluuSAMLTrustRelationship trust : trustService.getDeconstructedTrustRelationships(this.trustRelationship)) {
trustService.removeTrustRelationship(trust);
svnSyncTimer.removeTrustRelationship(trust, identity.getCredentials().getUsername());
}
shibboleth3ConfService.removeSpMetadataFile(this.trustRelationship.getSpMetaDataFN());
trustService.removeTrustRelationship(this.trustRelationship);
svnSyncTimer.removeTrustRelationship(this.trustRelationship, identity.getCredentials().getUsername());
}
result = OxTrustConstants.RESULT_SUCCESS;
} catch (LdapMappingException ex) {
result = OxTrustConstants.RESULT_FAILURE;
log.error("Failed to remove trust relationship {}", ex, this.trustRelationship.getInum());
} catch (InterruptedException e) {
log.error("Failed to add trust relationship to remove queue. It will be removed during next application restart", e);
} finally {
List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
updateShibboleth3Configuration(trustRelationships);
}
}
return result;
}
Aggregations