use of org.xdi.ldap.model.GluuStatus 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.xdi.ldap.model.GluuStatus in project oxAuth by GluuFederation.
the class UserService method addUser.
public User addUser(User user, boolean active) {
String peopleBaseDN = staticConfiguration.getBaseDn().getPeople();
String inum = inumService.generatePeopleInum();
user.setDn("inum=" + inum + "," + peopleBaseDN);
user.setAttribute("inum", inum);
GluuStatus status = active ? GluuStatus.ACTIVE : GluuStatus.REGISTER;
user.setAttribute("gluuStatus", status.getValue());
ldapEntryManager.persist(user);
return getUserByDn(user.getDn());
}
Aggregations