Skip to content

Commit

Permalink
fix(jans-config-api): create openid client throwing 502 (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
pujavs authored Mar 9, 2022
1 parent 5353ad9 commit 3f58aff
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static io.jans.as.model.util.Util.escapeLog;
import io.jans.as.common.model.registration.Client;
import io.jans.as.common.service.common.EncryptionService;
import io.jans.as.common.service.common.InumService;
import io.jans.configapi.core.rest.ProtectedApi;
import io.jans.configapi.rest.model.SearchRequest;
import io.jans.configapi.service.auth.ClientService;
Expand All @@ -33,6 +34,7 @@
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.slf4j.Logger;

Expand All @@ -54,6 +56,9 @@ public class ClientsResource extends BaseResource {

@Inject
ClientService clientService;

@Inject
private InumService inumService;

@Inject
EncryptionService encryptionService;
Expand Down Expand Up @@ -100,7 +105,7 @@ public Response createOpenIdConnect(@Valid Client client) throws NoSuchAlgorithm
}
String inum = client.getClientId();
if (inum == null || inum.isEmpty() || inum.isBlank()) {
inum = clientService.generateInumForNewClient();
inum = inumService.generateClientInum();
client.setClientId(inum);
}
checkNotNull(client.getClientName(), AttributeNames.DISPLAY_NAME);
Expand Down Expand Up @@ -185,11 +190,7 @@ private List<Client> getClients(List<Client> clients) throws EncryptionException
}

private String generatePassword() throws NoSuchAlgorithmException {
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
SecureRandom secureRandom = SecureRandom.getInstanceStrong();
return secureRandom.ints(12, 0, characters.length()).mapToObj(characters::charAt)
.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();

return UUID.randomUUID().toString();
}

private List<Client> doSearch(SearchRequest searchReq) {
Expand Down

0 comments on commit 3f58aff

Please sign in to comment.