Search in sources :

Example 11 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ClientsResource method patchClient.

@PATCH
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS })
@Path(ApiConstants.INUM_PATH)
public Response patchClient(@PathParam(ApiConstants.INUM) @NotNull String inum, @NotNull String pathString) throws JsonPatchException, IOException {
    if (logger.isDebugEnabled()) {
        logger.debug("Client details to be patched - inum:{}, pathString:{}", escapeLog(inum), escapeLog(pathString));
    }
    Client existingClient = clientService.getClientByInum(inum);
    checkResourceNotNull(existingClient, OPENID_CONNECT_CLIENT);
    existingClient = Jackson.applyPatch(pathString, existingClient);
    clientService.updateClient(existingClient);
    return Response.ok(existingClient).build();
}
Also used : Client(io.jans.as.common.model.registration.Client) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 12 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ClientsResource method getOpenIdClientByInum.

@GET
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_READ_ACCESS })
@Path(ApiConstants.INUM_PATH)
public Response getOpenIdClientByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    if (logger.isDebugEnabled()) {
        logger.debug("Client serach by inum:{}", escapeLog(inum));
    }
    Client client = clientService.getClientByInum(inum);
    checkResourceNotNull(client, OPENID_CONNECT_CLIENT);
    return Response.ok(client).build();
}
Also used : Client(io.jans.as.common.model.registration.Client) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 13 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ClientsResource method createOpenIdConnect.

@POST
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS })
public Response createOpenIdConnect(@Valid Client client) throws NoSuchAlgorithmException, EncryptionException {
    if (logger.isDebugEnabled()) {
        logger.debug("Client details to be added - client:{}", escapeLog(client));
    }
    String inum = client.getClientId();
    if (inum == null || inum.isEmpty() || inum.isBlank()) {
        inum = inumService.generateClientInum();
        client.setClientId(inum);
    }
    checkNotNull(client.getClientName(), AttributeNames.DISPLAY_NAME);
    String clientSecret = client.getClientSecret();
    if (StringHelper.isEmpty(clientSecret)) {
        clientSecret = generatePassword();
    }
    client.setClientSecret(encryptionService.encrypt(clientSecret));
    client.setDn(clientService.getDnForClient(inum));
    client.setDeletable(client.getClientSecretExpiresAt() != null);
    clientService.addClient(client);
    Client result = clientService.getClientByInum(inum);
    result.setClientSecret(encryptionService.decrypt(result.getClientSecret()));
    return Response.status(Response.Status.CREATED).entity(result).build();
}
Also used : Client(io.jans.as.common.model.registration.Client) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 14 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ClientsResource method getOpenIdConnectClients.

@GET
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_READ_ACCESS })
public Response getOpenIdConnectClients(@DefaultValue(DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, @DefaultValue("") @QueryParam(value = ApiConstants.PATTERN) String pattern, @DefaultValue(DEFAULT_LIST_START_INDEX) @QueryParam(value = ApiConstants.START_INDEX) int startIndex, @QueryParam(value = ApiConstants.SORT_BY) String sortBy, @QueryParam(value = ApiConstants.SORT_ORDER) String sortOrder) throws EncryptionException {
    if (logger.isDebugEnabled()) {
        logger.debug("Client serach param - limit:{}, pattern:{}, startIndex:{}, sortBy:{}, sortOrder:{}", escapeLog(limit), escapeLog(pattern), escapeLog(startIndex), escapeLog(sortBy), escapeLog(sortOrder));
    }
    SearchRequest searchReq = createSearchRequest(clientService.getDnForClient(null), pattern, sortBy, sortOrder, startIndex, limit, null, null);
    final List<Client> clients = this.doSearch(searchReq);
    log.trace("Client serach result:{}", clients);
    return Response.ok(getClients(clients)).build();
}
Also used : SearchRequest(io.jans.configapi.rest.model.SearchRequest) Client(io.jans.as.common.model.registration.Client) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 15 with ProtectedApi

use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.

the class ConfigSmtpResource method setupSmtpConfiguration.

@POST
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_WRITE_ACCESS })
public Response setupSmtpConfiguration(@Valid SmtpConfiguration smtpConfiguration) throws EncryptionException {
    log.debug("setupSmtpConfiguration() - 1 - smtpConfiguration = " + smtpConfiguration + "\n\n");
    String password = smtpConfiguration.getPassword();
    if (password != null && !password.isEmpty()) {
        smtpConfiguration.setPassword(encryptionService.encrypt(password));
    }
    log.debug("setupSmtpConfiguration() - 2 - smtpConfiguration = " + smtpConfiguration + "\n\n");
    GluuConfiguration configurationUpdate = configurationService.getConfiguration();
    log.debug("setupSmtpConfiguration() - 1 - configurationUpdate = " + configurationUpdate + "\n\n");
    configurationUpdate.setSmtpConfiguration(smtpConfiguration);
    configurationService.updateConfiguration(configurationUpdate);
    return Response.status(Response.Status.CREATED).entity(configurationService.getConfiguration().getSmtpConfiguration()).build();
}
Also used : GluuConfiguration(io.jans.as.persistence.model.configuration.GluuConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Aggregations

ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)52 Client (io.jans.as.common.model.registration.Client)6 Conf (io.jans.as.model.config.Conf)6 Scope (io.jans.as.persistence.model.Scope)5 GluuConfiguration (io.jans.as.persistence.model.configuration.GluuConfiguration)5 GluuAttribute (io.jans.model.GluuAttribute)5 WebKeysConfiguration (io.jans.as.model.config.WebKeysConfiguration)4 UmaResource (io.jans.as.model.uma.persistence.UmaResource)3 SmtpConfiguration (io.jans.model.SmtpConfiguration)3 CustomScript (io.jans.model.custom.script.model.CustomScript)3 AppConfiguration (io.jans.as.model.configuration.AppConfiguration)2 JSONWebKey (io.jans.as.model.jwk.JSONWebKey)2 LicenseResponse (io.jans.ca.plugin.adminui.model.auth.LicenseResponse)2 ApplicationException (io.jans.ca.plugin.adminui.model.exception.ApplicationException)2 ScimAppConfiguration (io.jans.configapi.plugin.scim.model.config.ScimAppConfiguration)2 Properties (java.util.Properties)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GluuOrganization (io.jans.as.persistence.model.GluuOrganization)1 OAuth2ConfigResponse (io.jans.ca.plugin.adminui.model.auth.OAuth2ConfigResponse)1 AUIConfiguration (io.jans.ca.plugin.adminui.model.config.AUIConfiguration)1