use of io.jans.as.common.model.registration.Client in project jans by JanssenProject.
the class CleanerTimerTest method client_whichIsExpiredAndNotDeletable_MustNotBeRemoved.
@Test
public void client_whichIsExpiredAndNotDeletable_MustNotBeRemoved() throws StringEncrypter.EncryptionException {
// 1. create client
final Client client = createClient(false);
try {
final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
client.setClientIdIssuedAt(calendar.getTime());
calendar.add(Calendar.HOUR, -1);
client.setExpirationDate(calendar.getTime());
clientService.persist(client);
// 2. client is in persistence
assertNotNull(clientService.getClient(client.getClientId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. client is in persistence (not removed)
assertNotNull(clientService.getClient(client.getClientId()));
} finally {
// make it available for cleaner
client.setDeletable(true);
clientService.merge(client);
}
}
use of io.jans.as.common.model.registration.Client in project jans by JanssenProject.
the class CleanerTimerTest method client_whichIsNotExpiredAndDeletable_MustNotBeRemoved.
@Test
public void client_whichIsNotExpiredAndDeletable_MustNotBeRemoved() throws StringEncrypter.EncryptionException {
// 1. create client
final Client client = createClient(true);
clientService.persist(client);
// 2. client is in persistence
assertNotNull(clientService.getClient(client.getClientId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. client is in persistence (not removed)
assertNotNull(clientService.getClient(client.getClientId()));
}
use of io.jans.as.common.model.registration.Client 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.as.common.model.registration.Client 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.as.common.model.registration.Client in project jans by JanssenProject.
the class DemoResource method getClient.
@GET
@Path(Constants.CLIENT + Constants.INUM_PATH)
public Response getClient(@PathParam(Constants.INUM) @NotNull String inum) {
log.debug("\n DemoResource::getClient() - log = " + log + " ,inum = " + inum + "\n\n");
Client client = utils.getClient(inum);
log.debug(" DemoResource::getClient() - client = " + client + "\n\n");
return Response.ok(client).build();
}
Aggregations