use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class InumService method containsTrustRelationship.
public boolean containsTrustRelationship(String inum, String gluuInum) {
GluuSAMLTrustRelationship tRelation = new GluuSAMLTrustRelationship();
tRelation.setBaseDn(String.format("inum=%s,ou=trustRelationships,inum=%s,o=gluu", inum, gluuInum));
return ldapEntryManager.contains(tRelation);
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship 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.oxtrust.model.GluuSAMLTrustRelationship 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;
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method markAsInactive.
private void markAsInactive() {
// files in meta-data folder
if (update) {
try {
GluuSAMLTrustRelationship tmpTrustRelationship = trustService.getRelationshipByInum(this.trustRelationship.getInum());
tmpTrustRelationship.setStatus(GluuStatus.INACTIVE);
saveTR(update);
} catch (LdapMappingException ex) {
log.error("Failed to update trust relationship {}", ex, inum);
}
} else {
// Remove file name to generate new one during new save attempt.
// Cover case when somebody else added new one simultaneously
this.trustRelationship.setSpMetaDataFN(null);
this.trustRelationship.setInum(null);
}
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method add.
public String add() {
if (this.trustRelationship != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.trustRelationship = new GluuSAMLTrustRelationship();
this.trustRelationship.setMaxRefreshDelay("PT8H");
this.fileWrapper = new FileUploadWrapper();
this.trustRelationship.setOwner(organizationService.getOrganization().getDn());
boolean initActionsResult = initActions();
if (!initActionsResult) {
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations