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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations