components/global/core/io.cellery.observability.api/src/main/java/io/cellery/observability/api/auth/OIDCOauthManager.java
private JSONObject createClientWithDcr() throws OIDCProviderException {
        try {
            List<String> callbackUris = Collections.singletonList(CelleryConfig.getInstance().getDashboardURL());
            List<String> grants = Collections.singletonList(Constants.AUTHORIZATION_CODE);

            String dcrEp = CelleryConfig.getInstance().getIdpURL() + Constants.IDP_REGISTERATION_ENDPOINT;
            JSONObject clientJson = new JSONObject();
            clientJson.put(Constants.CALL_BACK_URL, callbackUris);
            clientJson.put(Constants.CLIENT_NAME, Constants.APPLICATION_NAME);
            clientJson.put(Constants.GRANT_TYPE, grants);
            clientJson.put(Constants.EXT_PARAM_CLIENT_ID, Constants.STANDARD_CLIENT_ID);
            StringEntity requestEntity = new StringEntity(clientJson.toString(), ContentType.APPLICATION_JSON);

            HttpPost request = new HttpPost(dcrEp);
            request.setHeader(Constants.AUTHORIZATION, getEncodedIdpAdminCredentials());
            request.setHeader(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON);
            request.setEntity(requestEntity);

            HttpClient client = Utils.getTrustAllClient();
            if (logger.isDebugEnabled()) {
                logger.debug("Creating new Client " + Constants.APPLICATION_NAME);
            }
            HttpResponse response = client.execute(request);
            return new JSONObject(EntityUtils.toString(response.getEntity()));
        } catch (IOException | ParseException | NoSuchAlgorithmException | KeyManagementException |
                ConfigurationException e) {
            throw new OIDCProviderException("Error occurred while registering client", e);
        }
    }
/**
     * Register a Client for the Observability Portal.
     *
     * @return the HttpPost object
     * @throws OIDCProviderException if the HTTP call for creating the Client fails
     */
Register a Client for the Observability Portal.
@return the HttpPost object
@throws OIDCProviderException if the HTTP call for creating the Client fails
Register a Client for the Observability Portal . @return the HttpPost object @throws OIDCProviderException if the HTTP call for creating the Client fails
private JSONObject createClientWithDcr() throws OIDCProviderException {
        try {
            List<String> callbackUris = Collections.singletonList(CelleryConfig.getInstance().getDashboardURL());
            List<String> grants = Collections.singletonList(Constants.AUTHORIZATION_CODE);
            String dcrEp = CelleryConfig.getInstance().getIdpURL() + Constants.IDP_REGISTERATION_ENDPOINT;
            JSONObject clientJson = new JSONObject();
            clientJson.put(Constants.CALL_BACK_URL, callbackUris);
            clientJson.put(Constants.CLIENT_NAME, Constants.APPLICATION_NAME);
            clientJson.put(Constants.GRANT_TYPE, grants);
            clientJson.put(Constants.EXT_PARAM_CLIENT_ID, Constants.STANDARD_CLIENT_ID);
            StringEntity requestEntity = new StringEntity(clientJson.toString(), ContentType.APPLICATION_JSON);
            HttpPost request = new HttpPost(dcrEp);
            request.setHeader(Constants.AUTHORIZATION, getEncodedIdpAdminCredentials());
            request.setHeader(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON);
            request.setEntity(requestEntity);
            HttpClient client = Utils.getTrustAllClient();
            if (logger.isDebugEnabled()) {
                logger.debug("Creating new Client " + Constants.APPLICATION_NAME);
            }
            HttpResponse response = client.execute(request);
            return new JSONObject(EntityUtils.toString(response.getEntity()));
        } catch (IOException | ParseException | NoSuchAlgorithmException | KeyManagementException |
                ConfigurationException e) {
            throw new OIDCProviderException("Error occurred while registering client", e);
        }
    }
private JSONObject createClientWithDcr ( ) throws OIDCProviderException { try { List < String > callbackUris = Collections . singletonList ( CelleryConfig . getInstance ( ) . getDashboardURL ( ) ) ; List < String > grants = Collections . singletonList ( Constants . AUTHORIZATION_CODE ) ; String dcrEp = CelleryConfig . getInstance ( ) . getIdpURL ( ) + Constants . IDP_REGISTERATION_ENDPOINT ; JSONObject clientJson = new JSONObject ( ) ; clientJson . put ( Constants . CALL_BACK_URL , callbackUris ) ; clientJson . put ( Constants . CLIENT_NAME , Constants . APPLICATION_NAME ) ; clientJson . put ( Constants . GRANT_TYPE , grants ) ; clientJson . put ( Constants . EXT_PARAM_CLIENT_ID , Constants . STANDARD_CLIENT_ID ) ; StringEntity requestEntity = new StringEntity ( clientJson . toString ( ) , ContentType . APPLICATION_JSON ) ; HttpPost request = new HttpPost ( dcrEp ) ; request . setHeader ( Constants . AUTHORIZATION , getEncodedIdpAdminCredentials ( ) ) ; request . setHeader ( Constants . CONTENT_TYPE , Constants . APPLICATION_JSON ) ; request . setEntity ( requestEntity ) ; HttpClient client = Utils . getTrustAllClient ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Creating new Client " + Constants . APPLICATION_NAME ) ; } HttpResponse response = client . execute ( request ) ; return new JSONObject ( EntityUtils . toString ( response . getEntity ( ) ) ) ; } catch ( IOException | ParseException | NoSuchAlgorithmException | KeyManagementException | ConfigurationException e ) { throw new OIDCProviderException ( "Error occurred while registering client" , e ) ; } }
Register a Client for the Observability Portal.
Register a Client for the Observability Portal .