public GetAllCredentialsResponse getAllCredentialsFromJWTToken()

in services/src/main/java/org/apache/custos/service/credential/store/CredentialStoreService.java [513:566]


    public GetAllCredentialsResponse getAllCredentialsFromJWTToken(TokenRequest request) {
        try {
            String token = request.getToken();

            Credential credential = credentialManager.decodeJWTToken(token);
            if (credential == null || credential.getId() == null) {
                LOGGER.error("Invalid access token");
                throw new EntityNotFoundException("Invalid access token");
            }

            CredentialEntity entity = repository.findByClientId(credential.getId());

            if (entity == null) {
                LOGGER.error("Cannot find a CredentialEntity with the Id: " + credential.getId());
                throw new EntityNotFoundException("Cannot find a CredentialEntity with the Id: " + credential.getId());
            }

            String subPath = BASE_PATH + entity.getOwnerId();
            List<String> paths = vaultTemplate.list(subPath);

            List<CredentialMetadata> credentialMetadata = new ArrayList<>();

            if (paths != null && !paths.isEmpty()) {
                for (String key : paths) {
                    if (isMainType(key)) {
                        String path = subPath + "/" + key;
                        VaultResponseSupport<Credential> crRe = vaultTemplate.read(path, Credential.class);
                        CredentialMetadata metadata = convertToCredentialMetadata(crRe.getData(), entity.getOwnerId(), key);

                        if (key.equals(Type.CUSTOS.name())) {
                            metadata = metadata.toBuilder()
                                    .setClientIdIssuedAt(entity.getIssuedAt().getTime())
                                    .setClientSecretExpiredAt(entity.getClientSecretExpiredAt())
                                    .setSuperAdmin(credential.isAdmin())
                                    .setSuperTenant(crRe.getData().isSuperTenant())
                                    .build();
                        }
                        credentialMetadata.add(metadata);
                    }
                }
            }

            return GetAllCredentialsResponse.newBuilder()
                    .addAllSecretList(credentialMetadata)
                    .setRequesterUserEmail(credential.getEmail())
                    .setRequesterUsername(credential.getUsername())
                    .build();

        } catch (Exception ex) {
            String msg = "Operation failed  " + ex.getMessage();
            LOGGER.error(msg);
            throw new InternalServerException(msg, ex);
        }
    }