diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 52a1925df6..50bd278fe6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -118,9 +118,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe for (String tag: tags) { Map queryParams = new HashMap<>(); + Map headerParams = new HashMap<>(); queryParams.put("tag", tag); if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams); + consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); } else { //call All API getting call with carbon super header param } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index d628c4ce25..5b19bf9e3c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -26,6 +26,12 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException; + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 05ecf1fd9e..7209041ad6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; + import java.io.IOException; public class APIApplicationServicesImpl implements APIApplicationServices { @@ -78,6 +79,38 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } } + @Override + public APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException { + + String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("callbackUrl", Constants.EMPTY_STRING); + jsonObject.put("clientName", username); + jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("owner", username); + jsonObject.put("saasApp", true); + + RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); + Request request = new Request.Builder() + .url(applicationEndpoint) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(username, password)) + .post(requestBody) + .build(); + try { + Response response = client.newCall(request).execute(); + return gson.fromJson(response.body().string(), APIApplicationKey.class); + } catch (IOException e) { + msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(e); + } + } + @Override public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) throws APIServicesException { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 0dd8783663..e908e60ffd 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -18,47 +18,52 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; -import org.json.JSONObject; import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam) + APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParam, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 383098dd3d..cec4a927fe 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -19,9 +19,11 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; @@ -33,6 +35,7 @@ import okhttp3.*; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; import org.json.JSONObject; import java.io.IOException; @@ -51,7 +54,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + public Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; @@ -65,8 +68,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -89,6 +92,45 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + Request request = new Request.Builder() + .url(getAllApplicationsUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getDetailsOfAnApplication(apiApplicationKey, refreshedAccessToken, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) @@ -141,8 +183,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; @@ -156,8 +198,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -181,8 +223,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams) + public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -191,25 +233,28 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); } - Request request = new Request.Builder() - .url(getAPIsURL) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .get() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(getAPIsURL); + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()); + for (Map.Entry header : headerParams.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count - return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams); + return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams, headerParams); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -227,7 +272,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; @@ -274,8 +319,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + public Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; @@ -293,7 +338,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), Subscription.class); + JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -364,7 +410,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + public KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; @@ -378,8 +424,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java new file mode 100644 index 0000000000..f18647899f --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; +import org.json.JSONObject; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * This class represents the Consumer API Information. + */ + +public class APIInfo { + + private String id; + private String name; + private String description; + private String context; + private String version; + private String provider; + private JSONObject apiDefinition; + private String wsdlUri; + private String lifeCycleStatus; + private boolean isDefaultVersion; + private String type; + private Set transport; + private List operations; + private String authorizationHeader; + private String securityScheme; + private Set tags; + private List tiers; + private boolean hasThumbnail; + private String additionalProperties; + private JSONObject monetization; + private List endpointURLs; + private JSONObject businessInformation; + private List environmentList; + private List scopes; + private String avgRating; + private JSONObject advertiseInfo; + private boolean isSubscriptionAvailable; + private List categories; + private List keyManagers = new ArrayList(); + private String createdTime; + private String lastUpdatedTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public JSONObject getApiDefinition() { + return apiDefinition; + } + + public void setApiDefinition(JSONObject apiDefinition) { + this.apiDefinition = apiDefinition; + } + + public String getWsdlUri() { + return wsdlUri; + } + + public void setWsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + } + + public String getLifeCycleStatus() { + return lifeCycleStatus; + } + + public void setLifeCycleStatus(String lifeCycleStatus) { + this.lifeCycleStatus = lifeCycleStatus; + } + + public boolean isDefaultVersion() { + return isDefaultVersion; + } + + public void setDefaultVersion(boolean defaultVersion) { + isDefaultVersion = defaultVersion; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Set getTransport() { + return transport; + } + + public void setTransport(Set transport) { + this.transport = transport; + } + + public List getOperations() { + return operations; + } + + public void setOperations(List operations) { + this.operations = operations; + } + + public String getAuthorizationHeader() { + return authorizationHeader; + } + + public void setAuthorizationHeader(String authorizationHeader) { + this.authorizationHeader = authorizationHeader; + } + + public String getSecurityScheme() { + return securityScheme; + } + + public void setSecurityScheme(String securityScheme) { + this.securityScheme = securityScheme; + } + + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } + + public List getTiers() { + return tiers; + } + + public void setTiers(List tiers) { + this.tiers = tiers; + } + + public boolean isHasThumbnail() { + return hasThumbnail; + } + + public void setHasThumbnail(boolean hasThumbnail) { + this.hasThumbnail = hasThumbnail; + } + + public String getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(String additionalProperties) { + this.additionalProperties = additionalProperties; + } + + public JSONObject getMonetization() { + return monetization; + } + + public void setMonetization(JSONObject monetization) { + this.monetization = monetization; + } + + public List getEndpointURLs() { + return endpointURLs; + } + + public void setEndpointURLs(List endpointURLs) { + this.endpointURLs = endpointURLs; + } + + public JSONObject getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(JSONObject businessInformation) { + this.businessInformation = businessInformation; + } + + public List getEnvironmentList() { + return environmentList; + } + + public void setEnvironmentList(List environmentList) { + this.environmentList = environmentList; + } + + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public String getAvgRating() { + return avgRating; + } + + public void setAvgRating(String avgRating) { + this.avgRating = avgRating; + } + + public JSONObject getAdvertiseInfo() { + return advertiseInfo; + } + + public void setAdvertiseInfo(JSONObject advertiseInfo) { + this.advertiseInfo = advertiseInfo; + } + + public boolean isSubscriptionAvailable() { + return isSubscriptionAvailable; + } + + public void setSubscriptionAvailable(boolean subscriptionAvailable) { + isSubscriptionAvailable = subscriptionAvailable; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getKeyManagers() { + return keyManagers; + } + + public void setKeyManagers(List keyManagers) { + this.keyManagers = keyManagers; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(String lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java index 022f1831b4..5cdaa83577 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +/** + * This class represents the Consumer API Key Information. + */ + public class APIKey { private String apikey; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java index 4764f001b9..50fb64147d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java @@ -22,6 +22,10 @@ import org.json.JSONObject; import java.util.List; +/** + * This class represents the Consumer Application Information. + */ + public class Application { private String applicationId; private String name; @@ -33,7 +37,7 @@ public class Application { private int subscriptionCount; private List keys; private JSONObject attributes; - private List subscriptionScopes; + private List subscriptionScopes; private String owner; private boolean hashEnabled; @@ -117,11 +121,11 @@ public class Application { this.attributes = attributes; } - public List getSubscriptionScopes() { + public List getSubscriptionScopes() { return subscriptionScopes; } - public void setSubscriptionScopes(List subscriptionScopes) { + public void setSubscriptionScopes(List subscriptionScopes) { this.subscriptionScopes = subscriptionScopes; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java new file mode 100644 index 0000000000..9634b77528 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import io.apicurio.datamodels.asyncapi.v2.visitors.Aai20Traverser; + +import java.util.List; + +/** + * This class represents the Consumer Application configuration Information. + */ +public class ApplicationConfigurations { + + private String name; + private String label; + private String type; + private boolean required; + private boolean mask; + private boolean multiple; + private String tooltip; + private List values; + private String defaults; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public boolean isMask() { + return mask; + } + + public void setMask(boolean mask) { + this.mask = mask; + } + + public boolean isMultiple() { + return multiple; + } + + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + + public String getTooltip() { + return tooltip; + } + + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + public String getDefaults() { + return defaults; + } + + public void setDefaults(String defaults) { + this.defaults = defaults; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java new file mode 100644 index 0000000000..ac34e006dd --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +/** + * This class represents the Consumer Key manager Information. + */ + +public class KeyManager { + + private String id; + private String name; + private String type; + private String displayName; + private String description; + private boolean enabled; + private List availableGrantTypes; + private String tokenEndpoint; + private String revokeEndpoint; + private String userInfoEndpoint; + private String enableTokenGeneration; + private String enableTokenEncryption; + private String enableTokenHashing; + private String enableOAuthAppCreation; + private String enableMapOAuthConsumerApps; + private List applicationConfiguration; + private JSONObject additionalProperties; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public List getAvailableGrantTypes() { + return availableGrantTypes; + } + + public void setAvailableGrantTypes(List availableGrantTypes) { + this.availableGrantTypes = availableGrantTypes; + } + + public String getTokenEndpoint() { + return tokenEndpoint; + } + + public void setTokenEndpoint(String tokenEndpoint) { + this.tokenEndpoint = tokenEndpoint; + } + + public String getRevokeEndpoint() { + return revokeEndpoint; + } + + public void setRevokeEndpoint(String revokeEndpoint) { + this.revokeEndpoint = revokeEndpoint; + } + + public String getUserInfoEndpoint() { + return userInfoEndpoint; + } + + public void setUserInfoEndpoint(String userInfoEndpoint) { + this.userInfoEndpoint = userInfoEndpoint; + } + + public String getEnableTokenGeneration() { + return enableTokenGeneration; + } + + public void setEnableTokenGeneration(String enableTokenGeneration) { + this.enableTokenGeneration = enableTokenGeneration; + } + + public String getEnableTokenEncryption() { + return enableTokenEncryption; + } + + public void setEnableTokenEncryption(String enableTokenEncryption) { + this.enableTokenEncryption = enableTokenEncryption; + } + + public String getEnableTokenHashing() { + return enableTokenHashing; + } + + public void setEnableTokenHashing(String enableTokenHashing) { + this.enableTokenHashing = enableTokenHashing; + } + + public String getEnableOAuthAppCreation() { + return enableOAuthAppCreation; + } + + public void setEnableOAuthAppCreation(String enableOAuthAppCreation) { + this.enableOAuthAppCreation = enableOAuthAppCreation; + } + + public String getEnableMapOAuthConsumerApps() { + return enableMapOAuthConsumerApps; + } + + public void setEnableMapOAuthConsumerApps(String enableMapOAuthConsumerApps) { + this.enableMapOAuthConsumerApps = enableMapOAuthConsumerApps; + } + + public List getApplicationConfiguration() { + return applicationConfiguration; + } + + public void setApplicationConfiguration(List applicationConfiguration) { + this.applicationConfiguration = applicationConfiguration; + } + + public JSONObject getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(JSONObject additionalProperties) { + this.additionalProperties = additionalProperties; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java new file mode 100644 index 0000000000..a2b55005b6 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import java.util.List; + +/** + * This class represents the scope data. + */ + +public class Scopes { + + private String key; + private String name; + private List roles; + private String description; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index edfbce6b6a..dca36b9669 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -25,8 +25,8 @@ public class Subscription { private String subscriptionId; private String applicationId; private String apiId; - private JSONObject apiInfo; - private JSONObject applicationInfo; + private APIInfo apiInfo; + private Application applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -56,19 +56,19 @@ public class Subscription { this.apiId = apiId; } - public JSONObject getApiInfo() { + public APIInfo getApiInfo() { return apiInfo; } - public void setApiInfo(JSONObject apiInfo) { + public void setApiInfo(APIInfo apiInfo) { this.apiInfo = apiInfo; } - public JSONObject getApplicationInfo() { + public Application getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(JSONObject applicationInfo) { + public void setApplicationInfo(Application applicationInfo) { this.applicationInfo = applicationInfo; }