use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageOtherCustomScriptAction method addCustomScript.
public void addCustomScript(CustomScriptType scriptType) {
List<CustomScript> customScriptsByType = this.customScriptsByTypes.get(scriptType);
CustomScript customScript;
if (CustomScriptType.PERSON_AUTHENTICATION == scriptType) {
AuthenticationCustomScript authenticationCustomScript = new AuthenticationCustomScript();
authenticationCustomScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
authenticationCustomScript.setUsageType(AuthenticationScriptUsageType.INTERACTIVE);
customScript = authenticationCustomScript;
} else {
customScript = new CustomScript();
customScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
}
customScript.setLocationType(ScriptLocationType.LDAP);
customScript.setScriptType(scriptType);
customScript.setProgrammingLanguage(ProgrammingLanguage.PYTHON);
customScript.setConfigurationProperties(new ArrayList<SimpleExtendedCustomProperty>());
customScriptsByType.add(customScript);
}
use of org.gluu.model.custom.script.model.CustomScript 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.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class UpdateUmaScopeAction method updateAuthorizationPolicies.
private void updateAuthorizationPolicies() {
if (this.authorizationPolicies == null || this.authorizationPolicies.size() == 0) {
this.umaScope.setUmaAuthorizationPolicies(null);
return;
}
List<String> tmpAuthorizationPolicies = new ArrayList<String>();
for (CustomScript authorizationPolicy : this.authorizationPolicies) {
tmpAuthorizationPolicies.add(authorizationPolicy.getDn());
}
this.umaScope.setUmaAuthorizationPolicies(tmpAuthorizationPolicies);
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class CustomScriptWebResourceTest method getCustomScript.
private CustomScript getCustomScript(String name) {
CustomScript customScript = new CustomScript();
customScript.setName(name);
customScript.setDescription(name);
customScript.setEnabled(false);
customScript.setLevel(20);
customScript.setConfigurationProperties(new ArrayList<>());
customScript.setModuleProperties(new ArrayList<>());
customScript.setLocationType(ScriptLocationType.LDAP);
customScript.setProgrammingLanguage(ProgrammingLanguage.PYTHON);
customScript.setScript("I'm a custom script added via oxtrust api");
customScript.setScriptType(CustomScriptType.PERSON_AUTHENTICATION);
return customScript;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class CustomScriptWebResourceTest method listCustomScriptsTest.
@Test
public void listCustomScriptsTest() {
HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.CONFIGURATION + ApiConstants.SCRIPTS);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
try {
String content = EntityUtils.toString(entity);
CustomScript[] scripts = mapper.readValue(content, CustomScript[].class);
Assert.assertTrue(scripts.length > 5);
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
Aggregations