protected Cache getGatewayKeyCache() { String apimGWCacheExpiry = ServiceReferenceHolder.getInstance() .getAPIManagerConfiguration() .getFirstProperty(APIConstants.TOKEN_CACHE_EXPIRY); if (!gatewayKeyCacheInit) { gatewayKeyCacheInit = true; if (apimGWCacheExpiry != null) { return APIUtil.getCache( APIConstants.API_MANAGER_CACHE_MANAGER, APIConstants.GATEWAY_KEY_CACHE_NAME, Long.parseLong(apimGWCacheExpiry), Long.parseLong(apimGWCacheExpiry)); } else { long defaultCacheTimeout = Long.valueOf( ServerConfiguration.getInstance() .getFirstProperty(APIConstants.DEFAULT_CACHE_TIMEOUT)) * 60; return APIUtil.getCache( APIConstants.API_MANAGER_CACHE_MANAGER, APIConstants.GATEWAY_KEY_CACHE_NAME, defaultCacheTimeout, defaultCacheTimeout); } } return Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER) .getCache(APIConstants.GATEWAY_KEY_CACHE_NAME); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", justification = "It is required to set two options on the Options object") public APIKeyValidatorClient() throws APISecurityException { APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration(); String serviceURL = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_URL); username = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_USERNAME); password = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_PASSWORD); if (serviceURL == null || username == null || password == null) { throw new APISecurityException( APISecurityConstants.API_AUTH_GENERAL_ERROR, "Required connection details for the key management server not provided"); } try { ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null); keyValidationServiceStub = new APIKeyValidationServiceStub(ctx, serviceURL + "APIKeyValidationService"); ServiceClient client = keyValidationServiceStub._getServiceClient(); Options options = client.getOptions(); options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS); options.setCallTransportCleanup(true); options.setManageSession(true); } catch (AxisFault axisFault) { throw new APISecurityException( APISecurityConstants.API_AUTH_GENERAL_ERROR, "Error while initializing the API key validation stub", axisFault); } }
public APIKeyValidatorClient() throws APISecurityException { APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration(); String serviceURL = config.getFirstProperty(APIConstants.API_KEY_MANAGER_URL); username = config.getFirstProperty(APIConstants.API_KEY_MANAGER_USERNAME); password = config.getFirstProperty(APIConstants.API_KEY_MANAGER_PASSWORD); if (serviceURL == null || username == null || password == null) { throw new APISecurityException( APISecurityConstants.API_AUTH_GENERAL_ERROR, "Required connection details for the key management server not provided"); } try { clientStub = new APIKeyValidationServiceStub(null, serviceURL + "APIKeyValidationService"); ServiceClient client = clientStub._getServiceClient(); Options options = client.getOptions(); options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS); options.setCallTransportCleanup(true); options.setManageSession(true); } catch (AxisFault axisFault) { throw new APISecurityException( APISecurityConstants.API_AUTH_GENERAL_ERROR, "Error while initializing the API key validation stub", axisFault); } }
public boolean isAPIResourceValidationEnabled() { try { APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration(); String serviceURL = config.getFirstProperty(APIConstants.GATEWAY_RESOURCE_CACHE_ENABLED); return Boolean.parseBoolean(serviceURL); } catch (Exception e) { log.error( "Did not found valid API Resource Validation Information cache configuration. Use default configuration" + e); } return true; }
public boolean isGatewayTokenCacheEnabled() { try { APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration(); String cacheEnabled = config.getFirstProperty(APIConstants.GATEWAY_TOKEN_CACHE_ENABLED); return Boolean.parseBoolean(cacheEnabled); } catch (Exception e) { log.error( "Did not found valid API Validation Information cache configuration. Use default configuration" + e); } return true; }