Search in sources :

Example 31 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateClientAction method addCustomScript.

private void addCustomScript(String name) {
    if (StringHelper.isEmpty(name)) {
        return;
    }
    CustomScript addCustomScript = new CustomScript();
    addCustomScript.setName(name);
    if (addCustomScript != null) {
        this.customScripts.add(addCustomScript);
    }
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript)

Example 32 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateClientAction method updateCustomScripts.

private void updateCustomScripts() {
    List<CustomScript> currentCustomScripts = this.customScripts;
    if (currentCustomScripts == null || currentCustomScripts.size() == 0) {
        this.client.setDefaultAcrValues(null);
        return;
    }
    List<String> customScripts = new ArrayList<String>();
    for (CustomScript customScript : currentCustomScripts) {
        customScripts.add(customScript.getName());
    }
    this.client.setDefaultAcrValues(customScripts.toArray(new String[customScripts.size()]));
    this.client.getAttributes().setPostAuthnScripts(BaseEntry.getDNs(getPostAuthnScripts()));
    this.client.getAttributes().setRptClaimsScripts(BaseEntry.getDNs(getRptClaimsScripts()));
    this.client.getAttributes().setConsentGatheringScripts(BaseEntry.getDNs(getConsentScripts()));
    this.client.getAttributes().setIntrospectionScripts(BaseEntry.getDNs(getIntrospectionScripts()));
    this.client.getAttributes().setSpontaneousScopeScriptDns(BaseEntry.getDNs(getSpontaneousScopesScripts()));
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) ArrayList(java.util.ArrayList)

Example 33 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateScopeAction method updateDynamicScripts.

private void updateDynamicScripts() {
    if ((this.dynamicScripts == null) || (this.dynamicScripts.size() == 0)) {
        this.scope.setDynamicScopeScripts(null);
        return;
    }
    List<String> resultDynamicScripts = new ArrayList<String>();
    for (CustomScript dynamicScript : this.dynamicScripts) {
        resultDynamicScripts.add(dynamicScript.getDn());
    }
    this.scope.setDynamicScopeScripts(resultDynamicScripts);
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) ArrayList(java.util.ArrayList)

Example 34 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class CustomScriptWebResource method updateCustomScript.

@PUT
@Operation(summary = "Update custom script", description = "Update custom script")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CustomScript.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateCustomScript(CustomScript customScript) {
    try {
        Objects.requireNonNull(customScript, "Attempt to update null custom script");
        String inum = customScript.getInum();
        log(logger, "Update custom script " + inum);
        CustomScript existingScript = customScriptService.getScriptByInum(customScript.getInum());
        if (existingScript != null) {
            customScript.setInum(existingScript.getInum());
            customScriptService.update(customScript);
            return Response.ok().build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 35 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class GluuRadiusConfigWebResource method isValidAcrValue.

private final boolean isValidAcrValue(String acrValue) {
    List<CustomScriptType> script_types = new ArrayList<CustomScriptType>();
    script_types.add(CustomScriptType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
    List<CustomScript> allowed_scripts = customScriptService.findCustomScripts(script_types);
    for (CustomScript custom_script : allowed_scripts) {
        if (!custom_script.isEnabled())
            continue;
        if (StringUtils.equals(custom_script.getName(), acrValue))
            return true;
    }
    return false;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) CustomScriptType(org.gluu.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList)

Aggregations

CustomScript (org.gluu.model.custom.script.model.CustomScript)42 ArrayList (java.util.ArrayList)20 AuthenticationCustomScript (org.gluu.model.custom.script.model.auth.AuthenticationCustomScript)11 CustomScriptType (org.gluu.model.custom.script.CustomScriptType)8 IOException (java.io.IOException)7 SimpleCustomProperty (org.gluu.model.SimpleCustomProperty)6 HttpEntity (org.apache.http.HttpEntity)5 HttpResponse (org.apache.http.HttpResponse)5 ParseException (org.apache.http.ParseException)5 SimpleExtendedCustomProperty (org.gluu.model.SimpleExtendedCustomProperty)5 Test (org.junit.Test)5 List (java.util.List)4 CustomScriptConfiguration (org.gluu.model.custom.script.conf.CustomScriptConfiguration)4 HttpGet (org.apache.http.client.methods.HttpGet)3 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)3 SelectableEntity (org.gluu.model.SelectableEntity)3 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)3 Filter (org.gluu.search.filter.Filter)3 Operation (io.swagger.v3.oas.annotations.Operation)2 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)2