use of io.jans.as.common.model.registration.Client in project jans by JanssenProject.
the class AuthenticationService method configureSessionClient.
public Client configureSessionClient() {
String clientInum = credentials.getUsername();
log.debug("ConfigureSessionClient: username: '{}', credentials: '{}'", clientInum, System.identityHashCode(credentials));
Client client = clientService.getClient(clientInum);
configureSessionClient(client);
return client;
}
use of io.jans.as.common.model.registration.Client in project jans by JanssenProject.
the class ClientService method authenticate.
/**
* Authenticate client.
*
* @param clientId Client inum.
* @param password Client password.
* @return <code>true</code> if success, otherwise <code>false</code>.
*/
public boolean authenticate(String clientId, String password) {
log.debug("Authenticating Client with LDAP: clientId = {}", clientId);
boolean authenticated = false;
try {
Client client = getClient(clientId);
if (client == null) {
log.debug("Failed to find client = {}", clientId);
return authenticated;
}
String decryptedClientSecret = decryptSecret(client.getClientSecret());
authenticated = decryptedClientSecret != null && decryptedClientSecret.equals(password);
} catch (StringEncrypter.EncryptionException e) {
log.error(e.getMessage(), e);
}
return authenticated;
}
use of io.jans.as.common.model.registration.Client 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.as.common.model.registration.Client 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.as.common.model.registration.Client 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();
}
Aggregations