/** * Sets the apiKey ID that will be used when authenticating the client requests to the Stormpath REST API. If * unspecified, property value lookup heuristics will be used to find the apiKeyId value. * * @param id the apiKey ID that will be used when authenticating the client requests to the Stormpath REST API. */ public void setId(String id) { builder.setId(id); }
/** * Sets the apiKey ID that will be used when authenticating the client requests to the Stormpath REST API. If * unspecified, property value lookup heuristics will be used to find the apiKeyId value. * * @param id the apiKey ID that will be used when authenticating the client requests to the Stormpath REST API. */ public void setId(String id) { builder.setId(id); }
@Autowired public void oktaOidcClientApiKey(@Qualifier("stormpathClientApiKey") ApiKey stormpathClientApiKey) { if (oktaEnabled) { Assert.hasText(oktaApplicationId, "When okta.enabled is true, okta.application.id " + "must be configured with your Okta Application ID. This can be found in the URL when accessing " + "you application in a browser."); Client client = stormpathClient(); String applicationCredentialsHref = "/api/v1/internal/apps/" + oktaApplicationId + "/settings/clientcreds"; ApplicationCredentials applicationCredentials = client.getResource(applicationCredentialsHref, ApplicationCredentials.class); ApiKey secondary = ApiKeys.builder() .setId(applicationCredentials.getClientId()) .setSecret(applicationCredentials.getClientSecret()) .build(); ((PairedApiKey)stormpathClientApiKey).setSecondaryApiKey(secondary); } }
@Autowired public void oktaOidcClientApiKey(@Qualifier("stormpathClientApiKey") ApiKey stormpathClientApiKey) { if (oktaEnabled) { Assert.hasText(oktaApplicationId, "When okta.enabled is true, okta.application.id " + "must be configured with your Okta Application ID. This can be found in the URL when accessing " + "you application in a browser."); Client client = stormpathClient(); String applicationCredentialsHref = "/api/v1/internal/apps/" + oktaApplicationId + "/settings/clientcreds"; ApplicationCredentials applicationCredentials = client.getResource(applicationCredentialsHref, ApplicationCredentials.class); ApiKey secondary = ApiKeys.builder() .setId(applicationCredentials.getClientId()) .setSecret(applicationCredentials.getClientSecret()) .build(); ((PairedApiKey)stormpathClientApiKey).setSecondaryApiKey(secondary); } }
@Bean public ApiKey stormpathClientApiKey() { ApiKeyBuilder builder = ApiKeys.builder(); String twoAppApiKeyId = System.getenv(twoAppApiKeyIdEnvName); String twoAppApiKeySecret = System.getenv(twoAppApiKeySecretEnvName); if (Strings.hasText(twoAppApiKeyId) && Strings.hasText(twoAppApiKeySecret)) { builder.setId(twoAppApiKeyId).setSecret(twoAppApiKeySecret); } else { log.warn( "Using TwoAppTenantStormpathConfiguration and " + "no " + twoAppApiKeyIdEnvName + " and/or " + twoAppApiKeySecretEnvName + " set" ); } return builder.build(); }
protected Client postConfigure(Client client) { if (isOktaEnabled()) { String oktaApplicationId = config.get("okta.application.id"); Assert.hasText(oktaApplicationId, "When okta.enabled is true, okta.application.id " + "must be configured with your Okta Application ID. This can be found in the URL when accessing " + "you application in a browser."); String applicationCredentialsHref = "/api/v1/internal/apps/" + oktaApplicationId + "/settings/clientcreds"; ApplicationCredentials applicationCredentials = client.getResource(applicationCredentialsHref, ApplicationCredentials.class); ApiKey secondary = ApiKeys.builder() .setId(applicationCredentials.getClientId()) .setSecret(applicationCredentials.getClientSecret()) .build(); ((PairedApiKey)client.getApiKey()).setSecondaryApiKey(secondary); } return client; }
protected Client postConfigure(Client client) { if (isOktaEnabled()) { String oktaApplicationId = config.get("okta.application.id"); Assert.hasText(oktaApplicationId, "When okta.enabled is true, okta.application.id " + "must be configured with your Okta Application ID. This can be found in the URL when accessing " + "you application in a browser."); String applicationCredentialsHref = "/api/v1/internal/apps/" + oktaApplicationId + "/settings/clientcreds"; ApplicationCredentials applicationCredentials = client.getResource(applicationCredentialsHref, ApplicationCredentials.class); ApiKey secondary = ApiKeys.builder() .setId(applicationCredentials.getClientId()) .setSecret(applicationCredentials.getClientSecret()) .build(); ((PairedApiKey)client.getApiKey()).setSecondaryApiKey(secondary); } return client; }
@Override @SuppressWarnings("PMD.NPathComplexity") protected ApiKey createApiKey() { ApiKeyBuilder apiKeyBuilder = ApiKeys.builder(); Config config = getConfig(); String value = Strings.hasText(apiKeyId) ? apiKeyId : config.get("stormpath.client.apiKey.id"); if (Strings.hasText(value)) { apiKeyBuilder.setId(value); } //check for API Key ID embedded in the properties configuration value = Strings.hasText(apiKeySecret) ? apiKeySecret : config.get("stormpath.client.apiKey.secret"); if (Strings.hasText(value)) { apiKeyBuilder.setSecret(value); } value = Strings.hasText(apiKeyFileLocation) ? apiKeyFileLocation : config.get(STORMPATH_API_KEY_FILE); if (Strings.hasText(value)) { apiKeyBuilder.setFileLocation(value); } return apiKeyBuilder.build(); }
protected ApiKey createApiKey() { if (isOktaEnabled()) { String oktaToken = config.get("okta.api.token"); Assert.hasText(oktaToken, "'okta.api.token' is required when 'okta.enable' is true"); // TODO: duplicate code from spring config return new DefaultPairedApiKey(new ClientApiKey("okta_api_token", oktaToken)); } else { ApiKeyBuilder apiKeyBuilder = ApiKeys.builder(); String value = config.get("stormpath.client.apiKey.id"); if (Strings.hasText(value)) { apiKeyBuilder.setId(value); } //check for API Key ID embedded in the properties configuration value = config.get("stormpath.client.apiKey.secret"); if (Strings.hasText(value)) { apiKeyBuilder.setSecret(value); } value = config.get(STORMPATH_API_KEY_FILE); if (Strings.hasText(value)) { apiKeyBuilder.setFileLocation(value); } return apiKeyBuilder.build(); } }
protected ApiKey createApiKey() { if (isOktaEnabled()) { String oktaToken = config.get("okta.api.token"); Assert.hasText(oktaToken, "'okta.api.token' is required when 'okta.enable' is true"); // TODO: duplicate code from spring config return new DefaultPairedApiKey(new ClientApiKey("okta_api_token", oktaToken)); } else { ApiKeyBuilder apiKeyBuilder = ApiKeys.builder(); String value = config.get("stormpath.client.apiKey.id"); if (Strings.hasText(value)) { apiKeyBuilder.setId(value); } //check for API Key ID embedded in the properties configuration value = config.get("stormpath.client.apiKey.secret"); if (Strings.hasText(value)) { apiKeyBuilder.setSecret(value); } value = config.get(STORMPATH_API_KEY_FILE); if (Strings.hasText(value)) { apiKeyBuilder.setFileLocation(value); } return apiKeyBuilder.build(); } }