/** * Update an oAuth application owner * * @param appInfoDTO accept an appinfoDTO object * @return OAuthApplicationInfo this object will contain all the properties of updated oAuth application */ default OAuthApplicationInfo updateApplicationOwner(OAuthAppRequest appInfoDTO, String owner) throws APIManagementException { throw new APIManagementException("This is not supported"); }
/** * This method find the list of API published by particular Pulisher * @param providerId Provider username * @return list of APIs * @throws APIMgtUsageQueryServiceClientException throws if error occurred */ private List<API> getAPIsByProvider(String providerId) throws APIMgtUsageQueryServiceClientException { try { if (APIUsageStatisticsClientConstants.ALL_PROVIDERS.equals(providerId)) { return apiProviderImpl.getAllAPIs(); } else { return apiProviderImpl.getAPIsByProvider(providerId); } } catch (APIManagementException e) { log.error("Error while retrieving APIs by " + providerId, e); throw new APIMgtUsageQueryServiceClientException("Error while retrieving APIs by " + providerId, e); } }
/** * Converts a Quota Policy object into a Throttle Limit DTO object * * @param quotaPolicy Quota Policy object * @return Throttle Limit DTO object derived from the Quota Policy object * @throws UnsupportedThrottleLimitTypeException */ public static ThrottleLimitDTO fromQuotaPolicyToDTO(QuotaPolicy quotaPolicy) throws UnsupportedThrottleLimitTypeException { if (PolicyConstants.REQUEST_COUNT_TYPE.equals(quotaPolicy.getType())) { RequestCountLimit requestCountLimit = (RequestCountLimit) quotaPolicy.getLimit(); return fromRequestCountLimitToDTO(requestCountLimit); } else if (PolicyConstants.BANDWIDTH_TYPE.equals(quotaPolicy.getType())) { BandwidthLimit bandwidthLimit = (BandwidthLimit) quotaPolicy.getLimit(); return fromBandwidthLimitToDTO(bandwidthLimit); } else { String msg = "Throttle limit type " + quotaPolicy.getType() + " is not supported"; log.error(msg); throw new UnsupportedThrottleLimitTypeException(msg); } }
public boolean deleteApi(String apiProviderName, String apiName, String version) throws AxisFault { RESTAPIAdminClient restClient = getRestapiAdminClient(apiProviderName, apiName, version); // Delete secure vault alias properties if exists try { deleteRegistryProperty(apiProviderName, apiName, version, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); } catch (APIManagementException e) { String msg = "Failed to delete secure endpoint password alias " + e.getMessage(); throw new AxisFault(msg, e); } return restClient.deleteApi(); }
/** * Converts a Throttle Condition DTO object into a Condition model object * * @param dto Throttle Condition DTO object * @return Derived Condition model object from DTO * @throws UnsupportedThrottleConditionTypeException */ public static Condition fromDTOToCondition(ThrottleConditionDTO dto) throws UnsupportedThrottleConditionTypeException { if (dto instanceof IPConditionDTO) { return fromDTOToIPCondition((IPConditionDTO) dto); } else if (dto instanceof HeaderConditionDTO) { return fromDTOToHeaderCondition((HeaderConditionDTO) dto); } else if (dto instanceof QueryParameterConditionDTO) { return fromDTOToQueryParameterCondition((QueryParameterConditionDTO) dto); } else if (dto instanceof JWTClaimsConditionDTO) { return fromDTOToJWTClaimsCondition((JWTClaimsConditionDTO) dto); } else { String msg = "Throttle Condition type " + dto.getClass().getName() + " is not supported"; log.error(msg); throw new UnsupportedThrottleConditionTypeException(msg); } }
/** * Converts a Throttle Limit DTO object into a Limit object * * @param dto Throttle Limit DTO object * @return Limit object derived from DTO * @throws UnsupportedThrottleLimitTypeException */ public static Limit fromDTOToLimit(ThrottleLimitDTO dto) throws UnsupportedThrottleLimitTypeException { if (dto instanceof BandwidthLimitDTO) { return fromDTOToBandwidthLimit((BandwidthLimitDTO) dto); } else if (dto instanceof RequestCountLimitDTO) { return fromDTOToRequestCountLimit((RequestCountLimitDTO) dto); } else { String msg = "Throttle limit type " + dto.getClass().getName() + " is not supported"; log.error(msg); throw new UnsupportedThrottleLimitTypeException(msg); } }
public APIIdentifier(String apiId) throws APIManagementException { //eg: apiId = "P1_API1_v1.0.0" String[] split = apiId.split("_"); if (split.length == 3) { this.providerName = split[0]; this.apiName = split[1]; this.version = split[2]; } else { throw new APIManagementException("Invalid API ID : " + apiId); } }
/** * Delete the API from Gateway * * @param tenantDomain * @throws AxisFault */ public boolean deleteApiForTenant(String apiProviderName, String apiName, String version, String tenantDomain) throws AxisFault { RESTAPIAdminClient restClient = getRestapiAdminClient(apiProviderName, apiName, version); // Delete secure vault alias properties if exists try { deleteRegistryProperty(apiProviderName, apiName, version, tenantDomain); } catch (APIManagementException e) { String msg = "Failed to delete secure endpoint password alias " + e.getMessage(); throw new AxisFault(msg, e); } return restClient.deleteApi(tenantDomain); }
/** * This method find the list of API published by particular Pulisher * * @param providerId Provider username * @return list of APIs * @throws APIMgtUsageQueryServiceClientException throws if error occurred */ private List<API> getAPIsByProvider(String providerId) throws APIMgtUsageQueryServiceClientException { try { if (APIUsageStatisticsClientConstants.ALL_PROVIDERS.equals(providerId)) { return apiProviderImpl.getAllAPIs(); } else { return apiProviderImpl.getAPIsByProvider(providerId); } } catch (APIManagementException e) { log.error("Error while retrieving APIs by " + providerId, e); throw new APIMgtUsageQueryServiceClientException("Error while retrieving APIs by " + providerId, e); } }
/** * Converts a Throttle Condition model object into a DTO * * @param condition Throttle condition model object * @return Derived DTO object from the model object * @throws UnsupportedThrottleConditionTypeException */ public static ThrottleConditionDTO fromConditionToDTO(Condition condition) //................. throws UnsupportedThrottleConditionTypeException { if (condition instanceof IPCondition) { return fromIPConditionToDTO((IPCondition) condition); } else if (condition instanceof HeaderCondition) { return fromHeaderConditionToDTO((HeaderCondition) condition); } else if (condition instanceof QueryParameterCondition) { return fromQueryParameterConditionToDTO((QueryParameterCondition) condition); } else if (condition instanceof JWTClaimsCondition) { return fromJWTClaimsConditionToDTO((JWTClaimsCondition) condition); } else { String msg = "Throttle Condition type " + condition.getClass().getName() + " is not supported"; log.error(msg); throw new UnsupportedThrottleConditionTypeException(msg); } }
/** * logs the error message and throws an exception * * @param message Error message * @param throwable * @throws APIManagementException */ private static void handleException(String message, Throwable throwable) throws APIManagementException { log.error(message, throwable); throw new APIManagementException(throwable); }
/** * encrypt the plain text password * * @param plainTextPass * plain text password * @return encrypted password * @throws APIManagementException */ public String doEncryption(String tenantDomain, String secureVaultAlias, String plainTextPass) throws AxisFault { MediationSecurityAdminServiceClient client = getMediationSecurityAdminServiceClient(); String encodedValue; try { encodedValue = client.doEncryption(plainTextPass); setRegistryProperty(tenantDomain, secureVaultAlias, encodedValue); } catch (APIManagementException e) { String msg = "Failed to encrypt and store the secured endpoint password, " + e.getMessage(); throw new AxisFault(msg, e); } return encodedValue; }
/** * common method to throw exceptions. * * @param msg this parameter contain error message that we need to throw. * @param e Exception object. * @throws org.wso2.carbon.apimgt.api.APIManagementException */ private void handleException(String msg, Exception e) throws APIManagementException { log.error(msg, e); throw new APIManagementException(msg, e); }
private static void handleException(String msg, Throwable t) throws APIManagementException { log.error(msg, t); throw new APIManagementException(msg, t); }
private void handleException(String msg, Throwable t) throws APIManagementException { log.error(msg, t); throw new APIManagementException(msg, t); }
/** * encrypt the plain text password * * @param cipher * init cipher * @param plainTextPass * plain text password * @return encrypted password * @throws APIManagementException */ public String doEncryption(String plainTextPass) throws APIManagementException { String encodedValue = null; try { encodedValue = mediationSecurityAdminServiceStub.doEncrypt(plainTextPass); // encodedValue = CryptoUtil.getDefaultCryptoUtil() // .encryptAndBase64Encode(plainTextPass.getBytes()); //why ESB can not use this? } catch (Exception e) { String msg = "Failed to encrypt the secured endpoint password, " + e.getMessage(); throw new APIManagementException(msg, e); } return encodedValue; }
/** * This method will publish event for alert types configurations. * @param alertTypeDTO DTO object. * @throws APIManagementException */ @Override public void publishEvent(AlertTypeDTO alertTypeDTO) throws APIManagementException { DataBridgeAlertTypesPublisherDTO dataBridgeAlertTypesPublisherDTO = new DataBridgeAlertTypesPublisherDTO(alertTypeDTO); try { String streamID = DataPublisherUtil.getApiManagerAnalyticsConfiguration().getAlertTypeStreamName() + ":" + DataPublisherUtil.getApiManagerAnalyticsConfiguration().getAlertTypeStreamVersion(); dataPublisher.tryPublish(streamID,System.currentTimeMillis(), null, null, (Object[]) dataBridgeAlertTypesPublisherDTO.createPayload()); } catch (Exception e) { log.error("Error while publishing alert types events.", e); throw new APIManagementException("Error while publishing alert types events"); } }
/** * Get the config system registry for tenants * * @param tenantDomain - The tenant domain * @return - A UserRegistry instance for the tenant * @throws APIManagementException */ public static UserRegistry getRegistry(String tenantDomain) throws APIManagementException { PrivilegedCarbonContext.startTenantFlow(); if (tenantDomain != null && StringUtils.isNotEmpty(tenantDomain)) { PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); } else { PrivilegedCarbonContext.getThreadLocalCarbonContext() .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); } int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); UserRegistry registry; try { registry = RegistryServiceHolder.getInstance().getRegistryService().getConfigSystemRegistry(tenantId); } catch (RegistryException e) { String msg = "Failed to get registry instance for the tenant : " + tenantDomain + e.getMessage(); throw new APIManagementException(msg, e); } finally { PrivilegedCarbonContext.endTenantFlow(); } return registry; }
throw new APIManagementException("Error while reading registry resource " + path + " for tenant " + tenantDomain); } finally {
resource.discard(); } catch (RegistryException e) { throw new APIManagementException("Error while reading registry resource " + path + " for tenant " + tenantDomain); } finally {