use of org.gluu.model.custom.script.model.CustomScript in project oxCore by GluuFederation.
the class AbstractCustomScriptService method getCustomScriptByINum.
public Optional<CustomScript> getCustomScriptByINum(String baseDn, String inum, String... returnAttributes) {
final List<Filter> customScriptTypeFilters = new ArrayList<Filter>();
final Filter customScriptTypeFilter = Filter.createEqualityFilter("inum", inum);
customScriptTypeFilters.add(customScriptTypeFilter);
final Filter filter = Filter.createORFilter(customScriptTypeFilters);
final List<CustomScript> result = persistenceEntryManager.findEntries(baseDn, CustomScript.class, filter, returnAttributes);
if (result.isEmpty()) {
return Optional.absent();
}
return Optional.of(result.get(0));
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class UpdateUmaScopeAction method getInitialAuthorizationPolicies.
private List<CustomScript> getInitialAuthorizationPolicies() {
List<CustomScript> result = new ArrayList<CustomScript>();
if ((this.umaScope.getUmaAuthorizationPolicies() == null) || (this.umaScope.getUmaAuthorizationPolicies().size() == 0)) {
return result;
}
List<DisplayNameEntry> displayNameEntries = lookupService.getDisplayNameEntries(customScriptService.baseDn(), this.umaScope.getUmaAuthorizationPolicies());
if (displayNameEntries != null) {
for (DisplayNameEntry displayNameEntry : displayNameEntries) {
result.add(new CustomScript(displayNameEntry.getDn(), displayNameEntry.getInum(), displayNameEntry.getDisplayName()));
}
}
return result;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageOtherCustomScriptAction method cleanAcrs.
private Set<String> cleanAcrs(String name) {
Set<String> result = new HashSet<>();
result.addAll(allAcrs);
List<CustomScript> scripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION));
for (CustomScript customScript : scripts) {
if (null == customScript.getAliases())
customScript.setAliases(new ArrayList<>());
if (customScript.getName() != null) {
if (!customScript.getName().equals(name)) {
List<String> existing = customScript.getAliases();
if (existing != null && existing.size() > 0) {
for (String value : existing) {
result.remove(value);
}
}
}
}
}
return result;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageOtherCustomScriptAction method save.
public String save() {
try {
List<CustomScript> oldCustomScripts = customScriptService.findCustomScripts(Arrays.asList(getScriptType()), "dn", "inum");
List<String> updatedInums = new ArrayList<String>();
for (Entry<CustomScriptType, List<CustomScript>> customScriptsByType : this.customScriptsByTypes.entrySet()) {
List<CustomScript> customScripts = customScriptsByType.getValue();
for (CustomScript customScript : customScripts) {
String configId = customScript.getName();
if (StringHelper.equalsIgnoreCase(configId, OxConstants.SCRIPT_TYPE_INTERNAL_RESERVED_NAME)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "'%s' is reserved script name", configId);
return OxTrustConstants.RESULT_FAILURE;
}
boolean nameValidation = NAME_PATTERN.matcher(customScript.getName()).matches();
if (!nameValidation) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "'%s' is invalid script name. Only alphabetic, numeric and underscore characters are allowed in Script Name", configId);
return OxTrustConstants.RESULT_FAILURE;
}
customScript.setRevision(customScript.getRevision() + 1);
boolean update = true;
String dn = customScript.getDn();
String customScriptId = customScript.getInum();
if (StringHelper.isEmpty(dn)) {
customScriptId = INumGenerator.generate(2);
dn = customScriptService.buildDn(customScriptId);
customScript.setDn(dn);
customScript.setInum(customScriptId);
update = false;
}
customScript.setDn(dn);
customScript.setInum(customScriptId);
if (ScriptLocationType.LDAP == customScript.getLocationType()) {
customScript.removeModuleProperty(CustomScript.LOCATION_PATH_MODEL_PROPERTY);
}
if ((customScript.getConfigurationProperties() != null) && (customScript.getConfigurationProperties().size() == 0)) {
customScript.setConfigurationProperties(null);
}
if ((customScript.getConfigurationProperties() != null) && (customScript.getModuleProperties().size() == 0)) {
customScript.setModuleProperties(null);
}
updatedInums.add(customScriptId);
if (update) {
customScriptService.update(customScript);
} else {
customScriptService.add(customScript);
}
}
}
// Remove removed scripts
for (CustomScript oldCustomScript : oldCustomScripts) {
if (!updatedInums.contains(oldCustomScript.getInum())) {
customScriptService.remove(oldCustomScript);
}
}
} catch (Exception ex) {
log.error("Failed to update custom scripts", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update custom script configuration");
return OxTrustConstants.RESULT_FAILURE;
}
facesMessages.add(FacesMessage.SEVERITY_INFO, "Custom script configuration updated successfully");
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class UpdateClientAction method saveAttributesJson.
private void saveAttributesJson() {
ClientAttributes clientAttributes = new ClientAttributes();
try {
clientAttributes = new ObjectMapper().readValue(this.oxAttributesJson, ClientAttributes.class);
} catch (Exception e) {
log.info("error parsing json:" + e);
}
clientAttributes.setPostAuthnScripts(postAuthnScripts.stream().map(CustomScript::getDn).collect(Collectors.toList()));
clientAttributes.setRptClaimsScripts(rptClaimsScripts.stream().map(CustomScript::getDn).collect(Collectors.toList()));
clientAttributes.setConsentGatheringScripts(consentScripts.stream().map(CustomScript::getDn).collect(Collectors.toList()));
clientAttributes.setSpontaneousScopeScriptDns(spontaneousScopesScripts.stream().map(CustomScript::getDn).collect(Collectors.toList()));
clientAttributes.setIntrospectionScripts(introspectionScripts.stream().map(CustomScript::getDn).collect(Collectors.toList()));
this.client.setAttributes(clientAttributes);
}
Aggregations