use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AcrsResource method getDefaultAuthenticationMethod.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.ACRS_READ_ACCESS })
public Response getDefaultAuthenticationMethod() {
final GluuConfiguration gluuConfiguration = configurationService.findGluuConfiguration();
AuthenticationMethod authenticationMethod = new AuthenticationMethod();
authenticationMethod.setDefaultAcr(gluuConfiguration.getAuthenticationMode());
return Response.ok(authenticationMethod).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ClientsResource method updateClient.
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS })
public Response updateClient(@Valid Client client) throws EncryptionException {
if (logger.isDebugEnabled()) {
logger.debug("Client details to be updated - client:{}", escapeLog(client));
}
String inum = client.getClientId();
checkNotNull(inum, AttributeNames.INUM);
checkNotNull(client.getClientName(), AttributeNames.DISPLAY_NAME);
Client existingClient = clientService.getClientByInum(inum);
checkResourceNotNull(existingClient, OPENID_CONNECT_CLIENT);
client.setClientId(existingClient.getClientId());
client.setBaseDn(clientService.getDnForClient(inum));
client.setDeletable(client.getExpirationDate() != null);
if (client.getClientSecret() != null) {
client.setClientSecret(encryptionService.encrypt(client.getClientSecret()));
}
clientService.updateClient(client);
Client result = clientService.getClientByInum(existingClient.getClientId());
result.setClientSecret(encryptionService.decrypt(client.getClientSecret()));
return Response.ok(result).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ClientsResource method deleteClient.
@DELETE
@Path(ApiConstants.INUM_PATH)
@ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_DELETE_ACCESS })
public Response deleteClient(@PathParam(ApiConstants.INUM) @NotNull String inum) {
if (logger.isDebugEnabled()) {
logger.debug("Client to be deleted - inum:{} ", escapeLog(inum));
}
Client client = clientService.getClientByInum(inum);
checkResourceNotNull(client, OPENID_CONNECT_CLIENT);
clientService.removeClient(client);
return Response.noContent().build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ConfigSmtpResource method getSmtpServerConfiguration.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_READ_ACCESS })
public Response getSmtpServerConfiguration() {
SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
log.debug("getSmtpServerConfiguration() - smtpConfiguration = " + smtpConfiguration + "\n\n");
return Response.ok(Objects.requireNonNullElseGet(smtpConfiguration, SmtpConfiguration::new)).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ConfigSmtpResource method testSmtpConfiguration.
@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.SMTP_READ_ACCESS })
public Response testSmtpConfiguration() throws EncryptionException {
log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 1 - \n\n");
SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 1 - smtpConfiguration = " + smtpConfiguration + "\n\n");
smtpConfiguration.setPasswordDecrypted(encryptionService.decrypt(smtpConfiguration.getPassword()));
boolean status = mailService.sendMail(smtpConfiguration, smtpConfiguration.getFromEmailAddress(), smtpConfiguration.getFromName(), smtpConfiguration.getFromEmailAddress(), null, "SMTP Configuration verification", "Mail to test smtp configuration", "Mail to test smtp configuration");
log.debug("\n ConfigSmtpResource::testSmtpConfiguration() - 2 - status = " + status + "\n\n");
return Response.ok(status).build();
}
Aggregations