use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.
the class UpdateUmaScopeAction method searchAvailableAuthorizationPolicies.
public void searchAvailableAuthorizationPolicies() {
if (this.availableAuthorizationPolicies != null) {
selectAddedAuthorizationPolicies();
return;
}
try {
List<CustomScript> availableScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.UMA_RPT_POLICY), CUSTOM_SCRIPT_RETURN_ATTRIBUTES);
List<SelectableEntity<CustomScript>> tmpAvailableAuthorizationPolicies = new ArrayList<SelectableEntity<CustomScript>>();
for (CustomScript authorizationPolicy : availableScripts) {
tmpAvailableAuthorizationPolicies.add(new SelectableEntity<CustomScript>(authorizationPolicy));
}
this.availableAuthorizationPolicies = tmpAvailableAuthorizationPolicies;
selectAddedAuthorizationPolicies();
} catch (BasePersistenceException ex) {
log.error("Failed to find available authorization policies", ex);
}
}
use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.
the class UpdateUmaScopeAction method save.
public String save() throws Exception {
this.umaScope.setDisplayName(this.umaScope.getDisplayName().trim());
this.umaScope.setScopeType(ScopeType.UMA);
updateAuthorizationPolicies();
saveAttributesJson();
if (this.update) {
if (scopeWithSameNameExistInUpdate()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "A scope with same name already exist");
return OxTrustConstants.RESULT_FAILURE;
}
try {
scopeDescriptionService.updateUmaScope(this.umaScope);
} catch (BasePersistenceException ex) {
log.error("Failed to update scope description '{}'", this.umaScope.getId(), ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}'");
return OxTrustConstants.RESULT_FAILURE;
}
log.debug("Scope description were updated successfully");
facesMessages.add(FacesMessage.SEVERITY_INFO, "UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' updated successfully");
return OxTrustConstants.RESULT_UPDATE;
} else {
if (scopeWithSameNameExist()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "A scope with same name already exist");
return OxTrustConstants.RESULT_FAILURE;
}
Scope exampleScopeDescription = new Scope();
exampleScopeDescription.setDn(scopeDescriptionService.getDnForScope(null));
exampleScopeDescription.setId(umaScope.getId());
String inum = scopeDescriptionService.generateInumForNewScope();
String scopeDescriptionDn = scopeDescriptionService.getDnForScope(inum);
this.umaScope.setInum(inum);
this.umaScope.setDn(scopeDescriptionDn);
this.umaScope.setId(umaScope.getId());
try {
scopeDescriptionService.addUmaScope(this.umaScope);
} catch (BasePersistenceException ex) {
log.error("Failed to add new UMA resource '{}'", this.umaScope.getId(), ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new UMA resource");
return OxTrustConstants.RESULT_FAILURE;
}
log.debug("Scope description were add successfully");
facesMessages.add(FacesMessage.SEVERITY_INFO, "New UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' added successfully");
conversationService.endConversation();
this.update = true;
this.scopeInum = inum;
return OxTrustConstants.RESULT_SUCCESS;
}
}
use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.
the class UpdateUmaScopeAction method update.
public String update() {
this.update = true;
if (this.umaScope != null) {
this.oxAttributesJson = getScopeAttributesJson();
return OxTrustConstants.RESULT_SUCCESS;
}
try {
String scopeDn = scopeDescriptionService.getDnForScope(this.scopeInum);
this.umaScope = scopeDescriptionService.getUmaScopeByDn(scopeDn);
this.oxAttributesJson = getScopeAttributesJson();
this.authorizationPolicies = getInitialAuthorizationPolicies();
List<UmaResource> umaResourceList = resourceSetService.findResourcesByScope(scopeDn);
if (umaResourceList != null) {
for (UmaResource umaResource : umaResourceList) {
List<String> list = umaResource.getClients();
if (list != null) {
clientList = new ArrayList<OxAuthClient>();
for (String clientDn : list) {
OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
if (oxAuthClient != null) {
clientList.add(oxAuthClient);
}
}
}
}
}
} catch (BasePersistenceException ex) {
log.error("Failed to find scope description '{}'", this.scopeInum, ex);
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
if (this.umaScope == null) {
log.error("Scope description is null");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.
the class CacheRefreshTimer method removeTargetEntries.
private Pair<List<String>, List<String>> removeTargetEntries(LdapServerConnection inumDbServerConnection, PersistenceEntryManager targetPersistenceEntryManager, List<GluuSimplePerson> removedPersons, HashMap<String, GluuInumMap> inumInumMap) {
Date runDate = new Date(this.lastFinishedTime);
PersistenceEntryManager inumDbPersistenceEntryManager = inumDbServerConnection.getPersistenceEntryManager();
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, ldapEntryManager.encodeTime(removedPerson.getDn(), runDate));
try {
inumDbPersistenceEntryManager.merge(removedInumMap);
result2.add(removedInumMap.getInum());
} catch (BasePersistenceException ex) {
log.error("Failed to update entry with inum '{}' and DN: {}", currentInumMap.getInum(), currentInumMap.getDn(), ex);
continue;
}
}
// Remove person from target server
try {
targetPersistenceEntryManager.removeRecursively(removedPerson.getDn());
result1.add(inum);
} catch (BasePersistenceException ex) {
log.error("Failed to remove person entry with inum '{}' and DN: {}", inum, removedPerson.getDn(), ex);
continue;
}
log.debug("Person with DN: '{}' removed from target server", removedPerson.getDn());
}
return new Pair<List<String>, List<String>>(result1, result2);
}
use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.
the class UpdateResourceAction method update.
private String update() {
log.debug("Loading UMA resource set '{}'", this.oxId);
try {
String resourceDn = umaResourcesService.getDnForResource(this.oxId);
this.resource = umaResourcesService.getResourceByDn(resourceDn);
} catch (BasePersistenceException ex) {
log.error("Failed to find resource set '{}'", this.oxId, ex);
return OxTrustConstants.RESULT_FAILURE;
}
if (this.resource == null) {
log.error("Resource set is null");
return OxTrustConstants.RESULT_FAILURE;
}
this.scopes = getScopesDisplayNameEntries();
this.clients = getClientDisplayNameEntries();
this.clientList = new ArrayList<OxAuthClient>();
List<String> list = this.resource.getClients();
if (list != null) {
for (String clientDn : list) {
OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
if (oxAuthClient != null) {
clientList.add(oxAuthClient);
}
}
}
if (this.resource.getResources() == null) {
this.resources = new ArrayList<String>();
} else {
this.resources = new ArrayList<String>(this.resource.getResources());
}
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations