Search in sources :

Example 1 with RadiusClient

use of org.gluu.radius.model.RadiusClient in project oxTrust by GluuFederation.

the class SearchRadiusClientAction method search.

public String search() {
    if (this.oldSearchPattern != null && StringUtils.equals(this.searchPattern, this.oldSearchPattern))
        return OxTrustConstants.RESULT_SUCCESS;
    try {
        List<RadiusClient> radiusclients = null;
        if (searchPattern == null || searchPattern.isEmpty()) {
            radiusclients = gluuRadiusClientService.getAllClients(100);
        } else {
            radiusclients = gluuRadiusClientService.searchClients(searchPattern, 100);
        }
        radiusclients.sort(Comparator.comparing(RadiusClient::getName));
        this.results.clear();
        for (RadiusClient radiusclient : radiusclients) {
            this.results.add(new SelectableEntity<RadiusClient>(radiusclient));
        }
        this.oldSearchPattern = this.searchPattern;
        this.searchPattern = "";
    } catch (Exception e) {
        log.debug("Failed to find radius clients", e);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "#{msgs['radius.clients.search.error']}");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : RadiusClient(org.gluu.radius.model.RadiusClient)

Example 2 with RadiusClient

use of org.gluu.radius.model.RadiusClient in project oxTrust by GluuFederation.

the class UpdateRadiusClientAction method save.

public String save() {
    try {
        RadiusClient tmpclient = gluuRadiusClientService.getRadiusClientByInum(inum);
        if (client == null) {
            log.debug("Radius client " + inum + " not found.");
            return OxTrustConstants.RESULT_FAILURE;
        }
        if (client.getSecret() != null && !client.getSecret().isEmpty()) {
            String encsecret = encryptionService.encrypt(client.getSecret());
            client.setSecret(encsecret);
        } else {
            client.setSecret(tmpclient.getSecret());
        }
        client.setDn(tmpclient.getDn());
        client.setInum(tmpclient.getInum());
        gluuRadiusClientService.updateRadiusClient(client);
        facesMessages.add(FacesMessage.SEVERITY_INFO, "#{msgs['radius.client.update.success']}");
    } catch (Exception e) {
        log.debug("Could not update client " + inum, e);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "#{msgs['radius.client.update.error']}");
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : RadiusClient(org.gluu.radius.model.RadiusClient)

Example 3 with RadiusClient

use of org.gluu.radius.model.RadiusClient in project oxTrust by GluuFederation.

the class AddRadiusClientAction method start.

public void start() {
    client = new RadiusClient();
    client.setPriority(DEFAULT_PRIORITY);
}
Also used : RadiusClient(org.gluu.radius.model.RadiusClient)

Example 4 with RadiusClient

use of org.gluu.radius.model.RadiusClient in project oxTrust by GluuFederation.

the class GluuRadiusClientWebResource method updateRadiusClient.

@PUT
@Operation(summary = "Update existing radius client", description = "Update existing radius client")
@ApiResponses({ @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = RadiusClient.class)), description = "Success"), @ApiResponse(responseCode = "400", description = "Malformed Request. Missing parameter"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Radius client not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateRadiusClient(RadiusClient client) {
    try {
        if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
            return Response.status(Response.Status.FORBIDDEN).build();
        Objects.requireNonNull(client);
        if (client.getInum() == null)
            return Response.status(Response.Status.BAD_REQUEST).entity("Missing radius client inum").build();
        String inum = client.getInum();
        RadiusClient existingclient = gluuRadiusClientService.getRadiusClientByInum(inum);
        if (existingclient == null)
            return Response.status(Response.Status.NOT_FOUND).build();
        if (client.getIpAddress() != null)
            existingclient.setIpAddress(client.getIpAddress());
        if (client.getName() != null)
            existingclient.setName(client.getName());
        if (client.getPriority() != null)
            existingclient.setPriority(client.getPriority());
        if (client.getSecret() != null && !StringUtils.equals(client.getSecret(), existingclient.getSecret())) {
            String encryptedsecret = encryptionService.encrypt(client.getSecret());
            existingclient.setSecret(encryptedsecret);
        }
        gluuRadiusClientService.updateRadiusClient(existingclient);
        return Response.ok(gluuRadiusClientService.getRadiusClientByInum(inum)).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : RadiusClient(org.gluu.radius.model.RadiusClient) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 5 with RadiusClient

use of org.gluu.radius.model.RadiusClient in project oxTrust by GluuFederation.

the class GluuRadiusClientWebResource method deleteRadiusClient.

@DELETE
@Operation(summary = "Delete radius client", description = "Deletes a radius client")
@Path(ApiConstants.INUM_PARAM_PATH)
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Success"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Radius client not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteRadiusClient(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    try {
        if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
            return Response.status(Response.Status.FORBIDDEN).build();
        RadiusClient client = gluuRadiusClientService.getRadiusClientByInum(inum);
        if (client == null)
            return Response.status(Response.Status.NOT_FOUND).build();
        gluuRadiusClientService.deleteRadiusClient(client);
        return Response.status(Response.Status.NO_CONTENT).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : RadiusClient(org.gluu.radius.model.RadiusClient) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

RadiusClient (org.gluu.radius.model.RadiusClient)5 Operation (io.swagger.v3.oas.annotations.Operation)2 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)2 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)2