From 2a538ff9590b1df4d3f20cf638a0188a36f315c6 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Mon, 16 Jan 2017 16:07:36 +0530 Subject: [PATCH 001/193] fixed multi tenant login issue --- .../APIManagementProviderServiceImpl.java | 19 + .../src/main/webapp/WEB-INF/web.xml | 4 + .../src/main/webapp/WEB-INF/web.xml | 4 + .../devicemgt/app/conf/config.json | 2 +- .../app/modules/oauth/token-handler-utils.js | 2 +- .../pom.xml | 23 +- .../ExtendedSAML2BearerGrantHandler.java | 570 ++++++++++++++++++ .../pom.xml | 4 - 8 files changed, 614 insertions(+), 14 deletions(-) create mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 087a6ee4a24..daedca4271e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -30,6 +30,8 @@ import org.wso2.carbon.apimgt.application.extension.exception.APIManagerExceptio import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -276,6 +278,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Set userVisibleAPIs = null; for (String tag : tags) { Set tagAPIs = apiConsumer.getAPIsWithTag(tag, APIManagerUtil.getTenantDomain()); + if (tagAPIs == null || tagAPIs.size() == 0) { + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername( + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName()); + APIConsumer anonymousConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); + tagAPIs = anonymousConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + + } catch (UserStoreException e) { + log.error("failed to initialized super tenant flow", e); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } if (userVisibleAPIs == null) { userVisibleAPIs = tagAPIs; } else { diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/WEB-INF/web.xml index 62a814568e1..58aa02917c4 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/WEB-INF/web.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/WEB-INF/web.xml @@ -47,5 +47,9 @@ managed-api-owner admin + + isSharedWithAllTenants + true + diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/WEB-INF/web.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/WEB-INF/web.xml index 72020e147e4..1d59c04b173 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/WEB-INF/web.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/WEB-INF/web.xml @@ -52,6 +52,10 @@ managed-api-owner admin + + isSharedWithAllTenants + true + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 573d973b3a7..d87ca3d0a73 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -20,7 +20,7 @@ "owner": "admin@carbon.super", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", - "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer", + "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-carbon urn:ietf:params:oauth:grant-type:jwt-bearer", "tokenScope": "admin", "callbackUrl": "%https.ip%/api/device-mgt/v1.0" }, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js index 81cdc1729be..c60cd9c80d6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js @@ -303,7 +303,7 @@ var utils = function () { // calling oauth provider token service endpoint var requestURL = deviceMgtProps["oauthProvider"]["tokenServiceURL"]; - var requestPayload = "grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&" + + var requestPayload = "grant_type=urn:ietf:params:oauth:grant-type:saml2-carbon&" + "assertion=" + encodeURIComponent(encodedAssertion) + "&scope=" + scopes; var xhr = new XMLHttpRequest(); diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index dc80a4ff55f..2a01d519b02 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -100,24 +100,31 @@ org.wso2.carbon.identity.core.util, org.wso2.carbon.identity.oauth2.dto, org.wso2.carbon.identity.oauth2.token, - org.apache.oltu.oauth2.common.validators, org.wso2.carbon.utils, org.wso2.carbon.context, org.wso2.carbon.identity.oauth.cache, org.wso2.carbon.identity.oauth.config, org.wso2.carbon.identity.oauth2.dao, org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.identity.oauth2.grant.jwt.*, - org.wso2.carbon.device.mgt.core.*, - org.wso2.carbon.apimgt.keymgt, org.wso2.carbon.apimgt.keymgt.handlers, - com.google.gson, org.apache.commons.codec.binary, org.wso2.carbon.identity.application.authentication.framework.model, - org.apache.oltu.oauth2.common, org.wso2.carbon.base, - org.apache.xerces.impl; resolution:=optional, - org.apache.xerces.util; resolution:=optional + org.apache.commons.collections, + org.apache.commons.lang, + org.joda.time, + org.opensaml.saml2.core, + org.opensaml.security, + org.opensaml.xml.*, + org.w3c.dom, + org.wso2.carbon.identity.application.common.util, + org.wso2.carbon.identity.base, + org.wso2.carbon.identity.oauth2.token.handlers.grant.*, + org.wso2.carbon.identity.oauth2.util, + org.wso2.carbon.idp.mgt, + org.opensaml.common.xml, + org.wso2.carbon.identity.oauth.common, + org.opensaml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java new file mode 100644 index 00000000000..67fbe41ba4d --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -0,0 +1,570 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.joda.time.DateTime; +import org.opensaml.DefaultBootstrap; +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.Assertion; +import org.opensaml.saml2.core.Audience; +import org.opensaml.saml2.core.AudienceRestriction; +import org.opensaml.saml2.core.Conditions; +import org.opensaml.saml2.core.SubjectConfirmation; +import org.opensaml.security.SAMLSignatureProfileValidator; +import org.opensaml.xml.ConfigurationException; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.security.x509.X509Credential; +import org.opensaml.xml.signature.SignatureValidator; +import org.opensaml.xml.validation.ValidationException; +import org.w3c.dom.NodeList; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.device.mgt.oauth.extensions.OAuthExtUtils; +import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; +import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; +import org.wso2.carbon.identity.application.common.model.IdentityProvider; +import org.wso2.carbon.identity.application.common.model.Property; +import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; +import org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil; +import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.IdentityException; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.oauth.common.OAuthConstants; +import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; +import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.model.RequestParameter; +import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; +import org.wso2.carbon.identity.oauth2.token.handlers.grant.AbstractAuthorizationGrantHandler; +import org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2TokenCallbackHandler; +import org.wso2.carbon.identity.oauth2.util.X509CredentialImpl; +import org.wso2.carbon.idp.mgt.IdentityProviderManagementException; +import org.wso2.carbon.idp.mgt.IdentityProviderManager; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This looks up for idp in supertenant space. + */ +@SuppressWarnings("unused") +public class ExtendedSAML2BearerGrantHandler extends AbstractAuthorizationGrantHandler { + private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class); + SAMLSignatureProfileValidator profileValidator = null; + private static final String ASSERTION_IDENTIFIER = "assertion"; + + @Override + public void init() throws IdentityOAuth2Exception { + + super.init(); + + Thread thread = Thread.currentThread(); + ClassLoader loader = thread.getContextClassLoader(); + thread.setContextClassLoader(this.getClass().getClassLoader()); + + try { + DefaultBootstrap.bootstrap(); + } catch (ConfigurationException e) { + log.error("Error in bootstrapping the OpenSAML2 library", e); + throw new IdentityOAuth2Exception("Error in bootstrapping the OpenSAML2 library"); + } finally { + thread.setContextClassLoader(loader); + } + + profileValidator = new SAMLSignatureProfileValidator(); + } + + @Override + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { + return OAuthExtUtils.setScopes(tokReqMsgCtx); + } + + /** + * We're validating the SAML token that we receive from the request. Through the assertion parameter is the POST + * request. A request format that we handle here looks like, + *

+ * POST /token.oauth2 HTTP/1.1 + * Host: as.example.com + * Content-Type: application/x-www-form-urlencoded + *

+ * grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Asaml2-bearer& + * assertion=PHNhbWxwOl...[omitted for brevity]...ZT4 + * + * @param tokReqMsgCtx Token message request context + * @return true if validation is successful, false otherwise + * @throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception + */ + @Override + public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { + RequestParameter[] parameters = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters(); + for (RequestParameter parameter : parameters) { + if (ASSERTION_IDENTIFIER.equals(parameter.getKey())) { + tokReqMsgCtx.getOauth2AccessTokenReqDTO().setAssertion(parameter.getValue()[0]); + } + } + + if(!super.validateGrant(tokReqMsgCtx)){ + return false; + } + + Assertion assertion = null; + IdentityProvider identityProvider = null; + String tokenEndpointAlias = null; + String tenantDomain = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getTenantDomain(); + if (tenantDomain == null || "".equals(tenantDomain)) { + tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; + } + + // Logging the SAML token + if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.SAML_ASSERTION)) { + log.debug("Received SAML assertion : " + + new String(Base64.decodeBase64(tokReqMsgCtx.getOauth2AccessTokenReqDTO().getAssertion())) + ); + } + + try { + XMLObject samlObject = IdentityUtil.unmarshall(new String(Base64.decodeBase64( + tokReqMsgCtx.getOauth2AccessTokenReqDTO().getAssertion()))); + // Validating for multiple assertions + NodeList assertionList = samlObject.getDOM().getElementsByTagNameNS(SAMLConstants.SAML20_NS, "Assertion"); + if (assertionList.getLength() > 0) { + log.error("Invalid schema for SAML2 Assertion. Nested assertions detected."); + return false; + } + + if (samlObject instanceof Assertion) { + assertion = (Assertion) samlObject; + } else { + log.error("Only Assertion objects are validated in SAML2Bearer Grant Type"); + return false; + } + } catch (IdentityException e) { + // fault in the saml2 assertion + if(log.isDebugEnabled()){ + log.debug("Error while unmashalling the assertion", e); + } + return false; + } + + if (assertion == null) { + log.debug("Assertion is null, cannot continue"); + return false; + } + + /* + The Assertion MUST contain a element. The subject MAY identify the resource owner for whom + the access token is being requested. For client authentication, the Subject MUST be the "client_id" + of the OAuth client. When using an Assertion as an authorization grant, the Subject SHOULD identify + an authorized accessor for whom the access token is being requested (typically the resource owner, or + an authorized delegate). Additional information identifying the subject/principal of the transaction + MAY be included in an . + */ + if (assertion.getSubject() != null) { + String subjectIdentifier = assertion.getSubject().getNameID().getValue(); + if (StringUtils.isBlank(subjectIdentifier)) { + if (log.isDebugEnabled()){ + log.debug("NameID in Assertion cannot be empty"); + } + return false; + } + AuthenticatedUser user = + AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(subjectIdentifier); + user.setUserName(MultitenantUtils.getTenantAwareUsername(subjectIdentifier)); + // we take a tenant domain of the authorized user to be the tenant domain of the OAuth app + user.setTenantDomain(tenantDomain); + tokReqMsgCtx.setAuthorizedUser(user); + tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; + } else { + if (log.isDebugEnabled()) { + log.debug("Cannot find a Subject in the Assertion"); + } + return false; + } + + if (assertion.getIssuer() == null || "".equals(assertion.getIssuer().getValue())) { + if (log.isDebugEnabled()) { + log.debug("Issuer is empty in the SAML assertion"); + } + return false; + } else { + try { + identityProvider = IdentityProviderManager.getInstance(). + getIdPByAuthenticatorPropertyValue("IdPEntityId", + assertion.getIssuer().getValue(), tenantDomain, false); + // IF Federated IDP not found get the resident IDP and check, + // resident IDP entityID == issuer + if (identityProvider != null) { + if (IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME.equals( + identityProvider.getIdentityProviderName())) { + identityProvider = IdentityProviderManager.getInstance().getResidentIdP(tenantDomain); + + FederatedAuthenticatorConfig[] fedAuthnConfigs = + identityProvider.getFederatedAuthenticatorConfigs(); + String idpEntityId = null; + + // Get SAML authenticator + FederatedAuthenticatorConfig samlAuthenticatorConfig = + IdentityApplicationManagementUtil.getFederatedAuthenticator(fedAuthnConfigs, + IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); + // Get Entity ID from SAML authenticator + Property samlProperty = IdentityApplicationManagementUtil.getProperty( + samlAuthenticatorConfig.getProperties(), + IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID); + if (samlProperty != null) { + idpEntityId = samlProperty.getValue(); + } + + if (idpEntityId == null || !assertion.getIssuer().getValue().equals(idpEntityId)) { + if(log.isDebugEnabled()) { + log.debug("SAML Token Issuer verification failed against resident Identity Provider " + + "in tenant : " + tenantDomain + ". Received : " + + assertion.getIssuer().getValue() + ", Expected : " + idpEntityId); + } + return false; + } + + // Get OpenIDConnect authenticator == OAuth + // authenticator + FederatedAuthenticatorConfig oauthAuthenticatorConfig = + IdentityApplicationManagementUtil.getFederatedAuthenticator(fedAuthnConfigs, + IdentityApplicationConstants.Authenticator.OIDC.NAME); + // Get OAuth token endpoint + Property oauthProperty = IdentityApplicationManagementUtil.getProperty( + oauthAuthenticatorConfig.getProperties(), + IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_TOKEN_URL); + if (oauthProperty != null) { + tokenEndpointAlias = oauthProperty.getValue(); + } + } else { + // Get Alias from Federated IDP + tokenEndpointAlias = identityProvider.getAlias(); + } + } else { + if(log.isDebugEnabled()) { + log.debug("SAML Token Issuer : " + assertion.getIssuer().getValue() + + " not registered as a local Identity Provider in tenant : " + tenantDomain); + } + return false; + } + } catch (IdentityProviderManagementException e) { + throw new IdentityOAuth2Exception("Error while getting an Identity Provider for issuer value : " + + assertion.getIssuer().getValue(), e); + } + } + + /* + The Assertion MUST contain element with an element with an + element containing a URI reference that identifies the authorization server, or the service provider + SAML entity of its controlling domain, as an intended audience. The token endpoint URL of the + authorization server MAY be used as an acceptable value for an element. The authorization + server MUST verify that it is an intended audience for the Assertion. + */ + + if (StringUtils.isBlank(tokenEndpointAlias)) { + if (log.isDebugEnabled()){ + String errorMsg = "Token Endpoint alias has not been configured in the Identity Provider : " + + identityProvider.getIdentityProviderName() + " in tenant : " + tenantDomain; + log.debug(errorMsg); + } + return false; + } + + Conditions conditions = assertion.getConditions(); + if (conditions != null) { + //Set validity period extracted from SAML Assertion + long curTimeInMillis = Calendar.getInstance().getTimeInMillis(); + tokReqMsgCtx.setValidityPeriod(conditions.getNotOnOrAfter().getMillis() - curTimeInMillis); + List audienceRestrictions = conditions.getAudienceRestrictions(); + if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) { + boolean audienceFound = false; + for (AudienceRestriction audienceRestriction : audienceRestrictions) { + if (CollectionUtils.isNotEmpty(audienceRestriction.getAudiences())) { + for (Audience audience : audienceRestriction.getAudiences()) { + if (audience.getAudienceURI().equals(tokenEndpointAlias)) { + audienceFound = true; + break; + } + } + } + if (audienceFound) { + break; + } + } + if (!audienceFound) { + if (log.isDebugEnabled()) { + log.debug("SAML Assertion Audience Restriction validation failed against the Audience : " + + tokenEndpointAlias + " of Identity Provider : " + + identityProvider.getIdentityProviderName() + " in tenant : " + tenantDomain); + } + return false; + } + } else { + if (log.isDebugEnabled()) { + String message = "SAML Assertion doesn't contain AudienceRestrictions"; + log.debug(message); + } + return false; + } + } else { + if (log.isDebugEnabled()) { + String message = "SAML Assertion doesn't contain Conditions"; + log.debug(message); + } + return false; + } + + + /* + The Assertion MUST have an expiry that limits the time window during which it can be used. The expiry + can be expressed either as the NotOnOrAfter attribute of the element or as the NotOnOrAfter + attribute of a suitable element. + */ + + /* + The element MUST contain at least one element that allows the + authorization server to confirm it as a Bearer Assertion. Such a element MUST + have a Method attribute with a value of "urn:oasis:names:tc:SAML:2.0:cm:bearer". The + element MUST contain a element, unless the Assertion + has a suitable NotOnOrAfter attribute on the element, in which case the + element MAY be omitted. When present, the element + MUST have a Recipient attribute with a value indicating the token endpoint URL of the authorization + server (or an acceptable alias). The authorization server MUST verify that the value of the Recipient + attribute matches the token endpoint URL (or an acceptable alias) to which the Assertion was delivered. + The element MUST have a NotOnOrAfter attribute that limits the window during + which the Assertion can be confirmed. The element MAY also contain an Address + attribute limiting the client address from which the Assertion can be delivered. Verification of the + Address is at the discretion of the authorization server. + */ + + DateTime notOnOrAfterFromConditions = null; + Map notOnOrAfterFromAndNotBeforeSubjectConfirmations = new HashMap<>(); + boolean bearerFound = false; + List recipientURLS = new ArrayList<>(); + + if (assertion.getConditions() != null && assertion.getConditions().getNotOnOrAfter() != null) { + notOnOrAfterFromConditions = assertion.getConditions().getNotOnOrAfter(); + } + + DateTime notBeforeConditions = null; + if (assertion.getConditions() != null && assertion.getConditions().getNotBefore() != null) { + notBeforeConditions = assertion.getConditions().getNotBefore(); + } + + List subjectConfirmations = assertion.getSubject().getSubjectConfirmations(); + if (subjectConfirmations != null && !subjectConfirmations.isEmpty()) { + for (SubjectConfirmation s : subjectConfirmations) { + if (s.getMethod() != null) { + if (s.getMethod().equals(OAuthConstants.OAUTH_SAML2_BEARER_METHOD)) { + bearerFound = true; + } + } else { + if (log.isDebugEnabled()){ + log.debug("Cannot find Method attribute in SubjectConfirmation " + s.toString()); + } + return false; + } + + if (s.getSubjectConfirmationData() != null) { + if (s.getSubjectConfirmationData().getRecipient() != null) { + recipientURLS.add(s.getSubjectConfirmationData().getRecipient()); + } + if (s.getSubjectConfirmationData().getNotOnOrAfter() != null || s.getSubjectConfirmationData() + .getNotBefore() != null) { + notOnOrAfterFromAndNotBeforeSubjectConfirmations.put(s.getSubjectConfirmationData().getNotOnOrAfter(), + s.getSubjectConfirmationData().getNotBefore()); + } else { + if (log.isDebugEnabled()){ + log.debug("Cannot find NotOnOrAfter and NotBefore attributes in " + + "SubjectConfirmationData " + + s.getSubjectConfirmationData().toString()); + } + } + } else { + if (s.getSubjectConfirmationData() == null && notOnOrAfterFromConditions == null) { + if (log.isDebugEnabled()){ + log.debug("Neither can find NotOnOrAfter attribute in Conditions nor SubjectConfirmationData" + + "in SubjectConfirmation " + s.toString()); + } + return false; + } + + if (s.getSubjectConfirmationData() == null && notBeforeConditions == null) { + if (log.isDebugEnabled()){ + log.debug("Neither can find NotBefore attribute in Conditions nor SubjectConfirmationData" + + "in SubjectConfirmation " + s.toString()); + } + return false; + } + } + } + } else { + if (log.isDebugEnabled()){ + log.debug("No SubjectConfirmation exist in Assertion"); + } + return false; + } + + if (!bearerFound) { + if (log.isDebugEnabled()){ + log.debug("Failed to find a SubjectConfirmation with a Method attribute having : " + + OAuthConstants.OAUTH_SAML2_BEARER_METHOD); + } + return false; + } + + if (CollectionUtils.isNotEmpty(recipientURLS) && !recipientURLS.contains(tokenEndpointAlias)) { + if (log.isDebugEnabled()){ + log.debug("None of the recipient URLs match against the token endpoint alias : " + tokenEndpointAlias + + " of Identity Provider " + identityProvider.getIdentityProviderName() + " in tenant : " + + tenantDomain); + } + return false; + } + + /* + The authorization server MUST verify that the NotOnOrAfter instant has not passed, subject to allowable + clock skew between systems. An invalid NotOnOrAfter instant on the element invalidates + the entire Assertion. An invalid NotOnOrAfter instant on a element only + invalidates the individual . The authorization server MAY reject Assertions with + a NotOnOrAfter instant that is unreasonably far in the future. The authorization server MAY ensure + that Bearer Assertions are not replayed, by maintaining the set of used ID values for the length of + time for which the Assertion would be considered valid based on the applicable NotOnOrAfter instant. + */ + if (notOnOrAfterFromConditions != null && notOnOrAfterFromConditions.compareTo(new DateTime()) < 1) { + // notOnOrAfter is an expired timestamp + if (log.isDebugEnabled()){ + log.debug("NotOnOrAfter is having an expired timestamp in Conditions element"); + } + return false; + } + + if (notBeforeConditions != null && notBeforeConditions.compareTo(new DateTime()) >= 1) { + // notBefore is an early timestamp + if (log.isDebugEnabled()){ + log.debug("NotBefore is having an early timestamp in Conditions element"); + } + return false; + } + + boolean validSubjectConfirmationDataExists = false; + if (!notOnOrAfterFromAndNotBeforeSubjectConfirmations.isEmpty()) { + for (Map.Entry entry : notOnOrAfterFromAndNotBeforeSubjectConfirmations.entrySet()) { + if (entry.getKey() != null) { + if (entry.getKey().compareTo(new DateTime()) >= 1) { + validSubjectConfirmationDataExists = true; + } + } + if (entry.getValue() != null) { + if (entry.getValue().compareTo(new DateTime()) < 1) { + validSubjectConfirmationDataExists = true; + } + } + } + } + + if (notOnOrAfterFromConditions == null && !validSubjectConfirmationDataExists) { + if (log.isDebugEnabled()){ + log.debug("No valid NotOnOrAfter element found in SubjectConfirmations"); + } + return false; + } + + if (notBeforeConditions == null && !validSubjectConfirmationDataExists) { + if (log.isDebugEnabled()){ + log.debug("No valid NotBefore element found in SubjectConfirmations"); + } + return false; + } + + /* + The Assertion MUST be digitally signed by the issuer and the authorization server MUST verify the + signature. + */ + + try { + profileValidator.validate(assertion.getSignature()); + } catch (ValidationException e) { + // Indicates signature did not conform to SAML Signature profile + log.error("Signature do not confirm to SAML signature profile.", e); + + return false; + } + + X509Certificate x509Certificate = null; + try { + x509Certificate = (X509Certificate) IdentityApplicationManagementUtil + .decodeCertificate(identityProvider.getCertificate()); + } catch (CertificateException e) { + throw new IdentityOAuth2Exception("Error occurred while decoding public certificate of Identity Provider " + + identityProvider.getIdentityProviderName() + " for tenant domain " + tenantDomain, e); + } + + try { + X509Credential x509Credential = new X509CredentialImpl(x509Certificate); + SignatureValidator signatureValidator = new SignatureValidator(x509Credential); + signatureValidator.validate(assertion.getSignature()); + if (log.isDebugEnabled()){ + log.debug("Signature validation successful"); + } + } catch (ValidationException e) { + log.error("Error while validating the signature.", e); + return false; + } + + + /* + The authorization server MUST verify that the Assertion is valid in all other respects per + [OASIS.saml-core-2.0-os], such as (but not limited to) evaluating all content within the Conditions + element including the NotOnOrAfter and NotBefore attributes, rejecting unknown condition types, etc. + + [OASIS.saml-core-2.0-os] - http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf + */ + + + // TODO: Throw the SAML request through the general SAML2 validation routines + + tokReqMsgCtx.setScope(tokReqMsgCtx.getOauth2AccessTokenReqDTO().getScope()); + + // Storing the Assertion. This will be used in OpenID Connect for example + tokReqMsgCtx.addProperty(OAuthConstants.OAUTH_SAML2_ASSERTION, assertion); + + // Invoking extension + SAML2TokenCallbackHandler callback = + OAuthServerConfiguration.getInstance() + .getSAML2TokenCallbackHandler(); + if (callback != null) { + if (log.isDebugEnabled()){ + log.debug("Invoking the SAML2 Token callback handler "); + } + callback.handleSAML2Token(tokReqMsgCtx); + } + + return true; + } + +} diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index b39b20638d8..f5b348b6c97 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -133,7 +133,6 @@ org.osgi.framework, org.osgi.service.component, - org.wso2.carbon.governance.api.*, org.wso2.carbon.context, org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.exceptions, @@ -141,18 +140,15 @@ org.wso2.carbon.utils, org.apache.commons.logging, org.wso2.carbon.registry.core.*;resolution:=optional, - org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", com.nimbusds.jwt.*;version="${nimbus.orbit.version.range}", com.nimbusds.jose.*;version="${nimbus.orbit.version.range}", javax.net.ssl, org.apache.commons.codec.binary, - org.apache.commons.io, org.apache.http;version="${httpclient.version.range}", org.apache.http.client;version="${httpclient.version.range}", org.apache.http.message;version="${httpclient.version.range}", org.apache.http.client;version="${httpclient.version.range}", - org.apache.http.impl;version="${httpclient.version.range}", org.apache.http.conn.*;version="${httpclient.version.range}", org.apache.http.util;version="${httpclient.version.range}", org.apache.http.client.entity;version="${httpclient.version.range}", From 4128e2d355d2b823b3e12e3f837be6a3f422d653 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 17 Jan 2017 15:51:30 +0530 Subject: [PATCH 002/193] pointed to gateway node --- .../resources/jaggeryapps/devicemgt/app/conf/config.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index d87ca3d0a73..c850c11db93 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -3,7 +3,6 @@ "httpsURL" : "https://%server.ip%:8243", "httpURL" : "http://%server.ip%:8280", "wssURL" : "https://localhost:9445", - "wsURL" : "%http.ip%", "portalURL": "https://%server.ip%:9445", "dashboardServerURL" : "%https.ip%", "androidEnrollmentDir": "/android-web-agent/enrollment", @@ -19,12 +18,12 @@ "clientName": "emm", "owner": "admin@carbon.super", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", - "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", + "apiManagerClientAppRegistrationServiceURL": "https://%server.ip%:8243/api-application-registration/register/tenants", "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-carbon urn:ietf:params:oauth:grant-type:jwt-bearer", "tokenScope": "admin", "callbackUrl": "%https.ip%/api/device-mgt/v1.0" }, - "tokenServiceURL": "%https.ip%/oauth2/token" + "tokenServiceURL": "https://%server.ip%:8243/token" }, "adminUser":"admin@carbon.super", "adminUserTenantId":"-1234", From 59270644351f3d84924787d52c5e4b19b347ee73 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 18 Jan 2017 01:48:07 +0530 Subject: [PATCH 003/193] apim seperation --- ...ApiApplicationRegistrationServiceImpl.java | 26 +- .../api/util/RegistrationProfile.java | 28 - .../pom.xml | 4 + .../APIManagementProviderService.java | 10 +- .../APIManagementRestProviderServiceImpl.java | 151 + ...ApplicationManagerExtensionDataHolder.java | 11 + ...ationManagerExtensionServiceComponent.java | 20 +- .../pom.xml | 159 + .../client/IntegrationClientServiceImpl.java | 43 + .../client/OAuthRequestInterceptor.java | 111 + .../integration/client/PublisherClient.java | 92 + .../integration/client/StoreClient.java | 103 + .../client/configs/APIMConfig.java | 90 + .../client/configs/APIMConfigReader.java | 94 + .../client/exception/APIMClientException.java | 58 + .../exception/APIMClientOAuthException.java | 58 + .../InvalidConfigurationStateException.java | 78 + .../APIIntegrationClientDataHolder.java | 45 + .../APIIntegrationClientServiceComponent.java | 77 + .../client/model/ClientProfile.java | 96 + .../integration/client/model/DCRClient.java | 36 + .../client/model/OAuthApplication.java | 103 + .../service/IntegrationClientService.java | 41 + .../client/util/PropertyUtils.java | 41 + .../pom.xml | 173 ++ .../src/main/resources/publisher-api.yaml | 2747 +++++++++++++++++ .../pom.xml | 176 ++ .../src/main/resources/store-api.yaml | 2098 +++++++++++++ .../webapp/publisher/APIPublisherService.java | 15 - components/apimgt-extensions/pom.xml | 3 + .../pom.xml | 145 + .../src/main/resources/build.properties | 1 + .../main/resources/conf/apim-integration.xml | 28 + .../src/main/resources/p2.inf | 2 + features/apimgt-extensions/pom.xml | 1 + pom.xml | 72 +- 36 files changed, 6961 insertions(+), 75 deletions(-) create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java create mode 100755 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/PropertyUtils.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index a69ae339f22..bc75a9febe3 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -104,27 +104,11 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } else { validityPeriod = registrationProfile.getValidityPeriod(); } - if (registrationProfile.isMappingAnExistingOAuthApp()) { - JSONObject jsonStringObject = new JSONObject(); - jsonStringObject.put(ApiApplicationConstants.JSONSTRING_USERNAME_TAG, username); - jsonStringObject.put(ApiApplicationConstants.JSONSTRING_KEY_TYPE_TAG, - ApiApplicationConstants.DEFAULT_TOKEN_TYPE); - jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_ID, registrationProfile.getConsumerKey()); - jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_SECRET, - registrationProfile.getConsumerSecret()); - jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG, validityPeriod); - apiManagementProviderService.registerExistingOAuthApplicationToAPIApplication( - jsonStringObject.toJSONString(), registrationProfile.getApplicationName(), - registrationProfile.getConsumerKey(), username, registrationProfile.isAllowedToAllDomains(), - ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getTags()); - return Response.status(Response.Status.ACCEPTED).entity("true").build(); - } else { - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( - registrationProfile.getApplicationName(), registrationProfile.getTags(), - ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod); - return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); - } + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( + registrationProfile.getApplicationName(), registrationProfile.getTags(), + ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, + registrationProfile.isAllowedToAllDomains(), validityPeriod); + return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + registrationProfile.getApplicationName() + "'"; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java index b1634923f35..ef63946fd3b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java @@ -37,10 +37,6 @@ public class RegistrationProfile { private String tags[]; @XmlElement(required = true) private boolean isAllowedToAllDomains; - @XmlElement(required = true) - private boolean isMappingAnExistingOAuthApp; - private String consumerKey; - private String consumerSecret; @XmlElement(required = false) private String validityPeriod; @@ -68,30 +64,6 @@ public class RegistrationProfile { this.isAllowedToAllDomains = isAllowedToAllDomains; } - public boolean isMappingAnExistingOAuthApp() { - return isMappingAnExistingOAuthApp; - } - - public void setIsMappingAnExistingOAuthApp(boolean isMappingAnExistingOAuthApp) { - this.isMappingAnExistingOAuthApp = isMappingAnExistingOAuthApp; - } - - public String getConsumerKey() { - return consumerKey; - } - - public void setConsumerKey(String consumerKey) { - this.consumerKey = consumerKey; - } - - public String getConsumerSecret() { - return consumerSecret; - } - - public void setConsumerSecret(String consumerSecret) { - this.consumerSecret = consumerSecret; - } - public String getValidityPeriod() { return validityPeriod; } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 9d36ef9b700..758d77636ef 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -51,6 +51,10 @@ org.wso2.carbon org.wso2.carbon.logging + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.integration.client + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index 7e04924dc4c..8cad8b016f0 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -41,15 +41,7 @@ public interface APIManagementProviderService { */ ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], String keyType, String username, boolean isAllowedAllDomains, - String validityTime) - throws APIManagerException; - - /** - * Register existing Oauth application as apim application. - */ - void registerExistingOAuthApplicationToAPIApplication(String jsonString, String applicationName, String clientId, - String username, boolean isAllowedAllDomains, String keyType, - String tags[]) throws APIManagerException; + String validityTime) throws APIManagerException; /** * Remove APIM Application. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java new file mode 100644 index 00000000000..bea5cfcf3f1 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.application.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; +import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; +import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; +import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; +import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; +import org.wso2.carbon.apimgt.integration.client.StoreClient; +import org.wso2.carbon.apimgt.store.client.model.APIInfo; +import org.wso2.carbon.apimgt.store.client.model.APIList; +import org.wso2.carbon.apimgt.store.client.model.Application; +import org.wso2.carbon.apimgt.store.client.model.ApplicationInfo; +import org.wso2.carbon.apimgt.store.client.model.ApplicationKey; +import org.wso2.carbon.apimgt.store.client.model.ApplicationKeyGenerateRequest; +import org.wso2.carbon.apimgt.store.client.model.ApplicationList; +import org.wso2.carbon.apimgt.store.client.model.Subscription; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class represents an implementation of APIManagementProviderService. + */ +public class APIManagementRestProviderServiceImpl implements APIManagementProviderService { + + private static final Log log = LogFactory.getLog(APIManagementRestProviderServiceImpl.class); + private static final String CONTENT_TYPE = "application/json"; + private static final int MAX_API_PER_TAG = 200; + + @Override + public void removeAPIApplication(String applicationName, String username) throws APIManagerException { + + StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() + .getStoreClient(); + ApplicationList applicationList = storeClient.getApplications() + .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); + if (applicationList.getList() != null && applicationList.getList().size() > 0) { + ApplicationInfo applicationInfo = applicationList.getList().get(0); + storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), + null, null); + } + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, String validityTime) + throws APIManagerException { + StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() + .getStoreClient(); + ApplicationList applicationList = storeClient.getApplications() + .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); + Application application; + if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { + //create application; + application = new Application(); + application.setName(applicationName); + application.setSubscriber(username); + application.setDescription(""); + application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); + application.setGroupId(""); + application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); + } else { + ApplicationInfo applicationInfo = applicationList.getList().get(0); + application = storeClient.getIndividualApplication() + .applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null); + } + if (application == null) { + throw new APIManagerException ( + "Api application creation failed for " + applicationName + " to the user " + username); + } + // subscribe to apis. + if (tags != null && tags.length > 0) { + for (String tag: tags) { + APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, null, "tag:" + tag, CONTENT_TYPE, null); + if (apiList.getList() != null && apiList.getList().size() == 0) { + apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0 + , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null); + } + + if (apiList.getList() != null && apiList.getList().size() > 0) { + for (APIInfo apiInfo :apiList.getList()) { + Subscription subscription = new Subscription(); + subscription.setApiIdentifier(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscription.tier(ApiApplicationConstants.DEFAULT_TIER); + storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE); + } + + } + } + } + //end of subscription + + List applicationKeys = application.getKeys(); + if (applicationKeys != null) { + for (ApplicationKey applicationKey : applicationKeys) { + if (keyType.equals(applicationKey.getKeyType())) { + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } + } + } + + ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest(); + List allowedDomains = new ArrayList<>(); + if (isAllowedAllDomains) { + allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); + } else { + allowedDomains.add(APIManagerUtil.getTenantDomain()); + } + applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains); + applicationKeyGenerateRequest.setCallbackUrl(""); + applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION); + applicationKeyGenerateRequest.setValidityTime(validityTime); + + ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( + application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 6beb0bbb62e..cf7cbadea43 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,6 +18,7 @@ package org.wso2.carbon.apimgt.application.extension.internal; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; @@ -30,6 +31,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantManager tenantManager; private TenantRegistryLoader tenantRegistryLoader; private TenantIndexingLoader indexLoader; + private IntegrationClientService integrationClientService; private APIApplicationManagerExtensionDataHolder() { } @@ -86,4 +88,13 @@ public class APIApplicationManagerExtensionDataHolder { public TenantIndexingLoader getIndexLoaderService(){ return indexLoader; } + + public IntegrationClientService getIntegrationClientService() { + return integrationClientService; + } + + public void setIntegrationClientService( + IntegrationClientService integrationClientService) { + this.integrationClientService = integrationClientService; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 27104c13bd8..079b119c658 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -23,6 +23,8 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext;; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; +import org.wso2.carbon.apimgt.application.extension.APIManagementRestProviderServiceImpl; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; @@ -48,6 +50,11 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" + * interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService" + * cardinality="1..1" + * policy="dynamic" + * bind="setIntegrationClientService" + * unbind="unsetIntegrationClientService" */ public class APIApplicationManagerExtensionServiceComponent { @@ -57,7 +64,7 @@ public class APIApplicationManagerExtensionServiceComponent { if (log.isDebugEnabled()) { log.debug("Initializing device extension bundle"); } - APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); + APIManagementProviderService apiManagementProviderService = new APIManagementRestProviderServiceImpl(); APIApplicationManagerExtensionDataHolder.getInstance().setAPIManagementProviderService(apiManagementProviderService); BundleContext bundleContext = componentContext.getBundleContext(); bundleContext.registerService(APIManagementProviderService.class.getName(), apiManagementProviderService, null); @@ -86,6 +93,17 @@ public class APIApplicationManagerExtensionServiceComponent { APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null); } + protected void setIntegrationClientService(IntegrationClientService integrationClientService) { + if (integrationClientService != null && log.isDebugEnabled()) { + log.debug("integrationClientService initialized"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService); + } + + protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { + APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null); + } + /** * Sets Realm Service. * diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml new file mode 100644 index 00000000000..4efa8dfc227 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -0,0 +1,159 @@ + + + + + + apimgt-extensions + org.wso2.carbon.devicemgt + 2.0.8-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.apimgt.integration.client + 2.0.8-SNAPSHOT + bundle + WSO2 Carbon - API Management Integration Client + WSO2 Carbon - API Management Integration Client + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${project.version} + APIM Integration + org.wso2.carbon.apimgt.integration.client.internal + + org.wso2.carbon.apimgt.integration.client.*, + !org.wso2.carbon.apimgt.integration.client.internal + + + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.logging, + io.swagger, + junit, + feign, + feign.jackson, + feign.codec, + com.google.gson, + feign.auth, + feign.gson, + feign.slf4j, + feign.jaxrs, + com.fasterxml.jackson.core, + org.wso2.carbon.apimgt.publisher.client.*, + org.wso2.carbon.apimgt.store.client.*, + + + javax.ws.rs-api + + + + + + + + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + com.google.code.gson + gson + + + javax.ws.rs + jsr311-api + + + + io.swagger + swagger-annotations + + + junit + junit + + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-jackson + + + io.github.openfeign + feign-gson + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-annotations + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + + org.testng + testng + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.publisher.client + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.store.client + + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + + + javax.ws.rs + jsr311-api + + + + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java new file mode 100644 index 00000000000..b2c997e57ab --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client; + +import feign.RequestInterceptor; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; + +public class IntegrationClientServiceImpl implements IntegrationClientService { + + private static StoreClient storeClient; + private static PublisherClient publisherClient; + + public IntegrationClientServiceImpl() { + RequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); + storeClient = new StoreClient(oAuthRequestInterceptor); + publisherClient = new PublisherClient(oAuthRequestInterceptor); + } + @Override + public StoreClient getStoreClient() { + return storeClient; + } + + @Override + public PublisherClient getPublisherClient() { + return publisherClient; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java new file mode 100755 index 00000000000..1c421c46f10 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client; + +import feign.Feign; +import feign.RequestInterceptor; +import feign.RequestTemplate; +import feign.auth.BasicAuthRequestInterceptor; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; +import org.wso2.carbon.apimgt.integration.client.exception.APIMClientOAuthException; +import org.wso2.carbon.apimgt.integration.client.internal.APIIntegrationClientDataHolder; +import org.wso2.carbon.apimgt.integration.client.model.ClientProfile; +import org.wso2.carbon.apimgt.integration.client.model.DCRClient; +import org.wso2.carbon.apimgt.integration.client.model.OAuthApplication; +import org.wso2.carbon.apimgt.integration.client.util.PropertyUtils; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.jwt.client.extension.JWTClient; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.user.api.UserStoreException; + +import java.util.HashMap; +import java.util.Map; + +/** + * This is a request interceptor to add oauth token header. + */ +public class OAuthRequestInterceptor implements RequestInterceptor { + + private static final String APPLICATION_NAME = "api_integration_client"; + private static final String GRANT_TYPES = "password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"; + private static final String REQUIRED_SCOPE = + "apim:api_create apim:api_view apim:api_publish apim:subscribe apim:tier_view apim:tier_manage " + + "apim:subscription_view apim:subscription_block"; + private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000; + private DCRClient dcrClient; + private static OAuthApplication oAuthApplication; + private static Map tenantTokenMap = new HashMap<>(); + + /** + * Creates an interceptor that authenticates all requests. + */ + public OAuthRequestInterceptor() { + String username = APIMConfigReader.getInstance().getConfig().getUsername(); + String password = APIMConfigReader.getInstance().getConfig().getPassword(); + dcrClient = Feign.builder().requestInterceptor( + new BasicAuthRequestInterceptor(username, password)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(DCRClient.class, PropertyUtils.replaceProperties( + APIMConfigReader.getInstance().getConfig().getDcrEndpoint())); + } + + @Override + public void apply(RequestTemplate template) { + if (oAuthApplication == null) { + //had to do on demand initialization due to start up error. + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setClientName(APPLICATION_NAME); + clientProfile.setCallbackUrl(""); + clientProfile.setGrantType(GRANT_TYPES); + clientProfile.setOwner(APIMConfigReader.getInstance().getConfig().getUsername()); + clientProfile.setSaasApp(true); + oAuthApplication = dcrClient.register(clientProfile); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + AccessTokenInfo tenantBasedAccessTokenInfo = tenantTokenMap.get(tenantDomain); + + if ((tenantBasedAccessTokenInfo == null || + ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > + tenantBasedAccessTokenInfo.getExpiresIn()))) { + try { + JWTClient jwtClient = APIIntegrationClientDataHolder.getInstance().getJwtClientManagerService() + .getJWTClient(); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName() + "@" + tenantDomain; + + tenantBasedAccessTokenInfo = jwtClient.getAccessToken(oAuthApplication.getClientId(), + oAuthApplication.getClientSecret(), username, + REQUIRED_SCOPE); + tenantBasedAccessTokenInfo.setExpiresIn( + System.currentTimeMillis() + (tenantBasedAccessTokenInfo.getExpiresIn() * 1000)); + tenantTokenMap.put(tenantDomain, tenantBasedAccessTokenInfo); + } catch (JWTClientException e) { + throw new APIMClientOAuthException("failed to retrieve oauth token using jwt", e); + } catch (UserStoreException e) { + throw new APIMClientOAuthException("failed to retrieve tenant admin username", e); + } + + } + if (tenantBasedAccessTokenInfo.getAccessToken() != null) { + String headerValue = "Bearer " + tenantBasedAccessTokenInfo.getAccessToken(); + template.header("Authorization", headerValue); + } + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java new file mode 100644 index 00000000000..5754f07edd2 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client; + +import feign.Feign; +import feign.RequestInterceptor; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; +import org.wso2.carbon.apimgt.publisher.client.api.APIDocumentApi; +import org.wso2.carbon.apimgt.publisher.client.api.APIsApi; +import org.wso2.carbon.apimgt.publisher.client.api.ApplicationsApi; +import org.wso2.carbon.apimgt.publisher.client.api.EnvironmentsApi; +import org.wso2.carbon.apimgt.publisher.client.api.SubscriptionsApi; +import org.wso2.carbon.apimgt.publisher.client.api.TiersApi; +import org.wso2.carbon.apimgt.publisher.client.invoker.ApiClient; + +/** + * Publisher client generated using swagger. + */ +public class PublisherClient { + + private static final org.apache.commons.logging.Log log = LogFactory.getLog(PublisherClient.class); + private APIsApi api = null; + private APIDocumentApi document = null; + private ApplicationsApi application = null; + private EnvironmentsApi environments = null; + private SubscriptionsApi subscriptions = null; + private TiersApi tiers = null; + + + /** + * PublisherClient constructor - Initialize a PublisherClient instance + * + */ + public PublisherClient(RequestInterceptor requestInterceptor) { + Feign.Builder builder = Feign.builder().requestInterceptor(requestInterceptor) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()); + + ApiClient client = new ApiClient(); + client.setBasePath(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); + client.setFeignBuilder(builder); + + api = client.buildClient(APIsApi.class); + document = client.buildClient(APIDocumentApi.class); + application = client.buildClient(ApplicationsApi.class); + environments = client.buildClient(EnvironmentsApi.class); + subscriptions = client.buildClient(SubscriptionsApi.class); + tiers = client.buildClient(TiersApi.class); + } + + public APIsApi getApi() { + return api; + } + + public APIDocumentApi getDocument() { + return document; + } + + public ApplicationsApi getApplication() { + return application; + } + + public EnvironmentsApi getEnvironments() { + return environments; + } + + public SubscriptionsApi getSubscriptions() { + return subscriptions; + } + + public TiersApi getTiers() { + return tiers; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java new file mode 100644 index 00000000000..f7957ea147d --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client; + +import feign.Feign; +import feign.RequestInterceptor; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; +import org.wso2.carbon.apimgt.store.client.api.*; +import org.wso2.carbon.apimgt.store.client.invoker.ApiClient; + +/** + * API Store client, created using swagger gen. + */ +public class StoreClient { + + private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class); + private ApisAPIApi apis = null; + private APIindividualApi individualApi = null; + private ApplicationCollectionApi applications = null; + private ApplicationindividualApi individualApplication = null; + private SubscriptionCollectionApi subscriptions = null; + private SubscriptionindividualApi individualSubscription = null; + private TierindividualApi individualTier = null; + private TagCollectionApi tags = null; + private TierCollectionApi tiers = null; + + + public StoreClient(RequestInterceptor requestInterceptor) { + + Feign.Builder builder = Feign.builder().requestInterceptor(requestInterceptor) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()); + + ApiClient client = new ApiClient(); + client.setBasePath(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); + client.setFeignBuilder(builder); + + apis = client.buildClient(ApisAPIApi.class); + individualApi = client.buildClient(APIindividualApi.class); + applications = client.buildClient(ApplicationCollectionApi.class); + individualApplication = client.buildClient(ApplicationindividualApi.class); + subscriptions = client.buildClient(SubscriptionCollectionApi.class); + individualSubscription = client.buildClient(SubscriptionindividualApi.class); + tags = client.buildClient(TagCollectionApi.class); + tiers = client.buildClient(TierCollectionApi.class); + individualTier = client.buildClient(TierindividualApi.class); + + } + + public ApisAPIApi getApis() { + return apis; + } + + public APIindividualApi getIndividualApi() { + return individualApi; + } + + public ApplicationCollectionApi getApplications() { + return applications; + } + + public ApplicationindividualApi getIndividualApplication() { + return individualApplication; + } + + public SubscriptionCollectionApi getSubscriptions() { + return subscriptions; + } + + public SubscriptionindividualApi getIndividualSubscription() { + return individualSubscription; + } + + public TierindividualApi getIndividualTier() { + return individualTier; + } + + public TagCollectionApi getTags() { + return tags; + } + + public TierCollectionApi getTiers() { + return tiers; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java new file mode 100644 index 00000000000..1e3d34c7464 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.configs; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * This holds the configuration api manager integration. + */ +@XmlRootElement(name = "APIMConfiguration") +public class APIMConfig { + + String dcrEndpoint; + String tokenEndpoint; + String publisherEndpoint; + String storeEndpoint; + String username; + String password; + + @XmlElement(name = "DCREndpoint", required = true) + public String getDcrEndpoint() { + return dcrEndpoint; + } + + public void setDcrEndpoint(String dcrEndpoint) { + this.dcrEndpoint = dcrEndpoint; + } + + @XmlElement(name = "TokenEndpoint", required = true) + public String getTokenEndpoint() { + return tokenEndpoint; + } + + public void setTokenEndpoint(String tokenEndpoint) { + this.tokenEndpoint = tokenEndpoint; + } + + @XmlElement(name = "PublisherEndpoint", required = true) + public String getPublisherEndpoint() { + return publisherEndpoint; + } + + public void setPublisherEndpoint(String publisherEndpoint) { + this.publisherEndpoint = publisherEndpoint; + } + + @XmlElement(name = "StoreEndpoint", required = true) + public String getStoreEndpoint() { + return storeEndpoint; + } + + public void setStoreEndpoint(String storeEndpoint) { + this.storeEndpoint = storeEndpoint; + } + + @XmlElement(name = "Username", required = true) + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "Password", required = true) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java new file mode 100644 index 00000000000..8655a4d6a29 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.configs; + +import org.w3c.dom.Document; +import org.wso2.carbon.apimgt.integration.client.exception.APIMClientException; +import org.wso2.carbon.apimgt.integration.client.exception.InvalidConfigurationStateException; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; + +/** + * This holds the configuration parser for api integration.xml + */ +public class APIMConfigReader { + + private static APIMConfig config; + private static APIMConfigReader configReader= new APIMConfigReader(); + private static boolean isInitialized = false; + private static final String API_INTEGRATION_CONFIG_PATH = + CarbonUtils.getCarbonConfigDirPath() + File.separator + "apim-integration.xml"; + + private APIMConfigReader() { + + } + + private static String apimIntegrationXmlFilePath = ""; + + //TOD file may be a part of another file + public static APIMConfigReader getInstance() { + if (!isInitialized) { + try { + init(); + } catch (APIMClientException e) { + throw new InvalidConfigurationStateException("Webapp Authenticator Configuration is not " + + "initialized properly"); + } + } + return configReader; + } + + public static void init() throws APIMClientException { + try { + File apimConfigFile = new File(API_INTEGRATION_CONFIG_PATH); + Document doc = convertToDocument(apimConfigFile); + + JAXBContext ctx = JAXBContext.newInstance(APIMConfig.class); + Unmarshaller unmarshaller = ctx.createUnmarshaller(); + config = (APIMConfig) unmarshaller.unmarshal(doc); + isInitialized = true; + } catch (JAXBException e) { + throw new APIMClientException("Error occurred while un-marshalling APIMConfig", e); + } + } + + private static Document convertToDocument(File file) throws APIMClientException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + return docBuilder.parse(file); + } catch (Exception e) { + throw new APIMClientException("Error occurred while parsing file 'apim-integration.xml' to a org.w3c.dom.Document", e); + } + } + + public APIMConfig getConfig() { + return config; + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java new file mode 100644 index 00000000000..f893f6d276f --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.exception; + +/** + * This holds api client exception. + */ +public class APIMClientException extends Exception { + + private static final long serialVersionUID = -3976392476319079281L; + private String responseReason; + private int responseStatus; + private String methodKey; + + APIMClientException(String methodKey, String reason, int status) { + super("Exception occured while invoking " + methodKey + " status = " + status + " reason = " + reason); + this.methodKey = methodKey; + this.responseReason = reason; + this.responseStatus = status; + } + + APIMClientException(String message) { + super(message); + } + + public APIMClientException(String message, Exception e) { + super(message, e); + } + + public String getResponseReason() { + return responseReason; + } + + public int getResponseStatus() { + return responseStatus; + } + + public String getMethodKey() { + return methodKey; + } + +} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java new file mode 100644 index 00000000000..48f92d5abda --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.exception; + +/** + * This holds api client exception. + */ +public class APIMClientOAuthException extends RuntimeException { + + private static final long serialVersionUID = -3976392476319079281L; + private String responseReason; + private int responseStatus; + private String methodKey; + + APIMClientOAuthException(String methodKey, String reason, int status) { + super("Exception occured while invoking " + methodKey + " status = " + status + " reason = " + reason); + this.methodKey = methodKey; + this.responseReason = reason; + this.responseStatus = status; + } + + APIMClientOAuthException(String message) { + super(message); + } + + public APIMClientOAuthException(String message, Exception e) { + super(message, e); + } + + public String getResponseReason() { + return responseReason; + } + + public int getResponseStatus() { + return responseStatus; + } + + public String getMethodKey() { + return methodKey; + } + +} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java new file mode 100644 index 00000000000..dedb63c4bd1 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.exception; + +/** + * This error is thrown when there is an issue with the client. + */ +public class InvalidConfigurationStateException extends RuntimeException { + + private static final long serialVersionUID = -3151279311329070397L; + + private String errorMessage; + private int errorCode; + + public InvalidConfigurationStateException(int errorCode, String message) { + super(message); + this.errorCode = errorCode; + } + + public InvalidConfigurationStateException(int errorCode, String message, Throwable cause) { + super(message, cause); + this.errorCode = errorCode; + } + + public int getErrorCode() { + return errorCode; + } + + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public InvalidConfigurationStateException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public InvalidConfigurationStateException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public InvalidConfigurationStateException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public InvalidConfigurationStateException() { + super(); + } + + public InvalidConfigurationStateException(Throwable cause) { + super(cause); + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java new file mode 100644 index 00000000000..a53572cf257 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.internal; + + +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; + +/** + * This holds the required service for this component + */ +public class APIIntegrationClientDataHolder { + private static APIIntegrationClientDataHolder thisInstance = new APIIntegrationClientDataHolder(); + private JWTClientManagerService jwtClientManagerService; + private APIIntegrationClientDataHolder() { + } + + + public static APIIntegrationClientDataHolder getInstance() { + return thisInstance; + } + + public void setJwtClientManagerService(JWTClientManagerService jwtClientManagerService) { + this.jwtClientManagerService = jwtClientManagerService; + } + + public JWTClientManagerService getJwtClientManagerService() { + return jwtClientManagerService; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java new file mode 100644 index 00000000000..aaf178b7180 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.apimgt.integration.client.IntegrationClientServiceImpl; +import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; + +/** + * @scr.component name="org.wso2.carbon.api.integration.client" immediate="true" + * @scr.reference name="api.integration.client.service" + * interface="org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService" + * cardinality="1..1" + * policy="dynamic" + * bind="setJWTClientManagerService" + * unbind="unsetJWTClientManagerService" + */ +public class APIIntegrationClientServiceComponent { + + private static Log log = LogFactory.getLog(APIIntegrationClientServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + try { + if (log.isDebugEnabled()) { + log.debug("Initializing apimgt client bundle"); + } + + /* Initializing webapp publisher configuration */ + APIMConfigReader.init(); + BundleContext bundleContext = componentContext.getBundleContext(); + bundleContext.registerService(IntegrationClientService.class.getName(), new IntegrationClientServiceImpl(), null); + + if (log.isDebugEnabled()) { + log.debug("apimgt client bundle has been successfully initialized"); + } + } catch (Throwable e) { + log.error("Error occurred while initializing apimgt client bundle", e); + } + } + + protected void deactivate(ComponentContext componentContext) { + //do nothing + } + + protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + if (jwtClientManagerService != null) { + log.debug("jwtClientManagerService service is initialized"); + } + APIIntegrationClientDataHolder.getInstance().setJwtClientManagerService(jwtClientManagerService); + } + + protected void unsetJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + APIIntegrationClientDataHolder.getInstance().setJwtClientManagerService(null); + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java new file mode 100644 index 00000000000..fe1821d3a42 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.model; + +/** + * DTO fo DCR request. + */ +public class ClientProfile { + + private String clientName; + private String callbackUrl; + private String tokenScope; + private String owner; + private String grantType; + private boolean saasApp; + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public String getTokenScope() { + return tokenScope; + } + + public void setTokenScope(String tokenScope) { + this.tokenScope = tokenScope; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getGrantType() { + return grantType; + } + + public void setGrantType(String grantTypem) { + this.grantType = grantTypem; + } + + public boolean isSaasApp() { + return saasApp; + } + + public void setSaasApp(boolean saasApp) { + this.saasApp = saasApp; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{\n"); + + sb.append(" clientName: ").append(clientName).append("\n"); + sb.append(" callbackUrl: ").append("callbackUrl").append("\n"); + sb.append(" grantType: ").append(grantType).append("\n"); + sb.append(" tokenScope: ").append(tokenScope).append("\n"); + sb.append(" owner: ").append(owner).append("\n"); + sb.append(" saasApp: ").append(saasApp).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java new file mode 100644 index 00000000000..2adcfa45ad5 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.model; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +/** + * DCR Rest resource. + */ +@Path("/") +public interface DCRClient { + + // DCR APIs + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + OAuthApplication register(ClientProfile registrationProfile); + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java new file mode 100644 index 00000000000..7f3bf458f41 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.model; + +public class OAuthApplication { + + private String jsonString; + private String appOwner; + private String clientName; + private String callBackURL; + private String isSaasApplication; + private String clientId; + private String clientSecret; + + public String getJsonString() { + return jsonString; + } + + public void setJsonString(String jsonString) { + this.jsonString = jsonString; + } + + public String getAppOwner() { + return appOwner; + } + + public void setAppOwner(String appOwner) { + this.appOwner = appOwner; + } + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public String getCallBackURL() { + return callBackURL; + } + + public void setCallBackURL(String callBackURL) { + this.callBackURL = callBackURL; + } + + public String getIsSaasApplication() { + return isSaasApplication; + } + + public void setIsSaasApplication(String isSaasApplication) { + this.isSaasApplication = isSaasApplication; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OAuthApplication {\n"); + + sb.append(" jsonString: ").append(jsonString).append("\n"); + sb.append(" appOwner: ").append(appOwner).append("\n"); + sb.append(" clientName: ").append(clientName).append("\n"); + sb.append(" callBackURL: ").append(callBackURL).append("\n"); + sb.append(" isSaasApplication: ").append(isSaasApplication).append("\n"); + sb.append(" clientId: ").append(isSaasApplication).append("\n"); + sb.append(" clientSecret: ").append(clientSecret).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java new file mode 100644 index 00000000000..922aec75c34 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.service; + + +import org.wso2.carbon.apimgt.integration.client.PublisherClient; +import org.wso2.carbon.apimgt.integration.client.StoreClient; + +/** + * This is a service that can be called upon to access store and publisher. + */ +public interface IntegrationClientService { + + /** + * + * @return API Store Client. + */ + StoreClient getStoreClient(); + + /** + * + * @return API Publisher Client. + */ + PublisherClient getPublisherClient(); + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/PropertyUtils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/PropertyUtils.java new file mode 100644 index 00000000000..83d162fdb44 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/PropertyUtils.java @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.util; + + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PropertyUtils { + + //This method is only used if the mb features are within DAS. + public static String replaceProperties(String text) { + String regex = "\\$\\{(.*?)\\}"; + Pattern pattern = Pattern.compile(regex); + Matcher matchPattern = pattern.matcher(text); + while (matchPattern.find()) { + String sysPropertyName = matchPattern.group(1); + String sysPropertyValue = System.getProperty(sysPropertyName); + if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { + text = text.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); + } + } + return text; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml new file mode 100644 index 00000000000..682bb05aeb1 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml @@ -0,0 +1,173 @@ + + + + + + apimgt-extensions + org.wso2.carbon.devicemgt + 2.0.8-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.apimgt.publisher.client + bundle + org.wso2.carbon.apimgt.publisher.client + + + + + io.swagger + swagger-codegen-maven-plugin + + + + generate + + + ${project.basedir}/src/main/resources/publisher-api.yaml + java + + ${project.artifactId}.api + ${project.artifactId}.model + ${project.artifactId}.invoker + + feign + + + + + + maven-antrun-plugin + + + copy + process-resources + + + + + + + + + + + + + + run + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${project.version} + APIM publisher client + + org.wso2.carbon.apimgt.publisher.client.model, + org.wso2.carbon.apimgt.publisher.client.api, + org.wso2.carbon.apimgt.publisher.client.invoker + + + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.logging, + io.swagger, + junit, + javax.ws.rs, + feign, + feign.jackson, + feign.codec, + feign.auth, + feign.gson, + feign.slf4j, + com.google.gson, + com.fasterxml.jackson.core, + com.fasterxml.jackson.annotation, + com.fasterxml.jackson.databind, + com.fasterxml.jackson.datatype.joda, i + o.swagger.annotations, + javax.net.ssl, + org.apache.oltu.oauth2.client.*, + org.apache.oltu.oauth2.common.*, + org.junit;resolution:=optional + + + + + + + + + + + + + + io.swagger + swagger-annotations + + + junit + junit + + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-gson + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-annotations + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + org.wso2.orbit.joda-time + joda-time + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + + + io.github.openfeign + feign-jackson + + + io.github.openfeign + feign-slf4j + + + + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml new file mode 100644 index 00000000000..665d73ea53e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml @@ -0,0 +1,2747 @@ +swagger: '2.0' +###################################################### +# Prolog +###################################################### +info: + version: "0.10.0" + title: "WSO2 API Manager - Publisher API" + description: | + This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. + + It is written with [swagger 2](http://swagger.io/). + + contact: + name: "WSO2" + url: "http://wso2.com/products/api-manager/" + email: "architecture@wso2.com" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" + +###################################################### +# The fixed parts of the URLs of the API +###################################################### + +# The schemes supported by the API +schemes: + - https + +# The domain of the API. +# This is configured by the customer during deployment. +# The given host is just an example. +host: apis.wso2.com + +# The base path of the API. +# Will be prefixed to all paths. +basePath: /api/am/publisher/v0.10 + +# The following media types can be passed as input in message bodies of the API. +# The actual media type must be specified in the Content-Type header field of the request. +# The default is json, i.e. the Content-Type header is not needed to +# be set, but supporting it serves extensibility. +consumes: + - application/json + +# The following media types may be passed as output in message bodies of the API. +# The media type(s) consumable by the requestor is specified in the Accept header field +# of the corresponding request. +# The actual media type returned will be specfied in the Content-Type header field +# of the of the response. +# The default of the Accept header is json, i.e. there is not needed to +# set the value, but supporting it serves extensibility. +produces: + - application/json + + +x-wso2-security: + apim: + x-wso2-scopes: + - description: "" + roles: admin + name: apim:api_view + key: apim:api_view + - description: "" + roles: admin + name: apim:api_create + key: apim:api_create + - description: "" + roles: admin + name: apim:api_publish + key: apim:api_publish + - description: "" + roles: admin + name: apim:tier_view + key: apim:tier_view + - description: "" + roles: admin + name: apim:tier_manage + key: apim:tier_manage + - description: "" + roles: admin + name: apim:subscription_view + key: apim:subscription_view + - description: "" + roles: admin + name: apim:subscription_block + key: apim:subscription_block + +###################################################### +# The "API Collection" resource APIs +###################################################### +paths: + /apis: + +#----------------------------------------------------- +# Retrieving the list of all APIs qualifying under a given search condition +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This sample API provides Account Status Validation\",\n \"name\": \"AccountVal\",\n \"context\": \"/account\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\",\n \"status\": \"PUBLISHED\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"name\": \"api1\",\n \"context\": \"/api1\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\",\n \"status\": \"PUBLISHED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + summary: | + Get all APIs + description: | + Get a list of available APIs qualifying under a given search condition. + parameters: + - $ref : '#/parameters/limit' + - $ref : '#/parameters/offset' + - name : query + in: query + description: | + **Search condition**. + + You can search in attributes by using an **"attribute:"** modifier. + + Eg. "provider:wso2" will match an API if the provider of the API contains "wso2". + + Supported attribute modifiers are [**version, context, status, + description, subcontext, doc, provider**] + + If no advanced attribute modifier has been specified, search will match the + given query string against API Name. + type: string + - $ref : "#/parameters/Accept" + - $ref : "#/parameters/If-None-Match" + tags: + - APIs + responses: + 200: + description: | + OK. + List of qualifying APIs is returned. + schema: + $ref: '#/definitions/APIList' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Create a new API +#----------------------------------------------------- + post: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer 40e486e50ce43407181fb4c570d2cac7\" -H \"Content-Type: application/json\" -X POST -d @data.json http://127.0.0.1:9763/api/am/publisher/v0.10/apis" + x-wso2-request: "{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\"\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b\nContent-Type: application/json\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"890a4f4d-09eb-4877-a323-57f6ce2ed79b\",\n \"status\": \"CREATED\"\n}" + summary: Create a new API + description: | + Create a new API + parameters: + - in: body + name: body + description: | + API object that needs to be added + required: true + schema: + $ref: '#/definitions/API' + - $ref: '#/parameters/Content-Type' + tags: + - APIs + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/API' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported Media Type. + The entity of the request was in a not supported format. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual API" resource APIs +###################################################### + /apis/{apiId}: + +#----------------------------------------------------- +# Retrieve the details of an API definition +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b" + x-wso2-response: "HTTP/1.1 200 OK\nDate: Mon, 22 Feb 2016 13:27:08 GMT\nContent-Type: application/json\nTransfer-Encoding: chunked\nServer: WSO2 Carbon Server\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"890a4f4d-09eb-4877-a323-57f6ce2ed79b\",\n \"status\": \"PUBLISHED\"\n}" + summary: Get API details + description: | + Get details of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Requested API is returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + schema: + $ref: '#/definitions/API' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update the definition of an API +#----------------------------------------------------- + put: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d @data.json http://127.0.0.1:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060" + x-wso2-request: "{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"verification\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Use this API to verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" + x-wso2-response: "HTTP/1.1 200 OK\nDate: Mon, 22 Feb 2016 13:31:35 GMT\nContent-Type: application/json\nTransfer-Encoding: chunked\nServer: WSO2 Carbon Server\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"verification\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Use this API to verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" + summary: Update an existing API + description: | + Update an existing API + parameters: + - $ref: '#/parameters/apiId' + - in: body + name: body + description: | + API object that needs to be added + required: true + schema: + $ref: '#/definitions/API' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Successful response with updated API object + schema: + $ref: '#/definitions/API' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete the definition of an API +#----------------------------------------------------- + delete: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X DELETE http://127.0.0.1:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete API + description: | + Delete an existing API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Resource successfully deleted. + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +################################################################ +# The swagger resource of "Individual API" resource APIs +################################################################ + + /apis/{apiId}/swagger: +#----------------------------------------------------- +# Retrieve the API swagger definition +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\nContent-Length: 329\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" + summary: Get API Definition + description: | + Get the swagger of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update the API swagger definition +#----------------------------------------------------- + put: + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -F apiDefinition=\"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\" -X PUT \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger\"" + x-wso2-request: "{\n \"paths\": {\n \"\\/*\": {\n \"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\n \"200\": {\n \"description\": \"OK\"\n }\n }\n }\n }\n },\n \"x-wso2-security\": {\n \"apim\": {\n \"x-wso2-scopes\": []\n }\n },\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" + summary: Update API Definition + description: | + Update an existing swagger definition of an API + parameters: + - $ref: '#/parameters/apiId' + - in: formData + name: apiDefinition + description: Swagger definition of the API + type: string + required: true + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Successful response with updated Swagger definition + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +################################################################ +# The thumbnail resource of "Individual API" resource APIs +################################################################ + + /apis/{apiId}/thumbnail: +#------------------------------------------------------------------------------------------------- +# Downloads a thumbnail image of an API +#------------------------------------------------------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail > image.jpg" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" + summary: Get the thumbnail image + description: | + Downloads a thumbnail image of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Thumbnail image returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#---------------------------------------------------------------------------- +# Upload a thumbnail image to a certain API +#---------------------------------------------------------------------------- + post: + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -X POST -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail -F file=@image.jpg" + x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail\r\nContent-Type: application/json\r\n\r\n{\r\n \"relativePath\": \"/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail\",\r\n \"mediaType\": \"image/jpeg\"\r\n}" + summary: Upload a thumbnail image + description: | + Upload a thumbnail image to an API. + parameters: + - $ref: '#/parameters/apiId' + - in: formData + name: file + description: Image to upload + type: file + required: true + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Image updated + schema: + $ref : '#/definitions/FileInfo' + headers: + Location: + description: | + The URL of the uploaded thumbnail image of the API. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Copy API" Processing Function resource API +###################################################### + /apis/copy-api: + +#----------------------------------------------------- +# Create a new API based on an already existing one +#----------------------------------------------------- + post: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0\"" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060\nContent-Type: application/json\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" + summary: Copy API + description: | + Create a new API by copying an existing API + parameters: + - name: newVersion + description: Version of the new API. + type: string + in: query + required: true + - $ref: '#/parameters/apiId-Q' + tags: + - APIs + responses: + 201: + description: | + Created. + Successful response with the newly created API as entity in the body. Location header contains URL of newly created API. + headers: + Location: + description: | + The URL of the newly created API. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + API to copy does not exist. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Change Lifecycle" Processing Function resource API +###################################################### + /apis/change-lifecycle: + +#----------------------------------------------------- +# Change the lifecycle of an API +#----------------------------------------------------- + post: + x-scope: apim:api_publish + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish\"" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Change API Status + description: | + Change the lifecycle of an API + parameters: + - name: action + description: | + The action to demote or promote the state of the API. + + Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] + + in: query + type: string + required: true + enum: + - Publish + - Deploy as a Prototype + - Demote to Created + - Demote to Prototyped + - Block + - Deprecate + - Re-Publish + - Retire + - name: lifecycleChecklist + description: | + + You can specify additional checklist items by using an **"attribute:"** modifier. + + Eg: "Deprecate Old Versions:true" will deprecate older versions of a particular API when it is promoted to + Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" + format. + + Supported checklist items are as follows. + 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. + 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. + + type: string + in: query + - $ref: '#/parameters/apiId-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - APIs + responses: + 200: + description: | + OK. + Lifecycle changed successfully. + headers: + ETag: + description: | + Entity Tag of the changed API. Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the API lifecycle has been modified the last time. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Document Collection" resource APIs +###################################################### + /apis/{apiId}/documents: + +#----------------------------------------------------- +# Retrieve the documents associated with an API that qualify under a search condition +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"4145df31-04f1-440c-8d08-68952874622c\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + summary: Get API Documents + description: | + Get a list of documents belonging to an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - API Document + responses: + 200: + description: | + OK. + Document list is returned. + schema: + $ref: '#/definitions/DocumentList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Add a document to a certain API +#----------------------------------------------------- + post: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer cdcc8cf6016ed10620edf3a1d3c5ef2b\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\"" + x-wso2-request: "{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" + summary: Add a new document + description: | + Add a new document to an API + parameters: + - $ref: '#/parameters/apiId' + - in: body + name: body + description: | + Document object that needs to be added + required: true + schema: + $ref: '#/definitions/Document' + - $ref: '#/parameters/Content-Type' + tags: + - API Document + responses: + 201: + description: | + Created. + Successful response with the newly created Document object as entity in the body. + Location header contains URL of newly added document. + schema: + $ref: '#/definitions/Document' + headers: + Location: + description: | + Location to the newly created Document. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported media type. + The entity of the request was in a not supported format. + +###################################################### +# The "Individual Document" resource APIs +###################################################### + '/apis/{apiId}/documents/{documentId}': + +#----------------------------------------------------- +# Retrieve a particular document of a certain API +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + summary: Get an API Document + description: | + Get a particular document associated with an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API Document + responses: + 200: + description: | + OK. + Document returned. + schema: + $ref: '#/definitions/Document' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update a particular document of a certain API +#----------------------------------------------------- + put: + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" + x-wso2-request: "{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + summary: Update an API Document + description: | + Update document details. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - in: body + name: body + description: | + Document object that needs to be added + required: true + schema: + $ref: '#/definitions/Document' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API Document + responses: + 200: + description: | + OK. + Document updated + schema: + $ref: '#/definitions/Document' + headers: + Location: + description: | + The URL of the updated document. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete a particular document of a certain API +#----------------------------------------------------- + delete: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X DELETE http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete an API Document + description: | + Delete a document of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API Document + responses: + 200: + description: | + OK. + Resource successfully deleted. + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +################################################################ +# The content resource of "Individual Document" resource APIs +################################################################ + + '/apis/{apiId}/documents/{documentId}/content': + + #------------------------------------------------------------------------------------------------- + # Downloads a FILE type document/get the inline content or source url of a certain document + #------------------------------------------------------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\" > sample.pdf" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" + summary: Get document content + description: | + Downloads a FILE type document/get the inline content or source url of a certain document. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API Document + responses: + 200: + description: | + OK. + File or inline content returned. + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 303: + description: | + See Other. + Source can be retrived from the URL specified at the Location header. + headers: + Location: + description: | + The Source URL of the document. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + + #---------------------------------------------------------------------------- + # Upload a file or add inline content to a document of a certain API + #---------------------------------------------------------------------------- + post: + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -F file=@\"sample.pdf\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\"" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\nContent-Type: application/json\n\n{\n \"visibility\":\"API_LEVEL\",\n \"sourceType\":\"FILE\",\n \"sourceUrl\":null,\n \"otherTypeName\":null,\n \"documentId\":\"daf732d3-bda2-46da-b381-2c39d901ea61\",\n \"summary\":\"This is a sample documentation pdf\",\n \"name\":\"Introduction to PhoneVerification API PDF\",\n \"type\":\"HOWTO\"\n}" + summary: Update API document content. + description: | + Upload a file to a document or add inline content to the document. + + Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. + Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. + + Only one of **file** or **inlineContent** can be specified at one time. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - in: formData + name: file + description: Document to upload + type: file + required: false + - in: formData + name: inlineContent + description: Inline content of the document + type: string + required: false + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API Document + responses: + 200: + description: | + OK. + Document updated + schema: + $ref: '#/definitions/Document' + headers: + Location: + description: | + The URL of the updated content of the document. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual Application" resource APIs +###################################################### + '/applications/{applicationId}': + +#----------------------------------------------------- +# Retrieve the details about a certain application +#----------------------------------------------------- + get: + x-scope: apim:api_create + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/applications/896658a0-b4ee-4535-bbfa-806c894a4015" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"name\": \"DefaultApplication\"\n}" + summary: Get Application + description: | + Get application details + parameters: + - $ref: '#/parameters/applicationId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Applications + responses: + 200: + description: | + OK. + Application returned. + schema: + $ref: '#/definitions/Application' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested application does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Subscription Collection" resource APIs +###################################################### + /subscriptions: + +#----------------------------------------------------- +# Retrieve all subscriptions of a certain API +#----------------------------------------------------- + get: + x-scope: apim:subscription_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"previous\": \"\",\n \"list\": [\n {\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"subscriptionId\": \"7ac22c34-8745-4cfe-91e0-262c50b2f2e3\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + summary: Get All Subscriptions + description: | + Get subscription list. + The API Identifier and corresponding Application Identifier + the subscriptions of which are to be returned are passed as parameters. + parameters: + - $ref: '#/parameters/apiId-Q' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Subscriptions + responses: + 200: + description: | + OK. + Subscription list returned. + schema: + $ref: '#/definitions/SubscriptionList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual Subscription" resource APIs +###################################################### + '/subscriptions/{subscriptionId}': + +#----------------------------------------------------- +# Retrieve a certain subscription +#----------------------------------------------------- + get: + x-scope: apim:subscription_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n}" + summary: Get a Subscription + description: | + Get subscription details + parameters: + - $ref: '#/parameters/subscriptionId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Subscriptions + responses: + 200: + description: | + OK. + Subscription returned + schema: + $ref: '#/definitions/Subscription' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: 'Entity Tag of the response resource. Used by caches, or in conditional requests.' + type: string + Last-Modified: + description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.' + type: string + '304': + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + '404': + description: | + Not Found. + Requested Subscription does not exist. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Block Subscription" Processing Function resource API +###################################################### + /subscriptions/block-subscription: + +#----------------------------------------------------- +# Block a certain subscription +#----------------------------------------------------- + post: + x-scope: apim:subscription_block + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"PROD_ONLY_BLOCKED\"\n}" + summary: Block a subscription + parameters: + - $ref: '#/parameters/subscriptionId-Q' + - name: blockState + in: query + description: | + Subscription block state. + type: string + required: true + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + description: | + Block a subscription. + tags: + - Subscriptions + responses: + 200: + description: | + OK. + Subscription was blocked successfully. + headers: + ETag: + description: | + Entity Tag of the blocked subscription. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the subscription has been blocked. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Requested subscription does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Unblock Subscription" Processing Function resource API +###################################################### + /subscriptions/unblock-subscription: + +#----------------------------------------------------- +# Unblock a certain subscription +#----------------------------------------------------- + post: + x-scope: apim:subscription_block + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n} " + summary: Unblock a Subscription + parameters: + - $ref: '#/parameters/subscriptionId-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + description: | + Unblock a subscription. + tags: + - Subscriptions + responses: + 200: + description: | + OK. + Subscription was unblocked successfully. + headers: + ETag: + description: | + Entity Tag of the unblocked subscription. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the subscription has been unblocked. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Requested subscription does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Tier Collection" resource APIs +###################################################### + '/tiers/{tierLevel}': + +#----------------------------------------------------- +# Retrieve the list of all available tiers +#----------------------------------------------------- + get: + x-scope: apim:tier_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"next\": \"\",\n \"count\": 4\n}" + summary: List Tiers + description: | + Get available tiers + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Tiers + responses: + 200: + description: | + OK. + List of tiers returned. + schema: + $ref: '#/definitions/TierList' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Create a new tier +#----------------------------------------------------- + post: + x-scope: apim:tier_manage + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api\"" + x-wso2-request: "{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\":10,\n \"b\":30\n }\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/tiers/Low\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"30\",\n \"a\": \"10\"\n }\n}" + summary: Add a new Tier + description: | + Add a new tier + parameters: + - in: body + name: body + description: | + Tier object that should to be added + required: true + schema: + $ref: '#/definitions/Tier' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Content-Type' + tags: + - Tiers + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/Tier' + headers: + Location: + description: | + Location of the newly created tier. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request' + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported media type. + The entity of the request was in a not supported format. + +###################################################### +# The "Individual Tier" resource APIs +###################################################### + '/tiers/{tierLevel}/{tierName}': + +#----------------------------------------------------- +# Retrieve a certain tier +#----------------------------------------------------- + get: + x-scope: apim:tier_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Bronze" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" + summary: Get a Tier + description: | + Get tier details + parameters: + - $ref: '#/parameters/tierName' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Tiers + responses: + 200: + description: | + OK. + Tier returned + schema: + $ref: '#/definitions/Tier' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Tier does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update a certain tier +#----------------------------------------------------- + put: + x-scope: apim:tier_manage + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Low\"" + x-wso2-request: "{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\": \"30\",\n \"b\": \"10\",\n \"c\": \"20\"\n }\n}\n" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"10\",\n \"c\": \"20\",\n \"a\": \"30\"\n }\n}" + summary: Update a Tier + description: | + Update tier details + parameters: + - $ref: '#/parameters/tierName' + - in: body + name: body + description: | + Tier object that needs to be modified + required: true + schema: + $ref: '#/definitions/Tier' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Tiers + responses: + 200: + description: | + OK. + Subscription updated. + schema: + $ref: '#/definitions/Tier' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete a certain tier +#----------------------------------------------------- + delete: + x-scope: apim:tier_manage + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Low\"" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete a Tier + description: | + Remove a tier + parameters: + - $ref: '#/parameters/tierName' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Tiers + responses: + 200: + description: | + OK. + Resource successfully deleted. + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Update Permission" Processing Function resource API +###################################################### + '/tiers/update-permission': + +#----------------------------------------------------- +# Update the permission of a certain tier +#----------------------------------------------------- + post: + x-scope: apim:tier_manage + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/update-permission?tierName=Bronze&tierLevel=api\"" + x-wso2-request: "{\n \"permissionType\":\"deny\",\n \"roles\": [\"Internal/everyone\",\"admin\"]\n}" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Update Tier Permission + description: | + Update tier permission + parameters: + - $ref: '#/parameters/tierName-Q' + - $ref: '#/parameters/tierLevel-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + - in: body + name: permissions + schema: + $ref: '#/definitions/TierPermission' + tags: + - Tiers + responses: + 200: + description: | + OK. + Successfully updated tier permissions + schema: + type: array + items: + $ref: '#/definitions/Tier' + headers: + ETag: + description: | + Entity Tag of the modified tier. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the tier has been modified. + Used by caches, or in conditional requests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Requested tier does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + + +###################################################### +# The "Environment Collection" resource API +###################################################### + /environments: + +#----------------------------------------------------- +# Retrieve the list of environments configured for a certain API +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/environments\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"list\": [ {\n \"showInApiConsole\": true,\n \"serverUrl\": \"https://192.168.56.1:9444//services/\",\n \"endpoints\": {\n \"http\": \"http://192.168.56.1:8281\",\n \"https\": \"https://192.168.56.1:8244\"\n },\n \"name\": \"Production and Sandbox\",\n \"type\": \"hybrid\"\n }],\n \"count\": 1\n}" + summary: Get gateway environments + description: | + Get a list of gateway environments configured previously. + parameters: + - in: query + name: apiId + description: | + Will return environment list for the provided API. + type: string + tags: + - Environments + responses: + 200: + description: | + OK. + Environment list is returned. + schema: + $ref: '#/definitions/EnvironmentList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' +###################################################### +# Parameters - required by some of the APIs above +###################################################### +parameters: + +# API Identifier +# Specified as part of the path expression + apiId: + name: apiId + in: path + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. + Should be formatted as **provider-name-version**. + required: true + type: string + +# API Identifier +# Specified as part of the query string + apiId-Q: + name: apiId + in: query + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + required: true + type: string + + +# Document Identifier +# Specified as part of the path expression + documentId: + name: documentId + in: path + description: | + **Document Identifier** + required: true + type: string + +# Application Identifier +# Specified as part of the path expression + applicationId: + name: applicationId + in: path + description: | + **Application Identifier** consisting of the UUID of the Application. + required: true + type: string + +# Subscription Identifier +# Specified as part of the path expression + subscriptionId: + name: subscriptionId + in: path + description: | + Subscription Id + required: true + type: string + +# Subscription Identifier +# Specified as part of the query string + subscriptionId-Q: + name: subscriptionId + in: query + description: | + Subscription Id + required: true + type: string + +# Tier Name +# Specified as part of the path expression + tierName: + name: tierName + in: path + description: | + Tier name + required: true + type: string + +# Tier Name +# Specified as part of the query string + tierName-Q: + name: tierName + in: query + description: | + Name of the tier + required: true + type: string + +# Tier Type +# Specified as part of the path expression + tierLevel: + name: tierLevel + in: path + description: | + List API or Application or Resource type tiers. + type: string + enum: + - api + - application + - resource + required: true + +# Tier Type +# Specified as part of the query string + tierLevel-Q: + name: tierLevel + in: query + description: | + List API or Application or Resource type tiers. + type: string + enum: + - api + - application + - resource + required: true + +# Used for pagination: +# The maximum number of resoures to be returned by a GET + limit: + name: limit + in: query + description: | + Maximum size of resource array to return. + default: 25 + type: integer + +# Used for pagination: +# The order number of an instance in a qualified set of resoures +# at which to start to return the next batch of qualified resources + offset: + name: offset + in: query + description: | + Starting point within the complete list of items qualified. + default: 0 + type: integer + +# The HTTP Accept header + Accept: + name: Accept + in: header + description: | + Media types acceptable for the response. Default is JSON. + default: JSON + type: string + +# The HTTP Content-Type header + Content-Type: + name: Content-Type + in: header + description: | + Media type of the entity in the body. Default is JSON. + default: JSON + required: true + type : string + +# The HTTP If-None-Match header +# Used to avoid retrieving data that are already cached + If-None-Match: + name: If-None-Match + in: header + description: | + Validator for conditional requests; based on the ETag of the formerly retrieved + variant of the resourec. + type : string + +# The HTTP If-Modified-Since header +# Used to avoid retrieving data that are already cached + If-Modified-Since: + name: If-Modified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header of the + formerly retrieved variant of the resource. + type: string + +# The HTTP If-Match header +# Used to avoid concurrent updates + If-Match: + name: If-Match + in: header + description: | + Validator for conditional requests; based on ETag. + type: string + +# The HTTP If-Unmodified-Since header +# Used to avoid concurrent updates + If-Unmodified-Since: + name: If-Unmodified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header. + type: string + +###################################################### +# The resources used by some of the APIs above within the message body +###################################################### +definitions: + +#----------------------------------------------------- +# The API List resource +#----------------------------------------------------- + APIList: + title: API List + properties: + count: + type: integer + description: | + Number of APIs returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis?limit=1&offset=2&query=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis?limit=1&offset=0&query=" + list: + type: array + items: + $ref: '#/definitions/APIInfo' + +#----------------------------------------------------- +# The API Info resource +#----------------------------------------------------- + APIInfo: + title: API Info object with basic API details. + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI + description: + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + type: string + example: admin + status: + type: string + example: CREATED + +#----------------------------------------------------- +# The API resource +#----------------------------------------------------- + API: + title: API object + required: + - name + - context + - version + - apiDefinition + - tiers + - isDefaultVersion + - transport + - endpointConfig + - visibility + properties: + id: + type: string + description: | + UUID of the api registry artifact + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI + description: + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + description: | + If the provider value is not given user invoking the api will be used as the provider. + type: string + example: admin + apiDefinition: + description: | + Swagger definition of the API which contains details about URI templates and scopes + type: string + wsdlUri: + description: | + WSDL URL if the API is based on a WSDL endpoint + type: string + example: "http://www.webservicex.com/globalweather.asmx?wsdl" + status: + type: string + example: CREATED + responseCaching: + type: string + example: Disabled + cacheTimeout: + type: integer + example: 300 + destinationStatsEnabled: + type: string + example: Disabled + isDefaultVersion: + type: boolean + example: false + transport: + description: | + Supported transports for the API (http and/or https). + type: array + items: + type: string + example: ["http","https"] + tags: + type: array + items: + type: string + example: ["substract","add"] + tiers: + type: array + items: + type: string + example: ["Unlimited"] + maxTps: + properties: + production: + type: integer + format: int64 + example: 1000 + sandbox: + type: integer + format: int64 + example: 1000 + thumbnailUri: + type: string + example: "/apis/01234567-0123-0123-0123-012345678901/thumbnail" + visibility: + type: string + enum: + - PUBLIC + - PRIVATE + - RESTRICTED + - CONTROLLED + example: PUBLIC + visibleRoles: + type: array + items: + type: string + example: [] + visibleTenants: + type: array + items: + type: string + example: [] + endpointConfig: + type: string + example: "{\"production_endpoints\":{\"url\":\"http://localhost:9763/am/sample/calculator/v1/api\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}" + endpointSecurity: + properties: + type: + type: string + example: basic + enum: + - basic + - digest + username: + type: string + example: admin + password: + type: string + example: password + gatewayEnvironments: + description: | + Comma separated list of gateway environments. + type: string + example: Production and Sandbox + sequences: + type: array + items: + $ref: '#/definitions/Sequence' + example: [] + subscriptionAvailability: + type: string + enum: + - current_tenant + - all_tenants + - specific_tenants + example: current_tenant + subscriptionAvailableTenants: + type: array + items: + type: string + example: [] + businessInformation: + properties: + businessOwner: + type: string + example: businessowner + businessOwnerEmail: + type: string + example: businessowner@wso2.com + technicalOwner: + type: string + example: technicalowner + technicalOwnerEmail: + type: string + example: technicalowner@wso2.com + corsConfiguration: + description: | + CORS configuration for the API + properties: + corsConfigurationEnabled: + type: boolean + default: false + accessControlAllowOrigins: + type: array + items: + type: string + accessControlAllowCredentials: + type: boolean + default: false + accessControlAllowHeaders: + type: array + items: + type: string + accessControlAllowMethods: + type: array + items: + type: string + +#----------------------------------------------------- +# The Application resource +#----------------------------------------------------- + Application: + title: Application + required: + - name + - throttlingTier + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + type: string + example: admin + throttlingTier: + type: string + example: Unlimited + description: + type: string + example: Sample calculator application + groupId: + type: string + example: "" + +#----------------------------------------------------- +# The Document List resource +#----------------------------------------------------- + DocumentList: + title: Document List + properties: + count: + type: integer + description: | + Number of Documents returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Document' + +#----------------------------------------------------- +# The Document resource +#----------------------------------------------------- + Document: + title: Document + required: + - name + - type + - sourceType + - visibility + properties: + documentId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorDoc + type: + type: string + enum: + - HOWTO + - SAMPLES + - PUBLIC_FORUM + - SUPPORT_FORUM + - API_MESSAGE_FORMAT + - SWAGGER_DOC + - OTHER + example: HOWTO + summary: + type: string + example: "Summary of Calculator Documentation" + sourceType: + type: string + enum: + - INLINE + - URL + - FILE + example: INLINE + sourceUrl: + type: string + example: "" + otherTypeName: + type: string + example: "" + visibility: + type: string + enum: + - OWNER_ONLY + - PRIVATE + - API_LEVEL + example: API_LEVEL + +#----------------------------------------------------- +# The Tier List resource +#----------------------------------------------------- + TierList: + title: Tier List + properties: + count: + type: integer + description: | + Number of Tiers returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/tiers/api?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/tiers/api?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Tier' + +#----------------------------------------------------- +# The Tier resource +#----------------------------------------------------- + Tier: + title: Tier + required: + - name + - tierPlan + - requestCount + - unitTime + - stopOnQuotaReach + properties: + name: + type: string + example: Platinum + description: + type: string + example: "Allows 50 request(s) per minute." + tierLevel: + type: string + enum: + - api + - application + - resource + example: api + attributes: + description: | + Custom attributes added to the tier policy + type: object + additionalProperties: + type: string + example: {} + requestCount: + description: | + Maximum number of requests which can be sent within a provided unit time + type: integer + format: int64 + example: 50 + unitTime: + type: integer + format: int64 + example: 60000 + timeUnit: + type: string + example: "min" + tierPlan: + description: | + This attribute declares whether this tier is available under commercial or free + type: string + enum: + - FREE + - COMMERCIAL + example: FREE + stopOnQuotaReach: + description: | + By making this attribute to false, you are capabale of sending requests + even if the request count exceeded within a unit time + type: boolean + example: true + +#----------------------------------------------------- +# The Tier Permission resource +#----------------------------------------------------- + TierPermission: + title: tierPermission + required: + - permissionType + - roles + properties: + permissionType: + type: string + enum: + - allow + - deny + example: deny + roles: + type: array + items: + type: string + example: ["Internal/everyone"] + +#----------------------------------------------------- +# The Subscription List resource +#----------------------------------------------------- + SubscriptionList: + title: Subscription List + properties: + count: + type: integer + description: | + Number of Subscriptions returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" + list: + type: array + items: + $ref: '#/definitions/Subscription' + +#----------------------------------------------------- +# The Subscription resource +#----------------------------------------------------- + Subscription: + title: Subscription + required: + - applicationId + - apiIdentifier + - tier + properties: + subscriptionId: + type: string + example: 01234567-0123-0123-0123-012345678901 + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + apiIdentifier: + type: string + example: 01234567-0123-0123-0123-012345678901 + tier: + type: string + example: Unlimited + status: + type: string + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - UNBLOCKED + - ON_HOLD + - REJECTED + example: UNBLOCKED + +#----------------------------------------------------- +# The Sequence resource +#----------------------------------------------------- + Sequence: + title: Sequence + required: + - name + properties: + name: + type: string + example: log_in_message + config: + type: string + example: "" + type: + type: string + example: in + +#----------------------------------------------------- +# The Error resource +#----------------------------------------------------- + Error: + title: Error object returned with 4XX HTTP status + required: + - code + - message + properties: + code: + type: integer + format: int64 + message: + type: string + description: Error message. + description: + type: string + description: | + A detail description about the error message. + moreInfo: + type: string + description: | + Preferably an url with more details about the error. + error: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/definitions/ErrorListItem' + +#----------------------------------------------------- +# The Error List Item resource +#----------------------------------------------------- + ErrorListItem: + title: Description of individual errors that may have occurred during a request. + required: + - code + - message + properties: + code: + type: string + message: + type: string + description: | + Description about individual errors occurred + +#----------------------------------------------------- +# The Environment resource +#----------------------------------------------------- + Environment: + title: Environment + required: + - name + - type + - serverUrl + - endpoints + - showInApiConsole + properties: + name: + type: string + example: Production and Sandbox + type: + type: string + example: hybrid + serverUrl: + type: string + example: "https://localhost:9443//services/" + showInApiConsole: + type: boolean + example: true + endpoints: + $ref: '#/definitions/EnvironmentEndpoints' + +#----------------------------------------------------- +# The Environment List resource +#----------------------------------------------------- + EnvironmentList: + title: Environment List + properties: + count: + type: integer + description: | + Number of Environments returned. + example: 1 + list: + type: array + items: + $ref: '#/definitions/Environment' + + +#----------------------------------------------------- +# The Environment Endpoint resource +#----------------------------------------------------- + EnvironmentEndpoints : + title: Environment Endpoints + properties: + http: + type: string + description: HTTP environment URL + example: "http://localhost:8280" + https: + type: string + description: HTTPS environment URL + example: "https://localhost:8244" + +#----------------------------------------------------- +# The File Information resource +#----------------------------------------------------- + FileInfo : + title: File Information including meta data + properties: + relativePath: + type: string + description: relative location of the file (excluding the base context and host of the Publisher API) + example: "apis/01234567-0123-0123-0123-012345678901/thumbnail" + mediaType: + type: string + description: media-type of the file + example: "image/jpeg" diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml new file mode 100644 index 00000000000..47514272218 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml @@ -0,0 +1,176 @@ + + + + + + apimgt-extensions + org.wso2.carbon.devicemgt + 2.0.8-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.apimgt.store.client + bundle + org.wso2.carbon.apimgt.store.client + + + + + io.swagger + swagger-codegen-maven-plugin + 2.2.1 + + + + generate + + + ${project.basedir}/src/main/resources/store-api.yaml + java + + ${project.artifactId}.api + ${project.artifactId}.model + ${project.artifactId}.invoker + + feign + + + + + + maven-antrun-plugin + 1.4 + + + copy + process-resources + + + + + + + + + + + + + + run + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${project.version} + APIM Integration + + org.wso2.carbon.apimgt.store.client.model, + org.wso2.carbon.apimgt.store.client.api, + org.wso2.carbon.apimgt.store.client.invoker + + + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.logging, + io.swagger, + junit, + javax.ws.rs, + feign, + feign.jackson, + feign.codec, + feign.auth, + feign.gson, + feign.slf4j, + feign.jaxrs, + com.google.gson, + com.fasterxml.jackson.core, + com.fasterxml.jackson.annotation, + com.fasterxml.jackson.databind, + com.fasterxml.jackson.datatype.joda, i + o.swagger.annotations, + javax.net.ssl, + org.apache.oltu.oauth2.client.*, + org.apache.oltu.oauth2.common.*, + org.junit;resolution:=optional + + + + + + + + + + + + + + io.swagger + swagger-annotations + + + junit + junit + + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-gson + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-annotations + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + org.wso2.orbit.joda-time + joda-time + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + + + io.github.openfeign + feign-jackson + + + io.github.openfeign + feign-slf4j + + + + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml new file mode 100644 index 00000000000..b591fc3597c --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml @@ -0,0 +1,2098 @@ +swagger: '2.0' +###################################################### +# Prolog +###################################################### +info: + version: "0.10.0" + title: "WSO2 API Manager - Store" + description: | + This document specifies a **RESTful API** for WSO2 **API Manager** - Store. + + It is written with [swagger 2](http://swagger.io/). + + contact: + name: "WSO2" + url: "http://wso2.com/products/api-manager/" + email: "architecture@wso2.com" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" + +###################################################### +# The fixed parts of the URLs of the API +###################################################### + +# The schemes supported by the API +schemes: + - https + +# The domain of the API. +# This is configured by the customer during deployment. +# The given host is just an example. +host: apis.wso2.com + +# The base path of the API. +# Will be prefixed to all paths. +basePath: /api/am/store/v0.10 + +# The following media types can be passed as input in message bodies of the API. +# The actual media type must be specified in the Content-Type header field of the request. +# The default is json, i.e. the Content-Type header is not needed to +# be set, but supporting it serves extensibility. +consumes: + - application/json + +# The following media types may be passed as output in message bodies of the API. +# The media type(s) consumable by the requestor is specified in the Accept header field +# of the corresponding request. +# The actual media type returned will be specfied in the Content-Type header field +# of the of the response. +# The default of the Accept header is json, i.e. there is not needed to +# set the value, but supporting it serves extensibility. +produces: + - application/json + +x-wso2-security: + apim: + x-wso2-scopes: + - description: "" + roles: Internal/subscriber + name: apim:subscribe + key: apim:subscribe + +###################################################### +# The "API Collection" resource APIs +###################################################### +paths: + /apis: + +#----------------------------------------------------- +# Retrieving the list of all APIs qualifying under a given search condition +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This API provide Account Status Validation.\",\n \"status\": \"PUBLISHED\",\n \"name\": \"AccountVal\",\n \"context\": \"/account/1.0.0\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"status\": \"PUBLISHED\",\n \"name\": \"api1\",\n \"context\": \"/api1/1.0.0\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"status\": \"PUBLISHED\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify/2.0.0\",\n \"id\": \"c43a325c-260b-4302-81cb-768eafaa3aed\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" + summary: | + Retrieving APIs + description: | + Get a list of available APIs qualifying under a given search condition. + parameters: + - $ref : '#/parameters/limit' + - $ref : '#/parameters/offset' + - $ref : '#/parameters/requestedTenant' + - name : query + in: query + description: | + **Search condition**. + + You can search in attributes by using an **"attribute:"** modifier. + + Eg. + "provider:wso2" will match an API if the provider of the API is exactly "wso2". + + Additionally you can use wildcards. + + Eg. + "provider:wso2\*" will match an API if the provider of the API starts with "wso2". + + Supported attribute modifiers are [**version, context, status, + description, subcontext, doc, provider, tag**] + + If no advanced attribute modifier has been specified, search will match the + given query string against API Name. + type: string + - $ref : "#/parameters/Accept" + - $ref : "#/parameters/If-None-Match" + tags: + - apisAPI + responses: + 200: + description: | + OK. + List of qualifying APIs is returned. + schema: + $ref: '#/definitions/APIList' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual API" resource APIs +###################################################### + /apis/{apiId}: + +#----------------------------------------------------- +# Retrieve the details of an API definition +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"isDefaultVersion\": false,\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"status\": \"PUBLISHED\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify/2.0.0\",\n \"id\": \"c43a325c-260b-4302-81cb-768eafaa3aed\"\n}" + summary: | + Get Details of API + description: | + Get details of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + - $ref: '#/parameters/requestedTenant' + tags: + - API (individual) + responses: + 200: + description: | + OK. + Requested API is returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + schema: + $ref: '#/definitions/API' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + + + /apis/{apiId}/swagger: +#----------------------------------------------------- +# Retrieve the API swagger definition +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/swagger" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"2.0.0\"\n }\n}\n" + summary: | + Get the swagger of an API + description: | + Get the swagger of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + - $ref: '#/parameters/requestedTenant' + tags: + - API (individual) + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Document Collection" resource APIs +###################################################### + /apis/{apiId}/documents: + +#----------------------------------------------------- +# Retrieve the documents associated with an API that qualify under a search condition +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"98e18be8-5861-43c7-ba26-8cbbccd3a76f\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n },\n {\n \"sourceType\": \"FILE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"b66451ff-c6c2-4f6a-b91d-3821dc119b04\",\n \"summary\": \"This is a sample documentation pdf\",\n \"name\": \"Introduction to PhoneVerification API PDF\",\n \"type\": \"HOWTO\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" + summary: | + Get a list of documents belonging to an API. + description: | + Get a list of documents belonging to an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - API (individual) + responses: + 200: + description: | + OK. + Document list is returned. + schema: + $ref: '#/definitions/DocumentList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual Document" resource APIs +###################################################### + '/apis/{apiId}/documents/{documentId}': + +#----------------------------------------------------- +# Retrieve a particular document of a certain API +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + summary: | + Get a particular document associated with an API. + description: | + Get a particular document associated with an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (individual) + responses: + 200: + description: | + OK. + Document returned. + schema: + $ref: '#/definitions/Document' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + + +################################################################ +# The content resource of "Individual Document" resource APIs +################################################################ + + '/apis/{apiId}/documents/{documentId}/content': + + #------------------------------------------------------------------------------------------------- + # Downloads a FILE type document/get the inline content or source url of a certain document + #------------------------------------------------------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content\" > sample.pdf" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" + summary: | + Downloads a FILE type document/get the inline content or source url of a certain document. + description: | + Downloads a FILE type document/get the inline content or source url of a certain document. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (individual) + responses: + 200: + description: | + OK. + File or inline content returned. + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 303: + description: | + See Other. + Source can be retrived from the URL specified at the Location header. + headers: + Location: + description: | + The Source URL of the document. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +################################################################ +# The thumbnail resource of "Individual API" resource APIs +################################################################ + + /apis/{apiId}/thumbnail: +#------------------------------------------------------------------------------------------------- +# Downloads a thumbnail image of an API +#------------------------------------------------------------------------------------------------- + get: + x-wso2-curl: "curl http://127.0.0.1:9763/api/am/store/v0.10/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail > image.jpg" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" + summary: Get the thumbnail image + description: | + Downloads a thumbnail image of an API + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (individual) + responses: + 200: + description: | + OK. + Thumbnail image returned + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Application Collection" resource APIs +###################################################### + /applications: + +#----------------------------------------------------- +# Retrieve a list of all applications of a certain subscriber +#----------------------------------------------------- + get: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/applications\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"description\": \"\",\n \"status\": \"APPROVED\",\n \"name\": \"app1\"\n },\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" + summary: | + Get a list of applications + description: | + Get a list of applications + parameters: + - $ref: '#/parameters/groupId' + - name : query + in: query + description: | + **Search condition**. + + You can search for an application by specifying the name as "query" attribute. + + Eg. + "app1" will match an application if the name is exactly "app1". + + Currently this does not support wildcards. Given name must exactly match the application name. + type: string + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Application Collection + responses: + 200: + description: | + OK. + Application list returned. + schema: + $ref: '#/definitions/ApplicationList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Create a new application +#----------------------------------------------------- + post: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications\"" + x-wso2-request: "{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"description\": \"sample app description\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\"\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/store/v0.10/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": null,\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" + summary: | + Create a new application. + description: | + Create a new application. + parameters: + - in: body + name: body + description: | + Application object that is to be created. + required: true + schema: + $ref: '#/definitions/Application' + - $ref: '#/parameters/Content-Type' + tags: + - Application (individual) + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/Application' + headers: + Location: + description: | + Location of the newly created Application. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 409: + description: | + Conflict. + Application already exists. + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported media type. + The entity of the request was in a not supported format. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual Application" resource APIs +###################################################### + '/applications/{applicationId}': + +#----------------------------------------------------- +# Retrieve the details about a certain application +#----------------------------------------------------- + get: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/applications/896658a0-b4ee-4535-bbfa-806c894a4015\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"callbackUrl\": null,\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\",\n \"keys\": [ {\n \"consumerKey\": \"AVoREWiB16kY_GTIzscl40GYYZQa\",\n \"consumerSecret\": \"KXQxmS8W3xDvvJH4AfR6xrhKIeIa\",\n \"keyState\": \"COMPLETED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": null,\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"3887da6d111f0429c6dff47a46e87209\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n }]\n}" + summary: | + Get application details + description: | + Get application details + parameters: + - $ref: '#/parameters/applicationId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Application (individual) + responses: + 200: + description: | + OK. + Application returned. + schema: + $ref: '#/definitions/Application' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested application does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update a certain application +#----------------------------------------------------- + put: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" + x-wso2-request: "{\n \"groupId\": null,\n \"callbackUrl\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Bronze\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description updated\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\"\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Bronze\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description updated\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" + summary: | + Update application details + description: | + Update application details + parameters: + - $ref: '#/parameters/applicationId' + - in: body + name: body + description: | + Application object that needs to be updated + required: true + schema: + $ref: '#/definitions/Application' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Application (individual) + responses: + 200: + description: | + OK. + Application updated. + schema: + $ref: '#/definitions/Application' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete a certain application +#----------------------------------------------------- + delete: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -X DELETE \"http://127.0.0.1:9763/api/am/store/v0.10/applications/367a2361-8db5-4140-8133-c6c8dc7fa0c4\"" + x-wso2-response: "HTTP/1.1 200 OK" + summary: | + Remove an application + description: | + Remove an application + parameters: + - $ref: '#/parameters/applicationId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Application (individual) + responses: + 200: + description: | + OK. + Resource successfully deleted. + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Generate Keys" Processing Function resource API +###################################################### + '/applications/generate-keys': + +#----------------------------------------------------- +# Generate keys for an application +#----------------------------------------------------- + post: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications/generate-keys?applicationId=c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" + x-wso2-request: "{\n \"validityTime\": \"3600\",\n \"keyType\": \"PRODUCTION\",\n \"accessAllowDomains\": [\"ALL\"\n ]\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"consumerSecret\": \"8V7DDKtKGtuG_9GDjaOJ5sijdX0a\",\n \"consumerKey\": \"LOFL8He72MSGVil4SS_bsh9O8MQa\",\n \"keyState\": \"APPROVED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": [\n \"urn:ietf:params:oauth:grant-type:saml2-bearer\",\n \"iwa:ntlm\",\n \"refresh_token\",\n \"client_credentials\",\n \"password\"\n ],\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"fd2cdc4906fbc162e033d57f85a71c21\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n}" + description: | + Generate keys for application + summary: | + Generate keys for application + parameters: + - $ref: '#/parameters/applicationId-Q' + - in: body + name: body + description: | + Application object the keys of which are to be generated + required: true + schema: + $ref: '#/definitions/ApplicationKeyGenerateRequest' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Application (individual) + responses: + 200: + description: | + OK. + Keys are generated. + schema: + $ref: '#/definitions/ApplicationKey' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional request. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests.‚ + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Subscription Collection" resource APIs +###################################################### + /subscriptions: + +#----------------------------------------------------- +# Retrieve all subscriptions of a certain API and application +#----------------------------------------------------- + get: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"03b8ef2b-5ae5-41f5-968e-52fa7fbd5d33\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"5ed42650-9f5e-4dd4-94f3-3f09f1b17354\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"846118a5-3b25-4c22-a983-2d0278936f09\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" + summary: | + Get subscription list. + description: | + Get subscription list. + The API Identifier or Application Identifier + the subscriptions of which are to be returned are passed as parameters. + parameters: + - $ref: '#/parameters/apiId-Q' + - $ref: '#/parameters/applicationId-Q' + - $ref: '#/parameters/groupId' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Subscription Collection + responses: + 200: + description: | + OK. + Subscription list returned. + schema: + $ref: '#/definitions/SubscriptionList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Create a new subscription +#----------------------------------------------------- + post: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions\"" + x-wso2-request: "{\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"c43a325c-260b-4302-81cb-768eafaa3aed\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\"\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" + summary: | + Add a new subscription + description: | + Add a new subscription + parameters: + - in: body + name: body + description: | + Subscription object that should to be added + required: true + schema: + $ref: '#/definitions/Subscription' + - $ref: '#/parameters/Content-Type' + tags: + - Subscription (individual) + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/Subscription' + headers: + Location: + description: | + Location to the newly created subscription. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported media type. + The entity of the request was in a not supported format. + +###################################################### +# The "Individual Subscription" resource APIs +###################################################### + '/subscriptions/{subscriptionId}': + +#----------------------------------------------------- +# Retrieve a certain subscription +#----------------------------------------------------- + get: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" + description: | + Get subscription details + summary: | + Get subscription details + parameters: + - $ref: '#/parameters/subscriptionId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Subscription (individual) + responses: + 200: + description: | + OK. + Subscription returned + schema: + $ref: '#/definitions/Subscription' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: 'Entity Tag of the response resource. Used by caches, or in conditional requests.' + type: string + Last-Modified: + description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.' + type: string + '304': + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + '404': + description: | + Not Found. + Requested Subscription does not exist. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete a certain subscription +#----------------------------------------------------- + delete: + x-scope: apim:subscribe + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -X DELETE \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" + x-wso2-response: "HTTP/1.1 200 OK" + summary: | + Remove subscription + description: | + Remove subscription + parameters: + - $ref: '#/parameters/subscriptionId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Subscription (individual) + responses: + 200: + description: | + OK. + Resource successfully deleted. + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Tier Collection" resource APIs +###################################################### + /tiers/{tierLevel}: + +#----------------------------------------------------- +# Retrieve the list of all available tiers +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tiers/api\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"count\": 4,\n \"next\": \"\"\n}" + description: | + Get available tiers + summary: | + Get available tiers + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Tier Collection + responses: + 200: + description: | + OK. + List of tiers returned. + schema: + type: array + items: + $ref: '#/definitions/TierList' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual Tier" resource APIs +###################################################### + '/tiers/{tierLevel}/{tierName}': + +#----------------------------------------------------- +# Retrieve a certain tier +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tiers/api/Bronze\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" + description: | + Get tier details + summary: | + Get tier details + parameters: + - $ref: '#/parameters/tierName' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Tier (individual) + responses: + 200: + description: | + OK. + Tier returned + schema: + $ref: '#/definitions/Tier' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional reuquests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. + Requested Tier does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Tag Collection" resource API +###################################################### + /tags: + +#----------------------------------------------------- +# Retrieve the list of tags qualifying under a search condition +#----------------------------------------------------- + get: + x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tags\"" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"weight\": 1,\n \"name\": \"mobile\"\n },\n {\n \"weight\": 1,\n \"name\": \"multimedia\"\n },\n {\n \"weight\": 1,\n \"name\": \"phone\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" + description: | + Get a list of tags that are already added to APIs + summary: | + Get a list of tags that are already added to APIs + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/requestedTenant' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Tag Collection + responses: + 200: + description: | + OK. + Tag list is returned. + schema: + $ref: '#/definitions/TagList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + 404: + description: | + Not Found. Requested API does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +###################################################### +# Parameters - required by some of the APIs above +###################################################### +parameters: + +# Requested Tenant domain +# Specified as a header parameter + requestedTenant: + name: X-WSO2-Tenant + in: header + description: | + For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be + retirieved from. + required: false + type: string + +# API Identifier +# Specified as part of the path expression + apiId: + name: apiId + in: path + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. + Should be formatted as **provider-name-version**. + required: true + type: string + +# API Identifier +# Specified as part of the query string + apiId-Q: + name: apiId + in: query + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + required: true + type: string + + +# Document Identifier +# Specified as part of the path expression + documentId: + name: documentId + in: path + description: | + **Document Identifier** + required: true + type: string + +# Application Identifier +# Specified as part of the path expression + applicationId: + name: applicationId + in: path + description: | + **Application Identifier** consisting of the UUID of the Application. + required: true + type: string + +# Application Identifier +# Specified as part of the query string + applicationId-Q: + name: applicationId + in: query + description: | + **Application Identifier** consisting of the UUID of the Application. + required: true + type: string + +# Group Identifier of the application + groupId: + name: groupId + in: query + description: | + Application Group Id + required: false + type: string + +# Subscription Identifier +# Specified as part of the path expression + subscriptionId: + name: subscriptionId + in: path + description: | + Subscription Id + required: true + type: string + +# Tier Name +# Specified as part of the path expression + tierName: + name: tierName + in: path + description: | + Tier name + required: true + type: string + +# Tier Type +# Specified as part of the path expression + tierLevel: + name: tierLevel + in: path + description: | + List API or Application type tiers. + type: string + enum: + - api + - application + required: true + +# Used for pagination: +# The maximum number of resoures to be returned by a GET + limit: + name: limit + in: query + description: | + Maximum size of resource array to return. + default: 25 + type: integer + +# Used for pagination: +# The order number of an instance in a qualified set of resoures +# at which to start to return the next batch of qualified resources + offset: + name: offset + in: query + description: | + Starting point within the complete list of items qualified. + default: 0 + type: integer + +# The HTTP Accept header + Accept: + name: Accept + in: header + description: | + Media types acceptable for the response. Default is JSON. + default: JSON + type: string + +# The HTTP Content-Type header + Content-Type: + name: Content-Type + in: header + description: | + Media type of the entity in the body. Default is JSON. + default: JSON + required: true + type : string + +# The HTTP If-None-Match header +# Used to avoid retrieving data that are already cached + If-None-Match: + name: If-None-Match + in: header + description: | + Validator for conditional requests; based on the ETag of the formerly retrieved + variant of the resourec. + type : string + +# The HTTP If-Modified-Since header +# Used to avoid retrieving data that are already cached + If-Modified-Since: + name: If-Modified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header of the + formerly retrieved variant of the resource. + type: string + +# The HTTP If-Match header +# Used to avoid concurrent updates + If-Match: + name: If-Match + in: header + description: | + Validator for conditional requests; based on ETag. + type: string + +# The HTTP If-Unmodified-Since header +# Used to avoid concurrent updates + If-Unmodified-Since: + name: If-Unmodified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header. + type: string + +###################################################### +# The resources used by some of the APIs above within the message body +###################################################### +definitions: + +#----------------------------------------------------- +# The API List resource +#----------------------------------------------------- + APIList: + title: API List + properties: + count: + type: integer + description: | + Number of APIs returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis?limit=1&offset=2&query=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis?limit=1&offset=0&query=" + list: + type: array + items: + $ref: '#/definitions/APIInfo' + +#----------------------------------------------------- +# The API Info resource +#----------------------------------------------------- + APIInfo: + title: API Info object with basic API details. + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI + description: + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + type: string + example: admin + status: + type: string + example: PUBLISHED + +#----------------------------------------------------- +# The API resource +#----------------------------------------------------- + API: + title: API object + required: + - name + - context + - version + - provider + - status + - apiDefinition + properties: + id: + type: string + description: | + UUID of the api registry artifact + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI + description: + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + description: | + If the provider value is not given user invoking the api will be used as the provider. + type: string + example: admin + apiDefinition: + description: | + Swagger definition of the API which contains details about URI templates and scopes + type: string + example: "" + wsdlUri: + description: | + WSDL URL if the API is based on a WSDL endpoint + type: string + example: "http://www.webservicex.com/globalweather.asmx?wsdl" + status: + type: string + example: PUBLISHED + isDefaultVersion: + type: boolean + example: false + transport: + type: array + items: + description: | + Supported transports for the API (http and/or https). + type: string + example: ["http","https"] + tags: + type: array + items: + type: string + example: ["substract","add"] + tiers: + type: array + items: + type: string + example: ["Unlimited"] + thumbnailUrl: + type: string + example: "" + endpointURLs: + type: array + items: + properties: + environmentName: + type: string + example: Production and Sandbox + environmentType: + type: string + example: hybrid + environmentURLs: + properties: + http: + type: string + description: HTTP environment URL + example: "http://192.168.56.1:8280/phoneverify/1.0.0" + https: + type: string + description: HTTPS environment URL + example: "https://192.168.56.1:8243/phoneverify/1.0.0" + businessInformation: + properties: + businessOwner: + type: string + example: businessowner + businessOwnerEmail: + type: string + example: businessowner@wso2.com + technicalOwner: + type: string + example: technicalowner + technicalOwnerEmail: + type: string + example: technicalowner@wso2.com + +#----------------------------------------------------- +# The Application List resource +#----------------------------------------------------- + ApplicationList: + title: Application List + properties: + count: + type: integer + description: | + Number of applications returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/applications?limit=1&offset=2&groupId=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/applications?limit=1&offset=0&groupId=" + list: + type: array + items: + $ref: '#/definitions/ApplicationInfo' + +#----------------------------------------------------- +# The Application resource +#----------------------------------------------------- + Application: + title: Application + required: + - name + - throttlingTier + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + description: | + If subscriber is not given user invoking the API will be taken as the subscriber. + type: string + example: admin + throttlingTier: + type: string + example: Unlimited + callbackUrl: + type: string + example: "" + description: + type: string + example: Sample calculator application + status: + type: string + example: APPROVED + default: "" + groupId: + type: string + example: "" + keys: + type: array + items: + $ref: '#/definitions/ApplicationKey' + example: [] + +#----------------------------------------------------- +# The Application Info resource +#----------------------------------------------------- + ApplicationInfo: + title: Application info object with basic application details + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + type: string + example: admin + throttlingTier: + type: string + example: Unlimited + description: + type: string + example: Sample calculator application + status: + type: string + example: APPROVED + groupId: + type: string + example: "" + +#----------------------------------------------------- +# The Document List resource +#----------------------------------------------------- + DocumentList: + title: Document List + properties: + count: + type: integer + description: | + Number of Documents returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Document' + +#----------------------------------------------------- +# The Document resource +#----------------------------------------------------- + Document: + title: Document + required: + - name + - type + - sourceType + properties: + documentId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorDoc + type: + type: string + enum: + - HOWTO + - SAMPLES + - PUBLIC_FORUM + - SUPPORT_FORUM + - API_MESSAGE_FORMAT + - SWAGGER_DOC + - OTHER + example: HOWTO + summary: + type: string + example: "Summary of Calculator Documentation" + sourceType: + type: string + enum: + - INLINE + - URL + - FILE + example: INLINE + sourceUrl: + type: string + example: "" + otherTypeName: + type: string + example: "" + +#----------------------------------------------------- +# The Tier List resource +#----------------------------------------------------- + TierList: + title: Tier List + properties: + count: + type: integer + description: | + Number of Tiers returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/tiers/api?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/tiers/api?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Tier' + +#----------------------------------------------------- +# The Tier resource +#----------------------------------------------------- + Tier: + title: Tier + required: + - name + - tierPlan + - requestCount + - unitTime + - stopOnQuotaReach + properties: + name: + type: string + example: Platinum + description: + type: string + example: "Allows 50 request(s) per minute." + tierLevel: + type: string + enum: + - api + - application + example: api + attributes: + description: | + Custom attributes added to the tier policy + type: object + additionalProperties: + type: string + example: {} + requestCount: + description: | + Maximum number of requests which can be sent within a provided unit time + type: integer + format: int64 + example: 50 + unitTime: + type: integer + format: int64 + example: 60000 + tierPlan: + description: | + This attribute declares whether this tier is available under commercial or free + type: string + enum: + - FREE + - COMMERCIAL + example: FREE + stopOnQuotaReach: + description: | + If this attribute is set to false, you are capabale of sending requests + even if the request count exceeded within a unit time + type: boolean + example: true + +#----------------------------------------------------- +# The Subscription List resource +#----------------------------------------------------- + SubscriptionList: + title: Subscription List + properties: + count: + type: integer + description: | + Number of Subscriptions returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" + list: + type: array + items: + $ref: '#/definitions/Subscription' + +#----------------------------------------------------- +# The Subscription resource +#----------------------------------------------------- + Subscription: + title: Subscription + required: + - applicationId + - apiIdentifier + - tier + properties: + subscriptionId: + type: string + example: 01234567-0123-0123-0123-012345678901 + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + apiIdentifier: + type: string + example: 01234567-0123-0123-0123-012345678901 + tier: + type: string + example: Unlimited + status: + type: string + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - UNBLOCKED + - ON_HOLD + - REJECTED + example: UNBLOCKED + +#----------------------------------------------------- +# The Tag resource +#----------------------------------------------------- + Tag: + title: Tag + required: + - name + - weight + properties: + name: + type: string + example: tag1 + weight: + type: integer + example: 5 + +#----------------------------------------------------- +# The Tag List resource +#----------------------------------------------------- + TagList: + title: Tag List + properties: + count: + type: integer + description: | + Number of Tags returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/tags?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/tags?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Tag' + +#----------------------------------------------------- +# The Error resource +#----------------------------------------------------- + Error: + title: Error object returned with 4XX HTTP status + required: + - code + - message + properties: + code: + type: integer + format: int64 + message: + type: string + description: Error message. + description: + type: string + description: | + A detail description about the error message. + moreInfo: + type: string + description: | + Preferably an url with more details about the error. + error: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/definitions/ErrorListItem' + +#----------------------------------------------------- +# The Error List Item resource +#----------------------------------------------------- + ErrorListItem: + title: Description of individual errors that may have occurred during a request. + required: + - code + - message + properties: + code: + type: string + message: + type: string + description: | + Description about individual errors occurred + +#----------------------------------------------------- +# The Token resource +#----------------------------------------------------- + Token : + title: Token details for invoking APIs + properties: + accessToken: + type: string + description: Access token + example: 01234567890123456789012345678901 + tokenScopes: + type: array + items: + type: string + description: Valid scopes for the access token + example: ["default"] + validityTime: + type: integer + format: int64 + description: Maximum validity time for the access token + example: 3600 + +#----------------------------------------------------- +# The Application Key resource +#----------------------------------------------------- + ApplicationKey : + title: Application key details + properties: + consumerKey: + type: string + description: Consumer key of the application + example: vYDoc9s7IgAFdkSyNDaswBX7ejoa + consumerSecret: + type: string + description: Consumer secret of the application + example: TIDlOFkpzB7WjufO3OJUhy1fsvAa + supportedGrantTypes: + type: array + items: + type: string + description: Supported grant types for the application + example: ["client_credentials","password"] + keyState: + type: string + description: State of the key generation of the application + example: APPROVED + keyType: + description: Key type + type: string + enum: + - PRODUCTION + - SANDBOX + example: PRODUCTION + token: + $ref: '#/definitions/Token' + +#----------------------------------------------------- +# The Application Key Generation Request schema +#----------------------------------------------------- + ApplicationKeyGenerateRequest : + title: Application key generation request object + required: + - keyType + - validityTime + - accessAllowDomains + properties: + keyType: + type: string + enum: + - PRODUCTION + - SANDBOX + example: PRODUCTION + validityTime: + type: string + example: 3600 + callbackUrl: + type: string + description: Callback URL + example: "" + accessAllowDomains: + type: array + items: + type: string + description: Allowed domains for the access token + example: ["ALL"] + scopes: + type: array + items: + type: string + description: Allowed scopes for the access token + example: ["am_application_scope","default"] + +#----------------------------------------------------- +# END-OF-FILE +#----------------------------------------------------- diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java index c41a6849685..de3cc18668a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java @@ -41,19 +41,4 @@ public interface APIPublisherService { */ void publishAPI(API api) throws APIManagementException, FaultGatewaysException; - /** - * This method removes an API that's already published within the underlying API-Management infrastructure. - * - * @param id An instance of the bean that carries API identification related metadata - * @throws APIManagementException Is thrown if some unexpected event occurs while removing the API - */ - void removeAPI(APIIdentifier id) throws APIManagementException; - - /** - * This method registers a collection of APIs within the underlying API-Management infrastructure. - * - * @param apis A list of the beans that passes metadata related to the APIs being published - * @throws APIManagementException Is thrown if some unexpected event occurs while publishing the APIs - */ - void publishAPIs(List apis) throws APIManagementException, FaultGatewaysException; } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 8720c345cbd..218bf0883a5 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -34,6 +34,9 @@ http://wso2.org + org.wso2.carbon.apimgt.publisher.client + org.wso2.carbon.apimgt.store.client + org.wso2.carbon.apimgt.integration.client org.wso2.carbon.apimgt.webapp.publisher org.wso2.carbon.apimgt.application.extension org.wso2.carbon.apimgt.application.extension.api diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml new file mode 100644 index 00000000000..7d22f7be659 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -0,0 +1,145 @@ + + + + + + org.wso2.carbon.devicemgt + apimgt-extensions-feature + 2.0.8-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.apimgt.integration.client.feature + pom + WSO2 Carbon - APIM Integration Client Feature + http://wso2.org + This feature contains a http client implementation to communicate with WSO2-APIM server + + + + org.wso2.carbon + org.wso2.carbon.apimgt.integration.client + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.apimgt.client + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + + javax.ws.rs:jsr311-api:${jsr311.version} + + + io.swagger:swagger-annotations:${swagger.annotations.version} + + + io.github.openfeign:feign-slf4j:${io.github.openfeign.version} + + + io.github.openfeign:feign-jaxrs:${io.github.openfeign.version} + + + io.github.openfeign:feign-jackson:${io.github.openfeign.version} + + + io.github.openfeign:feign-core:${io.github.openfeign.version} + + + io.github.openfeign:feign-gson:${io.github.openfeign.version} + + + org.wso2.carbon:org.wso2.carbon.apimgt.integration.client:${project.version} + + + org.wso2.carbon:org.wso2.carbon.apimgt.publisher.client:${project.version} + + + org.wso2.carbon:org.wso2.carbon.apimgt.store.client:${project.version} + + + org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:${oltu.client.version} + + + com.fasterxml.jackson.datatype:jackson-datatype-joda:${jackson.datatype.joda.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + + + + + + + + + + 1.5.4 + 4.4.10 + 9.3.1 + + + diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties new file mode 100644 index 00000000000..9c86577d768 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml new file mode 100644 index 00000000000..c809feecdde --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml @@ -0,0 +1,28 @@ + + + + http://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.10/register + https://${iot.gateway.host}:${iot.gateway.https.port}/token + https://localhost:9443/api/am/publisher/v0.10 + https://localhost:9443/api/am/store/v0.10 + admin + admin + \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf new file mode 100644 index 00000000000..461f6ec80f7 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf @@ -0,0 +1,2 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.apim.integration_${feature.version}/conf/apim-integration.xml,target:${installFolder}/../../conf/apim-integration.xml,overwrite:true);\ diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 5575d0e8112..20391e8144d 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -35,6 +35,7 @@ http://wso2.org + org.wso2.carbon.apimgt.integration.client.feature org.wso2.carbon.apimgt.webapp.publisher.feature org.wso2.carbon.apimgt.application.extension.feature org.wso2.carbon.apimgt.handler.server.feature diff --git a/pom.xml b/pom.xml index e9b56eb1de9..241eb082a0d 100644 --- a/pom.xml +++ b/pom.xml @@ -37,11 +37,11 @@ components/device-mgt components/device-mgt-extensions + components/identity-extensions components/apimgt-extensions components/policy-mgt components/certificate-mgt components/webapp-authenticator-framework - components/identity-extensions components/email-sender features/device-mgt features/apimgt-extensions @@ -208,6 +208,21 @@ org.wso2.carbon.apimgt.webapp.publisher ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.publisher.client + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.store.client + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.integration.client + ${carbon.device.mgt.version} + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations @@ -1364,6 +1379,7 @@ ${jackson.version} + org.wso2.carbon.commons org.wso2.carbon.ntask.core @@ -1628,6 +1644,17 @@ jackson-annotations ${jackson-annotations.version} + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} + + + + org.wso2.orbit.joda-time + joda-time + ${joda-time.version} + org.wso2.orbit.org.owasp.encoder encoder @@ -1669,6 +1696,41 @@ org.wso2.store.sso.common ${carbon.store.sso.common.version} + + io.github.openfeign + feign-core + ${io.github.openfeign.version} + + + io.github.openfeign + feign-jaxrs + ${io.github.openfeign.version} + + + io.github.openfeign + feign-gson + ${io.github.openfeign.version} + + + io.github.openfeign + feign-jackson + ${io.github.openfeign.version} + + + io.github.openfeign + feign-slf4j + ${io.github.openfeign.version} + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + ${oltu.client.version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson.datatype.joda.version} + @@ -2047,6 +2109,8 @@ 1.0.2 2.6.1.wso2v1 + 2.6.1.wso2v3 + 2.8.2.wso2v1 1.2.0.wso2v1 5.0.2.Final @@ -2067,6 +2131,12 @@ 1.4.4 + + + 9.3.1 + + 1.0.1 + 2.1.5 From e29aa58e198105e45bf9ff8c387f2795e195cb26 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Tue, 24 Jan 2017 14:22:12 +0530 Subject: [PATCH 004/193] Removed tenant domain from Basic Authenticator --- .../framework/authenticator/BasicAuthAuthenticator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 908613cf359..3b06468fe92 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -28,6 +28,7 @@ import org.apache.tomcat.util.buf.CharChunk; import org.apache.tomcat.util.buf.MessageBytes; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.webapp.authenticator.framework.AuthenticationException; import org.wso2.carbon.webapp.authenticator.framework.AuthenticatorFrameworkDataHolder; import org.wso2.carbon.webapp.authenticator.framework.Constants; @@ -68,7 +69,8 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { int tenantId = Utils.getTenantIdOFUser(credentials.getUsername()); UserStoreManager userStore = AuthenticatorFrameworkDataHolder.getInstance().getRealmService(). getTenantUserRealm(tenantId).getUserStoreManager(); - boolean authenticated = userStore.authenticate(credentials.getUsername(), credentials.getPassword()); + String username = MultitenantUtils.getTenantAwareUsername(credentials.getUsername()); + boolean authenticated = userStore.authenticate(username, credentials.getPassword()); if (authenticated) { authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setUsername(credentials.getUsername()); From e74b4e23c4187a3a16fb8209d2570a8aea7b5eef Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 24 Jan 2017 19:32:59 +0530 Subject: [PATCH 005/193] removed apim dependency from cdmf --- ...ApiApplicationRegistrationServiceImpl.java | 2 +- .../pom.xml | 14 +- .../APIManagementProviderServiceImpl.java | 362 +-- .../APIManagementRestProviderServiceImpl.java | 151 - ...ationManagerExtensionServiceComponent.java | 3 +- .../pom.xml | 54 +- .../client/IntegrationClientServiceImpl.java | 2 + .../{ => publisher}/PublisherClient.java | 31 +- .../client/publisher/api/APIDocumentApi.java | 177 ++ .../client/publisher/api/APIsApi.java | 245 ++ .../client/publisher/api/ApplicationsApi.java | 35 + .../client/publisher/api/EnvironmentsApi.java | 25 + .../publisher/api/SubscriptionsApi.java | 99 + .../client/publisher/api/TiersApi.java | 146 + .../client/publisher/model/API.java | 847 +++++ .../model/APIBusinessInformation.java | 168 + .../publisher/model/APICorsConfiguration.java | 210 ++ .../publisher/model/APIEndpointSecurity.java | 176 ++ .../client/publisher/model/APIInfo.java | 237 ++ .../client/publisher/model/APIList.java | 175 ++ .../client/publisher/model/APIMaxTps.java | 122 + .../client/publisher/model/Application.java | 214 ++ .../client/publisher/model/Document.java | 365 +++ .../client/publisher/model/DocumentList.java | 175 ++ .../client/publisher/model/Environment.java | 191 ++ .../publisher/model/EnvironmentEndpoints.java | 122 + .../publisher/model/EnvironmentList.java | 129 + .../client/publisher/model/Error.java | 198 ++ .../client/publisher/model/ErrorListItem.java | 122 + .../client/publisher/model/FileInfo.java | 122 + .../client/publisher/model/Sequence.java | 145 + .../client/publisher/model/Subscription.java | 228 ++ .../publisher/model/SubscriptionList.java | 175 ++ .../client/publisher/model/Tier.java | 353 +++ .../client/publisher/model/TierList.java | 175 ++ .../publisher/model/TierPermission.java | 160 + .../service/IntegrationClientService.java | 4 +- .../client/{ => store}/StoreClient.java | 34 +- .../client/store/api/APIindividualApi.java | 170 + .../client/store/api/ApisAPIApi.java | 37 + .../store/api/ApplicationCollectionApi.java | 35 + .../store/api/ApplicationindividualApi.java | 121 + .../store/api/SubscriptionCollectionApi.java | 37 + .../store/api/SubscriptionindividualApi.java | 70 + .../client/store/api/TagCollectionApi.java | 36 + .../client/store/api/TierCollectionApi.java | 39 + .../client/store/api/TierindividualApi.java | 40 + .../integration/client/store/model/API.java | 466 +++ .../store/model/APIBusinessInformation.java | 168 + .../client/store/model/APIEndpointURLs.java | 145 + .../store/model/APIEnvironmentURLs.java | 122 + .../client/store/model/APIInfo.java | 237 ++ .../client/store/model/APIList.java | 175 ++ .../client/store/model/Application.java | 290 ++ .../client/store/model/ApplicationInfo.java | 237 ++ .../client/store/model/ApplicationKey.java | 252 ++ .../model/ApplicationKeyGenerateRequest.java | 234 ++ .../client/store/model/ApplicationList.java | 175 ++ .../client/store/model/Document.java | 310 ++ .../client/store/model/DocumentList.java | 175 ++ .../integration/client/store/model/Error.java | 198 ++ .../client/store/model/ErrorListItem.java | 122 + .../client/store/model/Subscription.java | 228 ++ .../client/store/model/SubscriptionList.java | 175 ++ .../integration/client/store/model/Tag.java | 122 + .../client/store/model/TagList.java | 175 ++ .../integration/client/store/model/Tier.java | 328 ++ .../client/store/model/TierList.java | 175 ++ .../integration/client/store/model/Token.java | 152 + .../pom.xml | 173 -- .../src/main/resources/publisher-api.yaml | 2747 ----------------- .../pom.xml | 176 -- .../src/main/resources/store-api.yaml | 2098 ------------- .../pom.xml | 30 +- .../apimgt/webapp/publisher/APIConfig.java | 50 +- .../webapp/publisher/APIPublisherService.java | 14 +- .../publisher/APIPublisherServiceImpl.java | 265 +- .../publisher/APIPublisherStartupHandler.java | 19 +- .../webapp/publisher/APIPublisherUtil.java | 238 +- .../webapp/publisher/config/APIResource.java | 8 +- .../apimgt/webapp/publisher/dto/ApiScope.java | 64 + .../webapp/publisher/dto/ApiUriTemplate.java | 73 + .../APIManagerPublisherException.java | 48 + .../internal/APIPublisherDataHolder.java | 20 +- .../APIPublisherServiceComponent.java | 47 +- .../APIPublisherLifecycleListener.java | 9 +- .../lifecycle/util/AnnotationProcessor.java | 18 +- components/apimgt-extensions/pom.xml | 2 - .../pom.xml | 2 +- .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 11 - .../device/mgt/jaxrs/util/DeviceMgtUtil.java | 2 +- .../org.wso2.carbon.device.mgt.common/pom.xml | 5 - .../scope/mgt/ScopeManagementException.java | 57 - .../scope/mgt/ScopeManagementService.java | 78 - .../org.wso2.carbon.device.mgt.core/pom.xml | 51 +- .../permission/AnnotationProcessor.java | 3 - .../permission/ExtendedAnnotationDB.java | 30 +- .../mgt/core/config/permission/Scope.java | 70 + .../internal/DeviceManagementDataHolder.java | 3 - .../DeviceManagementServiceComponent.java | 15 - .../dynamic-client-web/pom.xml | 5 - .../pom.xml | 22 +- .../mgt/oauth/extensions/OAuthExtUtils.java | 276 -- .../DeviceMgtOAuthCallbackHandler.java | 64 - .../grant/ExtendedPasswordGrantHandler.java | 32 - .../ExtendedSAML2BearerGrantHandler.java | 4 +- .../OAuthExtensionServiceComponent.java | 38 - .../pom.xml | 6 +- .../pom.xml | 6 +- .../pom.xml | 19 +- .../AuthenticationFrameworkUtil.java | 33 - .../pom.xml | 31 +- .../main/resources/conf/apim-integration.xml | 8 +- .../src/main/resources/p2.inf | 2 +- .../pom.xml | 7 +- .../pom.xml | 4 +- .../pom.xml | 5 - .../pom.xml | 7 - pom.xml | 259 +- 119 files changed, 11540 insertions(+), 7153 deletions(-) delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java rename components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/{ => publisher}/PublisherClient.java (63%) create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/API.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIBusinessInformation.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APICorsConfiguration.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIEndpointSecurity.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIInfo.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIMaxTps.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Application.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Document.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/DocumentList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Environment.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentEndpoints.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Error.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/ErrorListItem.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/FileInfo.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Sequence.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Subscription.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/SubscriptionList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Tier.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierPermission.java rename components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/{ => store}/StoreClient.java (69%) create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/API.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIBusinessInformation.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEndpointURLs.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEnvironmentURLs.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIInfo.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Application.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationInfo.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKey.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKeyGenerateRequest.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Document.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/DocumentList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Error.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ErrorListItem.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Subscription.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/SubscriptionList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tag.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TagList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tier.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TierList.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Token.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiScope.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiUriTemplate.java create mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/exception/APIManagerPublisherException.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementException.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/Scope.java delete mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java delete mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/DeviceMgtOAuthCallbackHandler.java delete mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index bc75a9febe3..268ec154ec5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -96,7 +96,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi return Response.status(Response.Status.NOT_ACCEPTABLE).entity("APIs(Tags) are not allowed to this user." ).build(); } - String username = APIUtil.getAuthenticatedUser() + "@" + APIUtil.getTenantDomainOftheUser(); + String username = APIUtil.getAuthenticatedUser(); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); String validityPeriod; if (registrationProfile.getValidityPeriod() == null) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 758d77636ef..1bf3bf678d9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -55,14 +55,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.integration.client - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - com.googlecode.json-simple.wso2 json-simple @@ -104,16 +96,14 @@ org.osgi.service.component, org.apache.commons.logging.*, org.wso2.carbon.user.core.*, - org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}", org.wso2.carbon.user.api, org.wso2.carbon.utils.multitenancy, org.json.simple, org.wso2.carbon.context, org.wso2.carbon.base, org.wso2.carbon.registry.core.*;resolution:=optional, - org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}" + org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", + org.wso2.carbon.apimgt.integration.client.* !org.wso2.carbon.apimgt.application.extension.internal, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index daedca4271e..f319c296323 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -20,23 +20,18 @@ package org.wso2.carbon.apimgt.application.extension; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; -import org.wso2.carbon.apimgt.api.APIConsumer; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; +import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; +import org.wso2.carbon.apimgt.integration.client.store.*; +import org.wso2.carbon.apimgt.integration.client.store.model.*; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.util.Map; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; /** * This class represents an implementation of APIManagementProviderService. @@ -44,81 +39,20 @@ import java.util.Set; public class APIManagementProviderServiceImpl implements APIManagementProviderService { private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); - - /** - * {@inheritDoc} - */ - @Override - public void registerExistingOAuthApplicationToAPIApplication(String jsonString, String applicationName, - String clientId, String username, - boolean isAllowedAllDomains, String keyType, - String tags[]) throws APIManagerException { - try { - APIManagerUtil.loadTenantRegistry(); - APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - if (apiConsumer != null) { - String groupId = getLoggedInUserGroupId(username, APIManagerUtil.getTenantDomain()); - int applicationId = createApplication(apiConsumer, applicationName, username, groupId); - Subscriber subscriber = apiConsumer.getSubscriber(username); - if (subscriber == null) { - String tenantDomain = MultitenantUtils.getTenantDomain(username); - addSubscriber(username, "", groupId, APIManagerUtil.getTenantId(tenantDomain)); - subscriber = apiConsumer.getSubscriber(username); - } - Application[] applications = apiConsumer.getApplications(subscriber, groupId); - Application application = null; - for (Application app : applications) { - if (app.getId() == applicationId) { - application = app; - } - } - if (application == null) { - throw new APIManagerException( - "Api application creation failed for " + applicationName + " to the user " + username); - } - - OAuthApplicationInfo oAuthApp = application.getOAuthApp(keyType); - if (oAuthApp != null) { - if (oAuthApp.getClientId().equals(clientId)) { - if (tags != null && tags.length > 0) { - createApplicationAndSubscribeToAPIs(applicationName, tags, username); - } - return; - } else { - throw new APIManagerException("Api application already mapped to another OAuth App"); - } - } - - apiConsumer.mapExistingOAuthClient(jsonString, username, clientId, applicationName, - ApiApplicationConstants.DEFAULT_TOKEN_TYPE); - if (tags != null && tags.length > 0) { - createApplicationAndSubscribeToAPIs(applicationName, tags, username); - } - } - } catch (APIManagementException e) { - throw new APIManagerException( - "Failed registering the OAuth app [ clientId " + clientId + " ] with api manager application", e); - } - } + private static final String CONTENT_TYPE = "application/json"; + private static final int MAX_API_PER_TAG = 200; @Override public void removeAPIApplication(String applicationName, String username) throws APIManagerException { - try { - APIManagerUtil.loadTenantRegistry(); - APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - if (apiConsumer != null) { - String groupId = getLoggedInUserGroupId(username, APIManagerUtil.getTenantDomain()); - Application[] applications = apiConsumer.getApplications(new Subscriber(username), groupId); - for (Application application : applications) { - if (application.getName().equals(applicationName)) { - apiConsumer.removeApplication(application); - break; - } - } - } - } catch (APIManagementException e) { - throw new APIManagerException( - "Failed to remove the application [ application name " + applicationName + " ]", e); + + StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() + .getStoreClient(); + ApplicationList applicationList = storeClient.getApplications() + .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); + if (applicationList.getList() != null && applicationList.getList().size() > 0) { + ApplicationInfo applicationInfo = applicationList.getList().get(0); + storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), + null, null); } } @@ -126,220 +60,88 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe * {@inheritDoc} */ @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException { - try { - APIManagerUtil.loadTenantRegistry(); - APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - String groupId = getLoggedInUserGroupId(username, APIManagerUtil.getTenantDomain()); - int applicationId = createApplicationAndSubscribeToAPIs(apiApplicationName, tags, username); - Application[] applications = apiConsumer.getApplications(apiConsumer.getSubscriber(username), groupId); - Application application = null; - for (Application app : applications) { - if (app.getId() == applicationId) { - application = app; - } - } - if (application == null) { - throw new APIManagerException( - "Api application creation failed for " + apiApplicationName + " to the user " + username); - } - - OAuthApplicationInfo oAuthApp = application.getOAuthApp(keyType); - if (oAuthApp != null) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(oAuthApp.getClientId()); - apiApplicationKey.setConsumerSecret(oAuthApp.getClientSecret()); - return apiApplicationKey; - } - String[] allowedDomains = new String[1]; - if (isAllowedAllDomains) { - allowedDomains[0] = ApiApplicationConstants.ALLOWED_DOMAINS; - } else { - allowedDomains[0] = APIManagerUtil.getTenantDomain(); - } - String ownerJsonString = "{\"username\":\"" + username + "\"}"; - Map keyDetails = apiConsumer.requestApprovalForApplicationRegistration(username, - apiApplicationName, - keyType, "", - allowedDomains, - validityTime, - "null", - groupId, - ownerJsonString); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey((String) keyDetails.get(APIConstants.FrontEndParameterNames - .CONSUMER_KEY)); - apiApplicationKey.setConsumerSecret((String) keyDetails.get( - APIConstants.FrontEndParameterNames.CONSUMER_SECRET)); - return apiApplicationKey; - } catch (APIManagementException e) { - throw new APIManagerException("Failed to register a api application : " + apiApplicationName, e); + StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() + .getStoreClient(); + ApplicationList applicationList = storeClient.getApplications() + .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); + Application application; + if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { + //create application; + application = new Application(); + application.setName(applicationName); + application.setSubscriber(username); + application.setDescription(""); + application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); + application.setGroupId(""); + application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); + } else { + ApplicationInfo applicationInfo = applicationList.getList().get(0); + application = storeClient.getIndividualApplication() + .applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null); } - } - - private int createApplication(APIConsumer apiConsumer, String applicationName, String username, String groupId) - throws APIManagerException { - try { - if (apiConsumer != null) { - if (apiConsumer.getSubscriber(username) == null) { - String tenantDomain = MultitenantUtils.getTenantDomain(username); - addSubscriber(username, "", groupId, APIManagerUtil.getTenantId(tenantDomain)); - } - Application application = apiConsumer.getApplicationsByName(username, applicationName, groupId); - if (application == null) { - Subscriber subscriber = apiConsumer.getSubscriber(username); - application = new Application(applicationName, subscriber); - application.setTier(ApiApplicationConstants.DEFAULT_TIER); - application.setGroupId(groupId); - return apiConsumer.addApplication(application, username); - } else { - if (log.isDebugEnabled()) { - log.debug("Application [" + applicationName + "] already exists for Subscriber [" + username + - "]"); - } - return application.getId(); - } - } else { - throw new APIManagerException("Failed to retrieve the api consumer for username" + username); - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to create application [name:" + applicationName + " , username:" - + username + ", " + "groupId:" + groupId, e); + if (application == null) { + throw new APIManagerException ( + "Api application creation failed for " + applicationName + " to the user " + username); } - } - - private void addSubscription(APIConsumer apiConsumer, APIIdentifier apiId, int applicationId, String username) - throws APIManagerException { - try { - if (apiConsumer != null) { - APIIdentifier apiIdentifier = new APIIdentifier(apiId.getProviderName(), apiId.getApiName(), - apiId.getVersion()); - apiIdentifier.setTier(ApiApplicationConstants.DEFAULT_TIER); - apiConsumer.addSubscription(apiIdentifier, username, applicationId); - if (log.isDebugEnabled()) { - log.debug("Successfully created subscription for API : " + apiId + " from application : " + - applicationId); + // subscribe to apis. + if (tags != null && tags.length > 0) { + for (String tag: tags) { + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag + , CONTENT_TYPE, null); + if (apiList.getList() != null && apiList.getList().size() == 0) { + apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0 + , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null); } - } else { - throw new APIManagerException("API provider configured for the given API configuration is null. " + - "Thus, the API is not published"); - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to create subscription for api name : " + apiId.getApiName(), e); - } - } - - private void addSubscriber(String subscriberName, String subscriberEmail, String groupId, int tenantId) - throws APIManagerException { - if (log.isDebugEnabled()) { - log.debug("Creating subscriber with name " + subscriberName); - } - try { - APIConsumer consumer = APIManagerFactory.getInstance().getAPIConsumer(subscriberName); - if (consumer != null) { - synchronized (consumer) { - if (consumer.getSubscriber(subscriberName) == null) { - consumer.addSubscriber(subscriberName, groupId); - if (log.isDebugEnabled()) { - log.debug("Successfully created subscriber with name : " + subscriberName + - " with groupID : " + groupId); - } + if (apiList.getList() != null && apiList.getList().size() > 0) { + for (APIInfo apiInfo :apiList.getList()) { + Subscription subscription = new Subscription(); + subscription.setApiIdentifier(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscription.tier(ApiApplicationConstants.DEFAULT_TIER); + storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE); } - } - } else { - throw new APIManagerException("API provider configured for the given API configuration is null. " + - "Thus, the API is not published"); - } - } catch (APIManagementException e) { - throw new APIManagerException("API provider configured for the given API configuration is null. " + - "Thus, the API is not published", e); - } - } - - /** - * This method registers an api application and then subscribe the application to the api. - * - * @param apiApplicationName name of the application. - * @param tags are used subscribe the apis with the tag. - * @param username subscription is created for the user. - * @throws APIManagerException - */ - private int createApplicationAndSubscribeToAPIs(String apiApplicationName, String tags[], String username) - throws APIManagerException { - try { - APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - String groupId = getLoggedInUserGroupId(username, APIManagerUtil.getTenantDomain()); - int applicationId = createApplication(apiConsumer, apiApplicationName, username, groupId); - Subscriber subscriber = apiConsumer.getSubscriber(username); - Set userVisibleAPIs = null; - for (String tag : tags) { - Set tagAPIs = apiConsumer.getAPIsWithTag(tag, APIManagerUtil.getTenantDomain()); - if (tagAPIs == null || tagAPIs.size() == 0) { - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername( - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName()); - APIConsumer anonymousConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - tagAPIs = anonymousConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - } catch (UserStoreException e) { - log.error("failed to initialized super tenant flow", e); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - if (userVisibleAPIs == null) { - userVisibleAPIs = tagAPIs; - } else { - userVisibleAPIs.addAll(tagAPIs); } } - if (userVisibleAPIs != null) { - Set subscribedAPIs = apiConsumer.getSubscribedAPIs(subscriber, apiApplicationName, - groupId); - for (API userVisibleAPI : userVisibleAPIs) { - APIIdentifier apiIdentifier = userVisibleAPI.getId(); - boolean isSubscribed = false; - if (subscribedAPIs != null) { - for (SubscribedAPI subscribedAPI : subscribedAPIs) { - if (subscribedAPI.getApiId().equals(apiIdentifier)) { - isSubscribed = true; - } - } - } - if (!isSubscribed) { - addSubscription(apiConsumer, apiIdentifier, applicationId, username); - } + } + //end of subscription + + List applicationKeys = application.getKeys(); + if (applicationKeys != null) { + for (ApplicationKey applicationKey : applicationKeys) { + if (keyType.equals(applicationKey.getKeyType().toString())) { + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } } - return applicationId; - } catch (APIManagementException e) { - throw new APIManagerException("Failed to fetch device apis information for the user " + username, e); } - } - private String getLoggedInUserGroupId(String username, String tenantDomain) throws APIManagerException { - JSONObject loginInfoJsonObj = new JSONObject(); - try { - APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); - loginInfoJsonObj.put("user", username); - if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - loginInfoJsonObj.put("isSuperTenant", true); - } else { - loginInfoJsonObj.put("isSuperTenant", false); - } - String loginInfoString = loginInfoJsonObj.toString(); - return apiConsumer.getGroupIds(loginInfoString); - } catch (APIManagementException e) { - throw new APIManagerException("Unable to get groupIds of user " + username, e); + ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest(); + List allowedDomains = new ArrayList<>(); + if (isAllowedAllDomains) { + allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); + } else { + allowedDomains.add(APIManagerUtil.getTenantDomain()); } + applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains); + applicationKeyGenerateRequest.setCallbackUrl(""); + applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION); + applicationKeyGenerateRequest.setValidityTime(validityTime); + + ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( + application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java deleted file mode 100644 index bea5cfcf3f1..00000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementRestProviderServiceImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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 org.wso2.carbon.apimgt.application.extension; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; -import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; -import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; -import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; -import org.wso2.carbon.apimgt.integration.client.StoreClient; -import org.wso2.carbon.apimgt.store.client.model.APIInfo; -import org.wso2.carbon.apimgt.store.client.model.APIList; -import org.wso2.carbon.apimgt.store.client.model.Application; -import org.wso2.carbon.apimgt.store.client.model.ApplicationInfo; -import org.wso2.carbon.apimgt.store.client.model.ApplicationKey; -import org.wso2.carbon.apimgt.store.client.model.ApplicationKeyGenerateRequest; -import org.wso2.carbon.apimgt.store.client.model.ApplicationList; -import org.wso2.carbon.apimgt.store.client.model.Subscription; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents an implementation of APIManagementProviderService. - */ -public class APIManagementRestProviderServiceImpl implements APIManagementProviderService { - - private static final Log log = LogFactory.getLog(APIManagementRestProviderServiceImpl.class); - private static final String CONTENT_TYPE = "application/json"; - private static final int MAX_API_PER_TAG = 200; - - @Override - public void removeAPIApplication(String applicationName, String username) throws APIManagerException { - - StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() - .getStoreClient(); - ApplicationList applicationList = storeClient.getApplications() - .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); - if (applicationList.getList() != null && applicationList.getList().size() > 0) { - ApplicationInfo applicationInfo = applicationList.getList().get(0); - storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), - null, null); - } - } - - /** - * {@inheritDoc} - */ - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, String validityTime) - throws APIManagerException { - StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() - .getStoreClient(); - ApplicationList applicationList = storeClient.getApplications() - .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); - Application application; - if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { - //create application; - application = new Application(); - application.setName(applicationName); - application.setSubscriber(username); - application.setDescription(""); - application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); - application.setGroupId(""); - application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); - } else { - ApplicationInfo applicationInfo = applicationList.getList().get(0); - application = storeClient.getIndividualApplication() - .applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null); - } - if (application == null) { - throw new APIManagerException ( - "Api application creation failed for " + applicationName + " to the user " + username); - } - // subscribe to apis. - if (tags != null && tags.length > 0) { - for (String tag: tags) { - APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, null, "tag:" + tag, CONTENT_TYPE, null); - if (apiList.getList() != null && apiList.getList().size() == 0) { - apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0 - , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null); - } - - if (apiList.getList() != null && apiList.getList().size() > 0) { - for (APIInfo apiInfo :apiList.getList()) { - Subscription subscription = new Subscription(); - subscription.setApiIdentifier(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscription.tier(ApiApplicationConstants.DEFAULT_TIER); - storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE); - } - - } - } - } - //end of subscription - - List applicationKeys = application.getKeys(); - if (applicationKeys != null) { - for (ApplicationKey applicationKey : applicationKeys) { - if (keyType.equals(applicationKey.getKeyType())) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } - } - } - - ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest(); - List allowedDomains = new ArrayList<>(); - if (isAllowedAllDomains) { - allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); - } else { - allowedDomains.add(APIManagerUtil.getTenantDomain()); - } - applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains); - applicationKeyGenerateRequest.setCallbackUrl(""); - applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION); - applicationKeyGenerateRequest.setValidityTime(validityTime); - - ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( - application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 079b119c658..c79f80d3b2b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -23,7 +23,6 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext;; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; -import org.wso2.carbon.apimgt.application.extension.APIManagementRestProviderServiceImpl; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; @@ -64,7 +63,7 @@ public class APIApplicationManagerExtensionServiceComponent { if (log.isDebugEnabled()) { log.debug("Initializing device extension bundle"); } - APIManagementProviderService apiManagementProviderService = new APIManagementRestProviderServiceImpl(); + APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); APIApplicationManagerExtensionDataHolder.getInstance().setAPIManagementProviderService(apiManagementProviderService); BundleContext bundleContext = componentContext.getBundleContext(); bundleContext.registerService(APIManagementProviderService.class.getName(), apiManagementProviderService, null); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 4efa8dfc227..6688f2fb112 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -51,23 +51,27 @@ org.osgi.framework, org.osgi.service.component, - org.wso2.carbon.logging, - io.swagger, - junit, feign, - feign.jackson, feign.codec, - com.google.gson, feign.auth, feign.gson, - feign.slf4j, - feign.jaxrs, - com.fasterxml.jackson.core, - org.wso2.carbon.apimgt.publisher.client.*, - org.wso2.carbon.apimgt.store.client.*, + javax.ws.rs, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.parsers;resolution:=optional, + org.apache.commons.logging, + org.w3c.dom, + org.wso2.carbon.context, + org.wso2.carbon.identity.jwt.client.*, + org.wso2.carbon.user.api, + org.wso2.carbon.utils, + com.fasterxml.jackson.annotation, + io.swagger.annotations, + org.wso2.carbon.core.util - javax.ws.rs-api + jsr311-api, + feign-jaxrs @@ -111,49 +115,25 @@ io.github.openfeign - feign-jaxrs + feign-jackson io.github.openfeign - feign-jackson + feign-jaxrs io.github.openfeign feign-gson - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - org.testng testng - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.publisher.client - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.store.client - org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension - - javax.ws.rs - jsr311-api - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java index b2c997e57ab..7878bcfffdf 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java @@ -19,7 +19,9 @@ package org.wso2.carbon.apimgt.integration.client; import feign.RequestInterceptor; +import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +import org.wso2.carbon.apimgt.integration.client.store.StoreClient; public class IntegrationClientServiceImpl implements IntegrationClientService { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java similarity index 63% rename from components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java rename to components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java index 5754f07edd2..ab1e1309542 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/PublisherClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java @@ -15,22 +15,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.apimgt.integration.client; +package org.wso2.carbon.apimgt.integration.client.publisher; import feign.Feign; import feign.RequestInterceptor; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; -import feign.jaxrs.JAXRSContract; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.publisher.client.api.APIDocumentApi; -import org.wso2.carbon.apimgt.publisher.client.api.APIsApi; -import org.wso2.carbon.apimgt.publisher.client.api.ApplicationsApi; -import org.wso2.carbon.apimgt.publisher.client.api.EnvironmentsApi; -import org.wso2.carbon.apimgt.publisher.client.api.SubscriptionsApi; -import org.wso2.carbon.apimgt.publisher.client.api.TiersApi; -import org.wso2.carbon.apimgt.publisher.client.invoker.ApiClient; +import org.wso2.carbon.apimgt.integration.client.publisher.api.*; +import org.wso2.carbon.core.util.Utils; /** * Publisher client generated using swagger. @@ -52,18 +46,15 @@ public class PublisherClient { */ public PublisherClient(RequestInterceptor requestInterceptor) { Feign.Builder builder = Feign.builder().requestInterceptor(requestInterceptor) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()); + .encoder(new GsonEncoder()).decoder(new GsonDecoder()); + String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); - ApiClient client = new ApiClient(); - client.setBasePath(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); - client.setFeignBuilder(builder); - - api = client.buildClient(APIsApi.class); - document = client.buildClient(APIDocumentApi.class); - application = client.buildClient(ApplicationsApi.class); - environments = client.buildClient(EnvironmentsApi.class); - subscriptions = client.buildClient(SubscriptionsApi.class); - tiers = client.buildClient(TiersApi.class); + api = builder.target(APIsApi.class, basePath); + document = builder.target(APIDocumentApi.class, basePath); + application = builder.target(ApplicationsApi.class, basePath); + environments = builder.target(EnvironmentsApi.class, basePath); + subscriptions = builder.target(SubscriptionsApi.class, basePath); + tiers = builder.target(TiersApi.class, basePath); } public APIsApi getApi() { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java new file mode 100644 index 00000000000..2f7c76f9cae --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java @@ -0,0 +1,177 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.Document; +import org.wso2.carbon.apimgt.integration.client.publisher.model.DocumentList; + + +import java.io.File; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface APIDocumentApi { + + + /** + * Get document content + * Downloads a FILE type document/get the inline content or source url of a certain document. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/documents/{documentId}/content") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + void apisApiIdDocumentsDocumentIdContentGet(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update API document content. + * Upload a file to a document or add inline content to the document. Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. Only one of **file** or **inlineContent** can be specified at one time. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param file Document to upload (optional) + * @param inlineContent Inline content of the document (optional) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return Document + */ + @RequestLine("POST /apis/{apiId}/documents/{documentId}/content") + @Headers({ + "Content-type: multipart/form-data", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + Document apisApiIdDocumentsDocumentIdContentPost(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("contentType") String contentType, @Param("file") File file, + @Param("inlineContent") String inlineContent, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Delete an API Document + * Delete a document of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("DELETE /apis/{apiId}/documents/{documentId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void apisApiIdDocumentsDocumentIdDelete(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get an API Document + * Get a particular document associated with an API. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly + * retrieved variant of the resource. (optional) + * @return Document + */ + @RequestLine("GET /apis/{apiId}/documents/{documentId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Document apisApiIdDocumentsDocumentIdGet(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update an API Document + * Update document details. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param body Document object that needs to be added (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return Document + */ + @RequestLine("PUT /apis/{apiId}/documents/{documentId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + Document apisApiIdDocumentsDocumentIdPut(@Param("apiId") String apiId, @Param("documentId") String documentId, + Document body, @Param("contentType") String contentType, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get API Documents + * Get a list of documents belonging to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return DocumentList + */ + @RequestLine("GET /apis/{apiId}/documents?limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + DocumentList apisApiIdDocumentsGet(@Param("apiId") String apiId, @Param("limit") Integer limit, + @Param("offset") Integer offset, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch); + + /** + * Add a new document + * Add a new document to an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param body Document object that needs to be added (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @return Document + */ + @RequestLine("POST /apis/{apiId}/documents") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}" + }) + Document apisApiIdDocumentsPost(@Param("apiId") String apiId, Document body, @Param("contentType") String contentType); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java new file mode 100644 index 00000000000..469dbcdbdb1 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java @@ -0,0 +1,245 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.API; +import org.wso2.carbon.apimgt.integration.client.publisher.model.APIList; +import org.wso2.carbon.apimgt.integration.client.publisher.model.FileInfo; + + +import java.io.File; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface APIsApi { + + + /** + * Delete API + * Delete an existing API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("DELETE /apis/{apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void apisApiIdDelete(@Param("apiId") String apiId, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get API details + * Get details of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return API + */ + @RequestLine("GET /apis/{apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + API apisApiIdGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update an existing API + * Update an existing API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param body API object that needs to be added (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return API + */ + @RequestLine("PUT /apis/{apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + API apisApiIdPut(@Param("apiId") String apiId, API body, @Param("contentType") String contentType, + @Param("ifMatch") String ifMatch, @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get API Definition + * Get the swagger of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/swagger") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + void apisApiIdSwaggerGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update API Definition + * Update an existing swagger definition of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param apiDefinition Swagger definition of the API (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("PUT /apis/{apiId}/swagger") + @Headers({ + "Content-type: multipart/form-data", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void apisApiIdSwaggerPut(@Param("apiId") String apiId, @Param("apiDefinition") String apiDefinition, + @Param("contentType") String contentType, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get the thumbnail image + * Downloads a thumbnail image of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/thumbnail") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + void apisApiIdThumbnailGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Upload a thumbnail image + * Upload a thumbnail image to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param file Image to upload (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return FileInfo + */ + @RequestLine("POST /apis/{apiId}/thumbnail") + @Headers({ + "Content-type: multipart/form-data", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + FileInfo apisApiIdThumbnailPost(@Param("apiId") String apiId, @Param("file") File file, + @Param("contentType") String contentType, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Change API Status + * Change the lifecycle of an API + * @param action The action to demote or promote the state of the API. Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] (required) + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. Should be formatted as **provider-name-version**. (required) + * @param lifecycleChecklist You can specify additional checklist items by using an **\"attribute:\"** modifier. Eg: \"Deprecate Old Versions:true\" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in \"attribute1:true, attribute2:false\" format. Supported checklist items are as follows. 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. (optional) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("POST /apis/change-lifecycle?action={action}&lifecycleChecklist={lifecycleChecklist}&apiId={apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void apisChangeLifecyclePost(@Param("action") String action, @Param("apiId") String apiId, + @Param("lifecycleChecklist") String lifecycleChecklist, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Copy API + * Create a new API by copying an existing API + * @param newVersion Version of the new API. (required) + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. Should be formatted as **provider-name-version**. (required) + * @return void + */ + @RequestLine("POST /apis/copy-api?newVersion={newVersion}&apiId={apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json" + }) + void apisCopyApiPost(@Param("newVersion") String newVersion, @Param("apiId") String apiId); + + /** + * Get all APIs + * Get a list of available APIs qualifying under a given search condition. + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param query **Search condition**. You can search in attributes by using an **\"attribute:\"** modifier. Eg. \"provider:wso2\" will match an API if the provider of the API contains \"wso2\". Supported attribute modifiers are [**version, context, status, description, subcontext, doc, provider**] If no advanced attribute modifier has been specified, search will match the given query string against API Name. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of + * the resourec. (optional) + * @return APIList + */ + @RequestLine("GET /apis?limit={limit}&offset={offset}&query={query}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + APIList apisGet(@Param("limit") Integer limit, @Param("offset") Integer offset, @Param("query") String query, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch); + + /** + * Create a new API + * Create a new API + * @param body API object that needs to be added (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @return API + */ + @RequestLine("POST /apis") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}" + }) + API apisPost(API body, @Param("contentType") String contentType); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java new file mode 100644 index 00000000000..baed5a1a78a --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java @@ -0,0 +1,35 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.Application; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface ApplicationsApi { + + + /** + * Get Application + * Get application details + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Application + */ + @RequestLine("GET /applications/{applicationId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Application applicationsApplicationIdGet(@Param("applicationId") String applicationId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java new file mode 100644 index 00000000000..63dd56a1dbe --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java @@ -0,0 +1,25 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.EnvironmentList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface EnvironmentsApi { + + + /** + * Get gateway environments + * Get a list of gateway environments configured previously. + * @param apiId Will return environment list for the provided API. (optional) + * @return EnvironmentList + */ + @RequestLine("GET /environments?apiId={apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json" + }) + EnvironmentList environmentsGet(@Param("apiId") String apiId); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java new file mode 100644 index 00000000000..9a38b6a477d --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java @@ -0,0 +1,99 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.Subscription; +import org.wso2.carbon.apimgt.integration.client.publisher.model.SubscriptionList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface SubscriptionsApi { + + + /** + * Block a subscription + * Block a subscription. + * @param subscriptionId Subscription Id (required) + * @param blockState Subscription block state. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("POST /subscriptions/block-subscription?subscriptionId={subscriptionId}&blockState={blockState}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void subscriptionsBlockSubscriptionPost(@Param("subscriptionId") String subscriptionId, + @Param("blockState") String blockState, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get All Subscriptions + * Get subscription list. The API Identifier and corresponding Application Identifier the subscriptions of which are to be returned are passed as parameters. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. Should be formatted as **provider-name-version**. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return SubscriptionList + */ + @RequestLine("GET /subscriptions?apiId={apiId}&limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + SubscriptionList subscriptionsGet(@Param("apiId") String apiId, @Param("limit") Integer limit, + @Param("offset") Integer offset, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch); + + /** + * Get a Subscription + * Get subscription details + * @param subscriptionId Subscription Id (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Subscription + */ + @RequestLine("GET /subscriptions/{subscriptionId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Subscription subscriptionsSubscriptionIdGet(@Param("subscriptionId") String subscriptionId, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Unblock a Subscription + * Unblock a subscription. + * @param subscriptionId Subscription Id (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("POST /subscriptions/unblock-subscription?subscriptionId={subscriptionId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void subscriptionsUnblockSubscriptionPost(@Param("subscriptionId") String subscriptionId, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java new file mode 100644 index 00000000000..7239c02e3bb --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java @@ -0,0 +1,146 @@ +package org.wso2.carbon.apimgt.integration.client.publisher.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.publisher.model.Tier; +import org.wso2.carbon.apimgt.integration.client.publisher.model.TierList; +import org.wso2.carbon.apimgt.integration.client.publisher.model.TierPermission; + + +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public interface TiersApi { + + + /** + * List Tiers + * Get available tiers + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return TierList + */ + @RequestLine("GET /tiers/{tierLevel}?limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + TierList tiersTierLevelGet(@Param("tierLevel") String tierLevel, @Param("limit") Integer limit, + @Param("offset") Integer offset, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch); + + /** + * Add a new Tier + * Add a new tier + * @param body Tier object that should to be added (required) + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @return Tier + */ + @RequestLine("POST /tiers/{tierLevel}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}" + }) + Tier tiersTierLevelPost(Tier body, @Param("tierLevel") String tierLevel, @Param("contentType") String contentType); + + /** + * Delete a Tier + * Remove a tier + * @param tierName Tier name (required) + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("DELETE /tiers/{tierLevel}/{tierName}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void tiersTierLevelTierNameDelete(@Param("tierName") String tierName, @Param("tierLevel") String tierLevel, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get a Tier + * Get tier details + * @param tierName Tier name (required) + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Tier + */ + @RequestLine("GET /tiers/{tierLevel}/{tierName}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Tier tiersTierLevelTierNameGet(@Param("tierName") String tierName, @Param("tierLevel") String tierLevel, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update a Tier + * Update tier details + * @param tierName Tier name (required) + * @param body Tier object that needs to be modified (required) + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return Tier + */ + @RequestLine("PUT /tiers/{tierLevel}/{tierName}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + Tier tiersTierLevelTierNamePut(@Param("tierName") String tierName, Tier body, @Param("tierLevel") String tierLevel, + @Param("contentType") String contentType, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Update Tier Permission + * Update tier permission + * @param tierName Name of the tier (required) + * @param tierLevel List API or Application or Resource type tiers. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @param permissions (optional) + * @return List + */ + @RequestLine("POST /tiers/update-permission?tierName={tierName}&tierLevel={tierLevel}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + List tiersUpdatePermissionPost(@Param("tierName") String tierName, @Param("tierLevel") String tierLevel, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince, TierPermission permissions); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/API.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/API.java new file mode 100644 index 00000000000..0e881e99222 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/API.java @@ -0,0 +1,847 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * API + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class API { + @JsonProperty("id") + private String id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("context") + private String context = null; + + @JsonProperty("version") + private String version = null; + + @JsonProperty("provider") + private String provider = null; + + @JsonProperty("apiDefinition") + private String apiDefinition = null; + + @JsonProperty("wsdlUri") + private String wsdlUri = null; + + @JsonProperty("status") + private String status = null; + + @JsonProperty("responseCaching") + private String responseCaching = null; + + @JsonProperty("cacheTimeout") + private Integer cacheTimeout = null; + + @JsonProperty("destinationStatsEnabled") + private String destinationStatsEnabled = null; + + @JsonProperty("isDefaultVersion") + private Boolean isDefaultVersion = null; + + @JsonProperty("transport") + private List transport = new ArrayList(); + + @JsonProperty("tags") + private List tags = new ArrayList(); + + @JsonProperty("tiers") + private List tiers = new ArrayList(); + + @JsonProperty("maxTps") + private APIMaxTps maxTps = null; + + @JsonProperty("thumbnailUri") + private String thumbnailUri = null; + + /** + * Gets or Sets visibility + */ + public enum VisibilityEnum { + PUBLIC("PUBLIC"), + + PRIVATE("PRIVATE"), + + RESTRICTED("RESTRICTED"), + + CONTROLLED("CONTROLLED"); + + private String value; + + VisibilityEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VisibilityEnum fromValue(String text) { + for (VisibilityEnum b : VisibilityEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("visibility") + private VisibilityEnum visibility = null; + + @JsonProperty("visibleRoles") + private List visibleRoles = new ArrayList(); + + @JsonProperty("visibleTenants") + private List visibleTenants = new ArrayList(); + + @JsonProperty("endpointConfig") + private String endpointConfig = null; + + @JsonProperty("endpointSecurity") + private APIEndpointSecurity endpointSecurity = null; + + @JsonProperty("gatewayEnvironments") + private String gatewayEnvironments = null; + + @JsonProperty("sequences") + private List sequences = new ArrayList(); + + /** + * Gets or Sets subscriptionAvailability + */ + public enum SubscriptionAvailabilityEnum { + current_tenant("current_tenant"), + + all_tenants("all_tenants"), + + specific_tenants("specific_tenants"); + + private String value; + + SubscriptionAvailabilityEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static SubscriptionAvailabilityEnum fromValue(String text) { + for (SubscriptionAvailabilityEnum b : SubscriptionAvailabilityEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("subscriptionAvailability") + private SubscriptionAvailabilityEnum subscriptionAvailability = null; + + @JsonProperty("subscriptionAvailableTenants") + private List subscriptionAvailableTenants = new ArrayList(); + + @JsonProperty("businessInformation") + private APIBusinessInformation businessInformation = null; + + @JsonProperty("corsConfiguration") + private APICorsConfiguration corsConfiguration = null; + + public API id(String id) { + this.id = id; + return this; + } + + /** + * UUID of the api registry artifact + * @return id + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "UUID of the api registry artifact ") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public API name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorAPI", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public API description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "A calculator API that supports basic operations", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public API context(String context) { + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @ApiModelProperty(example = "CalculatorAPI", required = true, value = "") + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public API version(String version) { + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @ApiModelProperty(example = "1.0.0", required = true, value = "") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public API provider(String provider) { + this.provider = provider; + return this; + } + + /** + * If the provider value is not given user invoking the api will be used as the provider. + * @return provider + **/ + @ApiModelProperty(example = "admin", value = "If the provider value is not given user invoking the api will be used as the provider. ") + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public API apiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + return this; + } + + /** + * Swagger definition of the API which contains details about URI templates and scopes + * @return apiDefinition + **/ + @ApiModelProperty(example = "null", required = true, value = "Swagger definition of the API which contains details about URI templates and scopes ") + public String getApiDefinition() { + return apiDefinition; + } + + public void setApiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + } + + public API wsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + return this; + } + + /** + * WSDL URL if the API is based on a WSDL endpoint + * @return wsdlUri + **/ + @ApiModelProperty(example = "http://www.webservicex.com/globalweather.asmx?wsdl", value = "WSDL URL if the API is based on a WSDL endpoint ") + public String getWsdlUri() { + return wsdlUri; + } + + public void setWsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + } + + public API status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "CREATED", value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public API responseCaching(String responseCaching) { + this.responseCaching = responseCaching; + return this; + } + + /** + * Get responseCaching + * @return responseCaching + **/ + @ApiModelProperty(example = "Disabled", value = "") + public String getResponseCaching() { + return responseCaching; + } + + public void setResponseCaching(String responseCaching) { + this.responseCaching = responseCaching; + } + + public API cacheTimeout(Integer cacheTimeout) { + this.cacheTimeout = cacheTimeout; + return this; + } + + /** + * Get cacheTimeout + * @return cacheTimeout + **/ + @ApiModelProperty(example = "300", value = "") + public Integer getCacheTimeout() { + return cacheTimeout; + } + + public void setCacheTimeout(Integer cacheTimeout) { + this.cacheTimeout = cacheTimeout; + } + + public API destinationStatsEnabled(String destinationStatsEnabled) { + this.destinationStatsEnabled = destinationStatsEnabled; + return this; + } + + /** + * Get destinationStatsEnabled + * @return destinationStatsEnabled + **/ + @ApiModelProperty(example = "Disabled", value = "") + public String getDestinationStatsEnabled() { + return destinationStatsEnabled; + } + + public void setDestinationStatsEnabled(String destinationStatsEnabled) { + this.destinationStatsEnabled = destinationStatsEnabled; + } + + public API isDefaultVersion(Boolean isDefaultVersion) { + this.isDefaultVersion = isDefaultVersion; + return this; + } + + /** + * Get isDefaultVersion + * @return isDefaultVersion + **/ + @ApiModelProperty(example = "false", required = true, value = "") + public Boolean getIsDefaultVersion() { + return isDefaultVersion; + } + + public void setIsDefaultVersion(Boolean isDefaultVersion) { + this.isDefaultVersion = isDefaultVersion; + } + + public API transport(List transport) { + this.transport = transport; + return this; + } + + public API addTransportItem(String transportItem) { + this.transport.add(transportItem); + return this; + } + + /** + * Supported transports for the API (http and/or https). + * @return transport + **/ + @ApiModelProperty(example = "null", required = true, value = "Supported transports for the API (http and/or https). ") + public List getTransport() { + return transport; + } + + public void setTransport(List transport) { + this.transport = transport; + } + + public API tags(List tags) { + this.tags = tags; + return this; + } + + public API addTagsItem(String tagsItem) { + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @ApiModelProperty(example = "null", value = "") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public API tiers(List tiers) { + this.tiers = tiers; + return this; + } + + public API addTiersItem(String tiersItem) { + this.tiers.add(tiersItem); + return this; + } + + /** + * Get tiers + * @return tiers + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public List getTiers() { + return tiers; + } + + public void setTiers(List tiers) { + this.tiers = tiers; + } + + public API maxTps(APIMaxTps maxTps) { + this.maxTps = maxTps; + return this; + } + + /** + * Get maxTps + * @return maxTps + **/ + @ApiModelProperty(example = "null", value = "") + public APIMaxTps getMaxTps() { + return maxTps; + } + + public void setMaxTps(APIMaxTps maxTps) { + this.maxTps = maxTps; + } + + public API thumbnailUri(String thumbnailUri) { + this.thumbnailUri = thumbnailUri; + return this; + } + + /** + * Get thumbnailUri + * @return thumbnailUri + **/ + @ApiModelProperty(example = "/apis/01234567-0123-0123-0123-012345678901/thumbnail", value = "") + public String getThumbnailUri() { + return thumbnailUri; + } + + public void setThumbnailUri(String thumbnailUri) { + this.thumbnailUri = thumbnailUri; + } + + public API visibility(VisibilityEnum visibility) { + this.visibility = visibility; + return this; + } + + /** + * Get visibility + * @return visibility + **/ + @ApiModelProperty(example = "PUBLIC", required = true, value = "") + public VisibilityEnum getVisibility() { + return visibility; + } + + public void setVisibility(VisibilityEnum visibility) { + this.visibility = visibility; + } + + public API visibleRoles(List visibleRoles) { + this.visibleRoles = visibleRoles; + return this; + } + + public API addVisibleRolesItem(String visibleRolesItem) { + this.visibleRoles.add(visibleRolesItem); + return this; + } + + /** + * Get visibleRoles + * @return visibleRoles + **/ + @ApiModelProperty(example = "null", value = "") + public List getVisibleRoles() { + return visibleRoles; + } + + public void setVisibleRoles(List visibleRoles) { + this.visibleRoles = visibleRoles; + } + + public API visibleTenants(List visibleTenants) { + this.visibleTenants = visibleTenants; + return this; + } + + public API addVisibleTenantsItem(String visibleTenantsItem) { + this.visibleTenants.add(visibleTenantsItem); + return this; + } + + /** + * Get visibleTenants + * @return visibleTenants + **/ + @ApiModelProperty(example = "null", value = "") + public List getVisibleTenants() { + return visibleTenants; + } + + public void setVisibleTenants(List visibleTenants) { + this.visibleTenants = visibleTenants; + } + + public API endpointConfig(String endpointConfig) { + this.endpointConfig = endpointConfig; + return this; + } + + /** + * Get endpointConfig + * @return endpointConfig + **/ + @ApiModelProperty(example = "{"production_endpoints":{"url":"http://localhost:9763/am/sample/calculator/v1/api","config":null},"implementation_status":"managed","endpoint_type":"http"}", required = true, value = "") + public String getEndpointConfig() { + return endpointConfig; + } + + public void setEndpointConfig(String endpointConfig) { + this.endpointConfig = endpointConfig; + } + + public API endpointSecurity(APIEndpointSecurity endpointSecurity) { + this.endpointSecurity = endpointSecurity; + return this; + } + + /** + * Get endpointSecurity + * @return endpointSecurity + **/ + @ApiModelProperty(example = "null", value = "") + public APIEndpointSecurity getEndpointSecurity() { + return endpointSecurity; + } + + public void setEndpointSecurity(APIEndpointSecurity endpointSecurity) { + this.endpointSecurity = endpointSecurity; + } + + public API gatewayEnvironments(String gatewayEnvironments) { + this.gatewayEnvironments = gatewayEnvironments; + return this; + } + + /** + * Comma separated list of gateway environments. + * @return gatewayEnvironments + **/ + @ApiModelProperty(example = "Production and Sandbox", value = "Comma separated list of gateway environments. ") + public String getGatewayEnvironments() { + return gatewayEnvironments; + } + + public void setGatewayEnvironments(String gatewayEnvironments) { + this.gatewayEnvironments = gatewayEnvironments; + } + + public API sequences(List sequences) { + this.sequences = sequences; + return this; + } + + public API addSequencesItem(Sequence sequencesItem) { + this.sequences.add(sequencesItem); + return this; + } + + /** + * Get sequences + * @return sequences + **/ + @ApiModelProperty(example = "null", value = "") + public List getSequences() { + return sequences; + } + + public void setSequences(List sequences) { + this.sequences = sequences; + } + + public API subscriptionAvailability(SubscriptionAvailabilityEnum subscriptionAvailability) { + this.subscriptionAvailability = subscriptionAvailability; + return this; + } + + /** + * Get subscriptionAvailability + * @return subscriptionAvailability + **/ + @ApiModelProperty(example = "current_tenant", value = "") + public SubscriptionAvailabilityEnum getSubscriptionAvailability() { + return subscriptionAvailability; + } + + public void setSubscriptionAvailability(SubscriptionAvailabilityEnum subscriptionAvailability) { + this.subscriptionAvailability = subscriptionAvailability; + } + + public API subscriptionAvailableTenants(List subscriptionAvailableTenants) { + this.subscriptionAvailableTenants = subscriptionAvailableTenants; + return this; + } + + public API addSubscriptionAvailableTenantsItem(String subscriptionAvailableTenantsItem) { + this.subscriptionAvailableTenants.add(subscriptionAvailableTenantsItem); + return this; + } + + /** + * Get subscriptionAvailableTenants + * @return subscriptionAvailableTenants + **/ + @ApiModelProperty(example = "null", value = "") + public List getSubscriptionAvailableTenants() { + return subscriptionAvailableTenants; + } + + public void setSubscriptionAvailableTenants(List subscriptionAvailableTenants) { + this.subscriptionAvailableTenants = subscriptionAvailableTenants; + } + + public API businessInformation(APIBusinessInformation businessInformation) { + this.businessInformation = businessInformation; + return this; + } + + /** + * Get businessInformation + * @return businessInformation + **/ + @ApiModelProperty(example = "null", value = "") + public APIBusinessInformation getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(APIBusinessInformation businessInformation) { + this.businessInformation = businessInformation; + } + + public API corsConfiguration(APICorsConfiguration corsConfiguration) { + this.corsConfiguration = corsConfiguration; + return this; + } + + /** + * Get corsConfiguration + * @return corsConfiguration + **/ + @ApiModelProperty(example = "null", value = "") + public APICorsConfiguration getCorsConfiguration() { + return corsConfiguration; + } + + public void setCorsConfiguration(APICorsConfiguration corsConfiguration) { + this.corsConfiguration = corsConfiguration; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + API API = (org.wso2.carbon.apimgt.integration.client.publisher.model.API) o; + return Objects.equals(this.id, API.id) && + Objects.equals(this.name, API.name) && + Objects.equals(this.description, API.description) && + Objects.equals(this.context, API.context) && + Objects.equals(this.version, API.version) && + Objects.equals(this.provider, API.provider) && + Objects.equals(this.apiDefinition, API.apiDefinition) && + Objects.equals(this.wsdlUri, API.wsdlUri) && + Objects.equals(this.status, API.status) && + Objects.equals(this.responseCaching, API.responseCaching) && + Objects.equals(this.cacheTimeout, API.cacheTimeout) && + Objects.equals(this.destinationStatsEnabled, API.destinationStatsEnabled) && + Objects.equals(this.isDefaultVersion, API.isDefaultVersion) && + Objects.equals(this.transport, API.transport) && + Objects.equals(this.tags, API.tags) && + Objects.equals(this.tiers, API.tiers) && + Objects.equals(this.maxTps, API.maxTps) && + Objects.equals(this.thumbnailUri, API.thumbnailUri) && + Objects.equals(this.visibility, API.visibility) && + Objects.equals(this.visibleRoles, API.visibleRoles) && + Objects.equals(this.visibleTenants, API.visibleTenants) && + Objects.equals(this.endpointConfig, API.endpointConfig) && + Objects.equals(this.endpointSecurity, API.endpointSecurity) && + Objects.equals(this.gatewayEnvironments, API.gatewayEnvironments) && + Objects.equals(this.sequences, API.sequences) && + Objects.equals(this.subscriptionAvailability, API.subscriptionAvailability) && + Objects.equals(this.subscriptionAvailableTenants, API.subscriptionAvailableTenants) && + Objects.equals(this.businessInformation, API.businessInformation) && + Objects.equals(this.corsConfiguration, API.corsConfiguration); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, context, version, provider, apiDefinition, wsdlUri, status, responseCaching, cacheTimeout, destinationStatsEnabled, isDefaultVersion, transport, tags, tiers, maxTps, thumbnailUri, visibility, visibleRoles, visibleTenants, endpointConfig, endpointSecurity, gatewayEnvironments, sequences, subscriptionAvailability, subscriptionAvailableTenants, businessInformation, corsConfiguration); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class API {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" apiDefinition: ").append(toIndentedString(apiDefinition)).append("\n"); + sb.append(" wsdlUri: ").append(toIndentedString(wsdlUri)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" responseCaching: ").append(toIndentedString(responseCaching)).append("\n"); + sb.append(" cacheTimeout: ").append(toIndentedString(cacheTimeout)).append("\n"); + sb.append(" destinationStatsEnabled: ").append(toIndentedString(destinationStatsEnabled)).append("\n"); + sb.append(" isDefaultVersion: ").append(toIndentedString(isDefaultVersion)).append("\n"); + sb.append(" transport: ").append(toIndentedString(transport)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" tiers: ").append(toIndentedString(tiers)).append("\n"); + sb.append(" maxTps: ").append(toIndentedString(maxTps)).append("\n"); + sb.append(" thumbnailUri: ").append(toIndentedString(thumbnailUri)).append("\n"); + sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n"); + sb.append(" visibleRoles: ").append(toIndentedString(visibleRoles)).append("\n"); + sb.append(" visibleTenants: ").append(toIndentedString(visibleTenants)).append("\n"); + sb.append(" endpointConfig: ").append(toIndentedString(endpointConfig)).append("\n"); + sb.append(" endpointSecurity: ").append(toIndentedString(endpointSecurity)).append("\n"); + sb.append(" gatewayEnvironments: ").append(toIndentedString(gatewayEnvironments)).append("\n"); + sb.append(" sequences: ").append(toIndentedString(sequences)).append("\n"); + sb.append(" subscriptionAvailability: ").append(toIndentedString(subscriptionAvailability)).append("\n"); + sb.append(" subscriptionAvailableTenants: ").append(toIndentedString(subscriptionAvailableTenants)).append("\n"); + sb.append(" businessInformation: ").append(toIndentedString(businessInformation)).append("\n"); + sb.append(" corsConfiguration: ").append(toIndentedString(corsConfiguration)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIBusinessInformation.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIBusinessInformation.java new file mode 100644 index 00000000000..0ef7335d5e7 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIBusinessInformation.java @@ -0,0 +1,168 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIBusinessInformation + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APIBusinessInformation { + @JsonProperty("businessOwner") + private String businessOwner = null; + + @JsonProperty("businessOwnerEmail") + private String businessOwnerEmail = null; + + @JsonProperty("technicalOwner") + private String technicalOwner = null; + + @JsonProperty("technicalOwnerEmail") + private String technicalOwnerEmail = null; + + public APIBusinessInformation businessOwner(String businessOwner) { + this.businessOwner = businessOwner; + return this; + } + + /** + * Get businessOwner + * @return businessOwner + **/ + @ApiModelProperty(example = "businessowner", value = "") + public String getBusinessOwner() { + return businessOwner; + } + + public void setBusinessOwner(String businessOwner) { + this.businessOwner = businessOwner; + } + + public APIBusinessInformation businessOwnerEmail(String businessOwnerEmail) { + this.businessOwnerEmail = businessOwnerEmail; + return this; + } + + /** + * Get businessOwnerEmail + * @return businessOwnerEmail + **/ + @ApiModelProperty(example = "businessowner@wso2.com", value = "") + public String getBusinessOwnerEmail() { + return businessOwnerEmail; + } + + public void setBusinessOwnerEmail(String businessOwnerEmail) { + this.businessOwnerEmail = businessOwnerEmail; + } + + public APIBusinessInformation technicalOwner(String technicalOwner) { + this.technicalOwner = technicalOwner; + return this; + } + + /** + * Get technicalOwner + * @return technicalOwner + **/ + @ApiModelProperty(example = "technicalowner", value = "") + public String getTechnicalOwner() { + return technicalOwner; + } + + public void setTechnicalOwner(String technicalOwner) { + this.technicalOwner = technicalOwner; + } + + public APIBusinessInformation technicalOwnerEmail(String technicalOwnerEmail) { + this.technicalOwnerEmail = technicalOwnerEmail; + return this; + } + + /** + * Get technicalOwnerEmail + * @return technicalOwnerEmail + **/ + @ApiModelProperty(example = "technicalowner@wso2.com", value = "") + public String getTechnicalOwnerEmail() { + return technicalOwnerEmail; + } + + public void setTechnicalOwnerEmail(String technicalOwnerEmail) { + this.technicalOwnerEmail = technicalOwnerEmail; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIBusinessInformation aPIBusinessInformation = (APIBusinessInformation) o; + return Objects.equals(this.businessOwner, aPIBusinessInformation.businessOwner) && + Objects.equals(this.businessOwnerEmail, aPIBusinessInformation.businessOwnerEmail) && + Objects.equals(this.technicalOwner, aPIBusinessInformation.technicalOwner) && + Objects.equals(this.technicalOwnerEmail, aPIBusinessInformation.technicalOwnerEmail); + } + + @Override + public int hashCode() { + return Objects.hash(businessOwner, businessOwnerEmail, technicalOwner, technicalOwnerEmail); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIBusinessInformation {\n"); + + sb.append(" businessOwner: ").append(toIndentedString(businessOwner)).append("\n"); + sb.append(" businessOwnerEmail: ").append(toIndentedString(businessOwnerEmail)).append("\n"); + sb.append(" technicalOwner: ").append(toIndentedString(technicalOwner)).append("\n"); + sb.append(" technicalOwnerEmail: ").append(toIndentedString(technicalOwnerEmail)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APICorsConfiguration.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APICorsConfiguration.java new file mode 100644 index 00000000000..707e5c08fc3 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APICorsConfiguration.java @@ -0,0 +1,210 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * CORS configuration for the API + */ +@ApiModel(description = "CORS configuration for the API ") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APICorsConfiguration { + @JsonProperty("corsConfigurationEnabled") + private Boolean corsConfigurationEnabled = false; + + @JsonProperty("accessControlAllowOrigins") + private List accessControlAllowOrigins = new ArrayList(); + + @JsonProperty("accessControlAllowCredentials") + private Boolean accessControlAllowCredentials = false; + + @JsonProperty("accessControlAllowHeaders") + private List accessControlAllowHeaders = new ArrayList(); + + @JsonProperty("accessControlAllowMethods") + private List accessControlAllowMethods = new ArrayList(); + + public APICorsConfiguration corsConfigurationEnabled(Boolean corsConfigurationEnabled) { + this.corsConfigurationEnabled = corsConfigurationEnabled; + return this; + } + + /** + * Get corsConfigurationEnabled + * @return corsConfigurationEnabled + **/ + @ApiModelProperty(example = "null", value = "") + public Boolean getCorsConfigurationEnabled() { + return corsConfigurationEnabled; + } + + public void setCorsConfigurationEnabled(Boolean corsConfigurationEnabled) { + this.corsConfigurationEnabled = corsConfigurationEnabled; + } + + public APICorsConfiguration accessControlAllowOrigins(List accessControlAllowOrigins) { + this.accessControlAllowOrigins = accessControlAllowOrigins; + return this; + } + + public APICorsConfiguration addAccessControlAllowOriginsItem(String accessControlAllowOriginsItem) { + this.accessControlAllowOrigins.add(accessControlAllowOriginsItem); + return this; + } + + /** + * Get accessControlAllowOrigins + * @return accessControlAllowOrigins + **/ + @ApiModelProperty(example = "null", value = "") + public List getAccessControlAllowOrigins() { + return accessControlAllowOrigins; + } + + public void setAccessControlAllowOrigins(List accessControlAllowOrigins) { + this.accessControlAllowOrigins = accessControlAllowOrigins; + } + + public APICorsConfiguration accessControlAllowCredentials(Boolean accessControlAllowCredentials) { + this.accessControlAllowCredentials = accessControlAllowCredentials; + return this; + } + + /** + * Get accessControlAllowCredentials + * @return accessControlAllowCredentials + **/ + @ApiModelProperty(example = "null", value = "") + public Boolean getAccessControlAllowCredentials() { + return accessControlAllowCredentials; + } + + public void setAccessControlAllowCredentials(Boolean accessControlAllowCredentials) { + this.accessControlAllowCredentials = accessControlAllowCredentials; + } + + public APICorsConfiguration accessControlAllowHeaders(List accessControlAllowHeaders) { + this.accessControlAllowHeaders = accessControlAllowHeaders; + return this; + } + + public APICorsConfiguration addAccessControlAllowHeadersItem(String accessControlAllowHeadersItem) { + this.accessControlAllowHeaders.add(accessControlAllowHeadersItem); + return this; + } + + /** + * Get accessControlAllowHeaders + * @return accessControlAllowHeaders + **/ + @ApiModelProperty(example = "null", value = "") + public List getAccessControlAllowHeaders() { + return accessControlAllowHeaders; + } + + public void setAccessControlAllowHeaders(List accessControlAllowHeaders) { + this.accessControlAllowHeaders = accessControlAllowHeaders; + } + + public APICorsConfiguration accessControlAllowMethods(List accessControlAllowMethods) { + this.accessControlAllowMethods = accessControlAllowMethods; + return this; + } + + public APICorsConfiguration addAccessControlAllowMethodsItem(String accessControlAllowMethodsItem) { + this.accessControlAllowMethods.add(accessControlAllowMethodsItem); + return this; + } + + /** + * Get accessControlAllowMethods + * @return accessControlAllowMethods + **/ + @ApiModelProperty(example = "null", value = "") + public List getAccessControlAllowMethods() { + return accessControlAllowMethods; + } + + public void setAccessControlAllowMethods(List accessControlAllowMethods) { + this.accessControlAllowMethods = accessControlAllowMethods; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APICorsConfiguration aPICorsConfiguration = (APICorsConfiguration) o; + return Objects.equals(this.corsConfigurationEnabled, aPICorsConfiguration.corsConfigurationEnabled) && + Objects.equals(this.accessControlAllowOrigins, aPICorsConfiguration.accessControlAllowOrigins) && + Objects.equals(this.accessControlAllowCredentials, aPICorsConfiguration.accessControlAllowCredentials) && + Objects.equals(this.accessControlAllowHeaders, aPICorsConfiguration.accessControlAllowHeaders) && + Objects.equals(this.accessControlAllowMethods, aPICorsConfiguration.accessControlAllowMethods); + } + + @Override + public int hashCode() { + return Objects.hash(corsConfigurationEnabled, accessControlAllowOrigins, accessControlAllowCredentials, accessControlAllowHeaders, accessControlAllowMethods); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APICorsConfiguration {\n"); + + sb.append(" corsConfigurationEnabled: ").append(toIndentedString(corsConfigurationEnabled)).append("\n"); + sb.append(" accessControlAllowOrigins: ").append(toIndentedString(accessControlAllowOrigins)).append("\n"); + sb.append(" accessControlAllowCredentials: ").append(toIndentedString(accessControlAllowCredentials)).append("\n"); + sb.append(" accessControlAllowHeaders: ").append(toIndentedString(accessControlAllowHeaders)).append("\n"); + sb.append(" accessControlAllowMethods: ").append(toIndentedString(accessControlAllowMethods)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIEndpointSecurity.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIEndpointSecurity.java new file mode 100644 index 00000000000..9ffc7088ec5 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIEndpointSecurity.java @@ -0,0 +1,176 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIEndpointSecurity + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APIEndpointSecurity { + /** + * Gets or Sets type + */ + public enum TypeEnum { + BASIC("basic"), + + DIGEST("digest"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String text) { + for (TypeEnum b : TypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("type") + private TypeEnum type = null; + + @JsonProperty("username") + private String username = null; + + @JsonProperty("password") + private String password = null; + + public APIEndpointSecurity type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(example = "basic", value = "") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public APIEndpointSecurity username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @ApiModelProperty(example = "admin", value = "") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public APIEndpointSecurity password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(example = "password", value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIEndpointSecurity aPIEndpointSecurity = (APIEndpointSecurity) o; + return Objects.equals(this.type, aPIEndpointSecurity.type) && + Objects.equals(this.username, aPIEndpointSecurity.username) && + Objects.equals(this.password, aPIEndpointSecurity.password); + } + + @Override + public int hashCode() { + return Objects.hash(type, username, password); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIEndpointSecurity {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIInfo.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIInfo.java new file mode 100644 index 00000000000..05abbdc698e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIInfo.java @@ -0,0 +1,237 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIInfo + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APIInfo { + @JsonProperty("id") + private String id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("context") + private String context = null; + + @JsonProperty("version") + private String version = null; + + @JsonProperty("provider") + private String provider = null; + + @JsonProperty("status") + private String status = null; + + public APIInfo id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public APIInfo name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorAPI", value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public APIInfo description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "A calculator API that supports basic operations", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public APIInfo context(String context) { + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @ApiModelProperty(example = "CalculatorAPI", value = "") + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public APIInfo version(String version) { + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @ApiModelProperty(example = "1.0.0", value = "") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public APIInfo provider(String provider) { + this.provider = provider; + return this; + } + + /** + * If the provider value is not given, the user invoking the API will be used as the provider. + * @return provider + **/ + @ApiModelProperty(example = "admin", value = "If the provider value is not given, the user invoking the API will be used as the provider. ") + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public APIInfo status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "CREATED", value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIInfo aPIInfo = (APIInfo) o; + return Objects.equals(this.id, aPIInfo.id) && + Objects.equals(this.name, aPIInfo.name) && + Objects.equals(this.description, aPIInfo.description) && + Objects.equals(this.context, aPIInfo.context) && + Objects.equals(this.version, aPIInfo.version) && + Objects.equals(this.provider, aPIInfo.provider) && + Objects.equals(this.status, aPIInfo.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, context, version, provider, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIInfo {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIList.java new file mode 100644 index 00000000000..f62fea9a8c3 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * APIList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APIList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public APIList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of APIs returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of APIs returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public APIList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/apis?limit=1&offset=2&query=", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public APIList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/apis?limit=1&offset=0&query=", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public APIList list(List list) { + this.list = list; + return this; + } + + public APIList addListItem(APIInfo listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIList aPIList = (APIList) o; + return Objects.equals(this.count, aPIList.count) && + Objects.equals(this.next, aPIList.next) && + Objects.equals(this.previous, aPIList.previous) && + Objects.equals(this.list, aPIList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIMaxTps.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIMaxTps.java new file mode 100644 index 00000000000..a6a83ffd537 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/APIMaxTps.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIMaxTps + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class APIMaxTps { + @JsonProperty("production") + private Long production = null; + + @JsonProperty("sandbox") + private Long sandbox = null; + + public APIMaxTps production(Long production) { + this.production = production; + return this; + } + + /** + * Get production + * @return production + **/ + @ApiModelProperty(example = "1000", value = "") + public Long getProduction() { + return production; + } + + public void setProduction(Long production) { + this.production = production; + } + + public APIMaxTps sandbox(Long sandbox) { + this.sandbox = sandbox; + return this; + } + + /** + * Get sandbox + * @return sandbox + **/ + @ApiModelProperty(example = "1000", value = "") + public Long getSandbox() { + return sandbox; + } + + public void setSandbox(Long sandbox) { + this.sandbox = sandbox; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIMaxTps aPIMaxTps = (APIMaxTps) o; + return Objects.equals(this.production, aPIMaxTps.production) && + Objects.equals(this.sandbox, aPIMaxTps.sandbox); + } + + @Override + public int hashCode() { + return Objects.hash(production, sandbox); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIMaxTps {\n"); + + sb.append(" production: ").append(toIndentedString(production)).append("\n"); + sb.append(" sandbox: ").append(toIndentedString(sandbox)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Application.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Application.java new file mode 100644 index 00000000000..09e0fa94290 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Application.java @@ -0,0 +1,214 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Application + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Application { + @JsonProperty("applicationId") + private String applicationId = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("subscriber") + private String subscriber = null; + + @JsonProperty("throttlingTier") + private String throttlingTier = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("groupId") + private String groupId = null; + + public Application applicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get applicationId + * @return applicationId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public Application name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorApp", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Application subscriber(String subscriber) { + this.subscriber = subscriber; + return this; + } + + /** + * Get subscriber + * @return subscriber + **/ + @ApiModelProperty(example = "admin", value = "") + public String getSubscriber() { + return subscriber; + } + + public void setSubscriber(String subscriber) { + this.subscriber = subscriber; + } + + public Application throttlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + return this; + } + + /** + * Get throttlingTier + * @return throttlingTier + **/ + @ApiModelProperty(example = "Unlimited", required = true, value = "") + public String getThrottlingTier() { + return throttlingTier; + } + + public void setThrottlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + } + + public Application description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "Sample calculator application", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Application groupId(String groupId) { + this.groupId = groupId; + return this; + } + + /** + * Get groupId + * @return groupId + **/ + @ApiModelProperty(example = "", value = "") + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Application application = (Application) o; + return Objects.equals(this.applicationId, application.applicationId) && + Objects.equals(this.name, application.name) && + Objects.equals(this.subscriber, application.subscriber) && + Objects.equals(this.throttlingTier, application.throttlingTier) && + Objects.equals(this.description, application.description) && + Objects.equals(this.groupId, application.groupId); + } + + @Override + public int hashCode() { + return Objects.hash(applicationId, name, subscriber, throttlingTier, description, groupId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Application {\n"); + + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" subscriber: ").append(toIndentedString(subscriber)).append("\n"); + sb.append(" throttlingTier: ").append(toIndentedString(throttlingTier)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Document.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Document.java new file mode 100644 index 00000000000..d0dfa2ad90f --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Document.java @@ -0,0 +1,365 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Document + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Document { + @JsonProperty("documentId") + private String documentId = null; + + @JsonProperty("name") + private String name = null; + + /** + * Gets or Sets type + */ + public enum TypeEnum { + HOWTO("HOWTO"), + + SAMPLES("SAMPLES"), + + PUBLIC_FORUM("PUBLIC_FORUM"), + + SUPPORT_FORUM("SUPPORT_FORUM"), + + API_MESSAGE_FORMAT("API_MESSAGE_FORMAT"), + + SWAGGER_DOC("SWAGGER_DOC"), + + OTHER("OTHER"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String text) { + for (TypeEnum b : TypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("type") + private TypeEnum type = null; + + @JsonProperty("summary") + private String summary = null; + + /** + * Gets or Sets sourceType + */ + public enum SourceTypeEnum { + INLINE("INLINE"), + + URL("URL"), + + FILE("FILE"); + + private String value; + + SourceTypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static SourceTypeEnum fromValue(String text) { + for (SourceTypeEnum b : SourceTypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("sourceType") + private SourceTypeEnum sourceType = null; + + @JsonProperty("sourceUrl") + private String sourceUrl = null; + + @JsonProperty("otherTypeName") + private String otherTypeName = null; + + /** + * Gets or Sets visibility + */ + public enum VisibilityEnum { + OWNER_ONLY("OWNER_ONLY"), + + PRIVATE("PRIVATE"), + + API_LEVEL("API_LEVEL"); + + private String value; + + VisibilityEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VisibilityEnum fromValue(String text) { + for (VisibilityEnum b : VisibilityEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("visibility") + private VisibilityEnum visibility = null; + + public Document documentId(String documentId) { + this.documentId = documentId; + return this; + } + + /** + * Get documentId + * @return documentId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public Document name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorDoc", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Document type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(example = "HOWTO", required = true, value = "") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public Document summary(String summary) { + this.summary = summary; + return this; + } + + /** + * Get summary + * @return summary + **/ + @ApiModelProperty(example = "Summary of Calculator Documentation", value = "") + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public Document sourceType(SourceTypeEnum sourceType) { + this.sourceType = sourceType; + return this; + } + + /** + * Get sourceType + * @return sourceType + **/ + @ApiModelProperty(example = "INLINE", required = true, value = "") + public SourceTypeEnum getSourceType() { + return sourceType; + } + + public void setSourceType(SourceTypeEnum sourceType) { + this.sourceType = sourceType; + } + + public Document sourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + return this; + } + + /** + * Get sourceUrl + * @return sourceUrl + **/ + @ApiModelProperty(example = "", value = "") + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public Document otherTypeName(String otherTypeName) { + this.otherTypeName = otherTypeName; + return this; + } + + /** + * Get otherTypeName + * @return otherTypeName + **/ + @ApiModelProperty(example = "", value = "") + public String getOtherTypeName() { + return otherTypeName; + } + + public void setOtherTypeName(String otherTypeName) { + this.otherTypeName = otherTypeName; + } + + public Document visibility(VisibilityEnum visibility) { + this.visibility = visibility; + return this; + } + + /** + * Get visibility + * @return visibility + **/ + @ApiModelProperty(example = "API_LEVEL", required = true, value = "") + public VisibilityEnum getVisibility() { + return visibility; + } + + public void setVisibility(VisibilityEnum visibility) { + this.visibility = visibility; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Document document = (Document) o; + return Objects.equals(this.documentId, document.documentId) && + Objects.equals(this.name, document.name) && + Objects.equals(this.type, document.type) && + Objects.equals(this.summary, document.summary) && + Objects.equals(this.sourceType, document.sourceType) && + Objects.equals(this.sourceUrl, document.sourceUrl) && + Objects.equals(this.otherTypeName, document.otherTypeName) && + Objects.equals(this.visibility, document.visibility); + } + + @Override + public int hashCode() { + return Objects.hash(documentId, name, type, summary, sourceType, sourceUrl, otherTypeName, visibility); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Document {\n"); + + sb.append(" documentId: ").append(toIndentedString(documentId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" sourceUrl: ").append(toIndentedString(sourceUrl)).append("\n"); + sb.append(" otherTypeName: ").append(toIndentedString(otherTypeName)).append("\n"); + sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/DocumentList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/DocumentList.java new file mode 100644 index 00000000000..9a9c16003fe --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/DocumentList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * DocumentList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class DocumentList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public DocumentList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Documents returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Documents returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public DocumentList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public DocumentList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public DocumentList list(List list) { + this.list = list; + return this; + } + + public DocumentList addListItem(Document listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentList documentList = (DocumentList) o; + return Objects.equals(this.count, documentList.count) && + Objects.equals(this.next, documentList.next) && + Objects.equals(this.previous, documentList.previous) && + Objects.equals(this.list, documentList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Environment.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Environment.java new file mode 100644 index 00000000000..7744ed91b76 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Environment.java @@ -0,0 +1,191 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Environment + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Environment { + @JsonProperty("name") + private String name = null; + + @JsonProperty("type") + private String type = null; + + @JsonProperty("serverUrl") + private String serverUrl = null; + + @JsonProperty("showInApiConsole") + private Boolean showInApiConsole = null; + + @JsonProperty("endpoints") + private EnvironmentEndpoints endpoints = null; + + public Environment name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "Production and Sandbox", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Environment type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(example = "hybrid", required = true, value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Environment serverUrl(String serverUrl) { + this.serverUrl = serverUrl; + return this; + } + + /** + * Get serverUrl + * @return serverUrl + **/ + @ApiModelProperty(example = "https://localhost:9443//services/", required = true, value = "") + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public Environment showInApiConsole(Boolean showInApiConsole) { + this.showInApiConsole = showInApiConsole; + return this; + } + + /** + * Get showInApiConsole + * @return showInApiConsole + **/ + @ApiModelProperty(example = "true", required = true, value = "") + public Boolean getShowInApiConsole() { + return showInApiConsole; + } + + public void setShowInApiConsole(Boolean showInApiConsole) { + this.showInApiConsole = showInApiConsole; + } + + public Environment endpoints(EnvironmentEndpoints endpoints) { + this.endpoints = endpoints; + return this; + } + + /** + * Get endpoints + * @return endpoints + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public EnvironmentEndpoints getEndpoints() { + return endpoints; + } + + public void setEndpoints(EnvironmentEndpoints endpoints) { + this.endpoints = endpoints; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Environment environment = (Environment) o; + return Objects.equals(this.name, environment.name) && + Objects.equals(this.type, environment.type) && + Objects.equals(this.serverUrl, environment.serverUrl) && + Objects.equals(this.showInApiConsole, environment.showInApiConsole) && + Objects.equals(this.endpoints, environment.endpoints); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, serverUrl, showInApiConsole, endpoints); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Environment {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" serverUrl: ").append(toIndentedString(serverUrl)).append("\n"); + sb.append(" showInApiConsole: ").append(toIndentedString(showInApiConsole)).append("\n"); + sb.append(" endpoints: ").append(toIndentedString(endpoints)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentEndpoints.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentEndpoints.java new file mode 100644 index 00000000000..d25686dcdb7 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentEndpoints.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * EnvironmentEndpoints + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class EnvironmentEndpoints { + @JsonProperty("http") + private String http = null; + + @JsonProperty("https") + private String https = null; + + public EnvironmentEndpoints http(String http) { + this.http = http; + return this; + } + + /** + * HTTP environment URL + * @return http + **/ + @ApiModelProperty(example = "http://localhost:8280", value = "HTTP environment URL") + public String getHttp() { + return http; + } + + public void setHttp(String http) { + this.http = http; + } + + public EnvironmentEndpoints https(String https) { + this.https = https; + return this; + } + + /** + * HTTPS environment URL + * @return https + **/ + @ApiModelProperty(example = "https://localhost:8244", value = "HTTPS environment URL") + public String getHttps() { + return https; + } + + public void setHttps(String https) { + this.https = https; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnvironmentEndpoints environmentEndpoints = (EnvironmentEndpoints) o; + return Objects.equals(this.http, environmentEndpoints.http) && + Objects.equals(this.https, environmentEndpoints.https); + } + + @Override + public int hashCode() { + return Objects.hash(http, https); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnvironmentEndpoints {\n"); + + sb.append(" http: ").append(toIndentedString(http)).append("\n"); + sb.append(" https: ").append(toIndentedString(https)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentList.java new file mode 100644 index 00000000000..6440009cb2c --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/EnvironmentList.java @@ -0,0 +1,129 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * EnvironmentList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class EnvironmentList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public EnvironmentList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Environments returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Environments returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public EnvironmentList list(List list) { + this.list = list; + return this; + } + + public EnvironmentList addListItem(Environment listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnvironmentList environmentList = (EnvironmentList) o; + return Objects.equals(this.count, environmentList.count) && + Objects.equals(this.list, environmentList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnvironmentList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Error.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Error.java new file mode 100644 index 00000000000..94ced5af6b0 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Error.java @@ -0,0 +1,198 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * Error + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Error { + @JsonProperty("code") + private Long code = null; + + @JsonProperty("message") + private String message = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("moreInfo") + private String moreInfo = null; + + @JsonProperty("error") + private List error = new ArrayList(); + + public Error code(Long code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public Long getCode() { + return code; + } + + public void setCode(Long code) { + this.code = code; + } + + public Error message(String message) { + this.message = message; + return this; + } + + /** + * Error message. + * @return message + **/ + @ApiModelProperty(example = "null", required = true, value = "Error message.") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Error description(String description) { + this.description = description; + return this; + } + + /** + * A detail description about the error message. + * @return description + **/ + @ApiModelProperty(example = "null", value = "A detail description about the error message. ") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Error moreInfo(String moreInfo) { + this.moreInfo = moreInfo; + return this; + } + + /** + * Preferably an url with more details about the error. + * @return moreInfo + **/ + @ApiModelProperty(example = "null", value = "Preferably an url with more details about the error. ") + public String getMoreInfo() { + return moreInfo; + } + + public void setMoreInfo(String moreInfo) { + this.moreInfo = moreInfo; + } + + public Error error(List error) { + this.error = error; + return this; + } + + public Error addErrorItem(ErrorListItem errorItem) { + this.error.add(errorItem); + return this; + } + + /** + * If there are more than one error list them out. For example, list out validation errors by each field. + * @return error + **/ + @ApiModelProperty(example = "null", value = "If there are more than one error list them out. For example, list out validation errors by each field. ") + public List getError() { + return error; + } + + public void setError(List error) { + this.error = error; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.moreInfo, error.moreInfo) && + Objects.equals(this.error, error.error); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, moreInfo, error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" moreInfo: ").append(toIndentedString(moreInfo)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/ErrorListItem.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/ErrorListItem.java new file mode 100644 index 00000000000..a25c6827a34 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/ErrorListItem.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * ErrorListItem + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class ErrorListItem { + @JsonProperty("code") + private String code = null; + + @JsonProperty("message") + private String message = null; + + public ErrorListItem code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public ErrorListItem message(String message) { + this.message = message; + return this; + } + + /** + * Description about individual errors occurred + * @return message + **/ + @ApiModelProperty(example = "null", required = true, value = "Description about individual errors occurred ") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorListItem errorListItem = (ErrorListItem) o; + return Objects.equals(this.code, errorListItem.code) && + Objects.equals(this.message, errorListItem.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorListItem {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/FileInfo.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/FileInfo.java new file mode 100644 index 00000000000..bfcd100386d --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/FileInfo.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * FileInfo + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class FileInfo { + @JsonProperty("relativePath") + private String relativePath = null; + + @JsonProperty("mediaType") + private String mediaType = null; + + public FileInfo relativePath(String relativePath) { + this.relativePath = relativePath; + return this; + } + + /** + * relative location of the file (excluding the base context and host of the Publisher API) + * @return relativePath + **/ + @ApiModelProperty(example = "apis/01234567-0123-0123-0123-012345678901/thumbnail", value = "relative location of the file (excluding the base context and host of the Publisher API)") + public String getRelativePath() { + return relativePath; + } + + public void setRelativePath(String relativePath) { + this.relativePath = relativePath; + } + + public FileInfo mediaType(String mediaType) { + this.mediaType = mediaType; + return this; + } + + /** + * media-type of the file + * @return mediaType + **/ + @ApiModelProperty(example = "image/jpeg", value = "media-type of the file") + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileInfo fileInfo = (FileInfo) o; + return Objects.equals(this.relativePath, fileInfo.relativePath) && + Objects.equals(this.mediaType, fileInfo.mediaType); + } + + @Override + public int hashCode() { + return Objects.hash(relativePath, mediaType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileInfo {\n"); + + sb.append(" relativePath: ").append(toIndentedString(relativePath)).append("\n"); + sb.append(" mediaType: ").append(toIndentedString(mediaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Sequence.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Sequence.java new file mode 100644 index 00000000000..7cd5b67d86d --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Sequence.java @@ -0,0 +1,145 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Sequence + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Sequence { + @JsonProperty("name") + private String name = null; + + @JsonProperty("config") + private String config = null; + + @JsonProperty("type") + private String type = null; + + public Sequence name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "log_in_message", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Sequence config(String config) { + this.config = config; + return this; + } + + /** + * Get config + * @return config + **/ + @ApiModelProperty(example = "", value = "") + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + + public Sequence type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(example = "in", value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Sequence sequence = (Sequence) o; + return Objects.equals(this.name, sequence.name) && + Objects.equals(this.config, sequence.config) && + Objects.equals(this.type, sequence.type); + } + + @Override + public int hashCode() { + return Objects.hash(name, config, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Sequence {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Subscription.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Subscription.java new file mode 100644 index 00000000000..5a4c4c3ca6e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Subscription.java @@ -0,0 +1,228 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Subscription + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Subscription { + @JsonProperty("subscriptionId") + private String subscriptionId = null; + + @JsonProperty("applicationId") + private String applicationId = null; + + @JsonProperty("apiIdentifier") + private String apiIdentifier = null; + + @JsonProperty("tier") + private String tier = null; + + /** + * Gets or Sets status + */ + public enum StatusEnum { + BLOCKED("BLOCKED"), + + PROD_ONLY_BLOCKED("PROD_ONLY_BLOCKED"), + + UNBLOCKED("UNBLOCKED"), + + ON_HOLD("ON_HOLD"), + + REJECTED("REJECTED"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + public Subscription subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get subscriptionId + * @return subscriptionId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + public Subscription applicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get applicationId + * @return applicationId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", required = true, value = "") + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public Subscription apiIdentifier(String apiIdentifier) { + this.apiIdentifier = apiIdentifier; + return this; + } + + /** + * Get apiIdentifier + * @return apiIdentifier + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", required = true, value = "") + public String getApiIdentifier() { + return apiIdentifier; + } + + public void setApiIdentifier(String apiIdentifier) { + this.apiIdentifier = apiIdentifier; + } + + public Subscription tier(String tier) { + this.tier = tier; + return this; + } + + /** + * Get tier + * @return tier + **/ + @ApiModelProperty(example = "Unlimited", required = true, value = "") + public String getTier() { + return tier; + } + + public void setTier(String tier) { + this.tier = tier; + } + + public Subscription status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "UNBLOCKED", value = "") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Subscription subscription = (Subscription) o; + return Objects.equals(this.subscriptionId, subscription.subscriptionId) && + Objects.equals(this.applicationId, subscription.applicationId) && + Objects.equals(this.apiIdentifier, subscription.apiIdentifier) && + Objects.equals(this.tier, subscription.tier) && + Objects.equals(this.status, subscription.status); + } + + @Override + public int hashCode() { + return Objects.hash(subscriptionId, applicationId, apiIdentifier, tier, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Subscription {\n"); + + sb.append(" subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n"); + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" apiIdentifier: ").append(toIndentedString(apiIdentifier)).append("\n"); + sb.append(" tier: ").append(toIndentedString(tier)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/SubscriptionList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/SubscriptionList.java new file mode 100644 index 00000000000..5c167402cdf --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/SubscriptionList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * SubscriptionList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class SubscriptionList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public SubscriptionList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Subscriptions returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Subscriptions returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public SubscriptionList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public SubscriptionList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public SubscriptionList list(List list) { + this.list = list; + return this; + } + + public SubscriptionList addListItem(Subscription listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscriptionList subscriptionList = (SubscriptionList) o; + return Objects.equals(this.count, subscriptionList.count) && + Objects.equals(this.next, subscriptionList.next) && + Objects.equals(this.previous, subscriptionList.previous) && + Objects.equals(this.list, subscriptionList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubscriptionList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Tier.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Tier.java new file mode 100644 index 00000000000..7f0aa83910f --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/Tier.java @@ -0,0 +1,353 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + + +/** + * Tier + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class Tier { + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + /** + * Gets or Sets tierLevel + */ + public enum TierLevelEnum { + API("api"), + + APPLICATION("application"), + + RESOURCE("resource"); + + private String value; + + TierLevelEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TierLevelEnum fromValue(String text) { + for (TierLevelEnum b : TierLevelEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("tierLevel") + private TierLevelEnum tierLevel = null; + + @JsonProperty("attributes") + private Map attributes = new HashMap(); + + @JsonProperty("requestCount") + private Long requestCount = null; + + @JsonProperty("unitTime") + private Long unitTime = null; + + @JsonProperty("timeUnit") + private String timeUnit = null; + + /** + * This attribute declares whether this tier is available under commercial or free + */ + public enum TierPlanEnum { + FREE("FREE"), + + COMMERCIAL("COMMERCIAL"); + + private String value; + + TierPlanEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TierPlanEnum fromValue(String text) { + for (TierPlanEnum b : TierPlanEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("tierPlan") + private TierPlanEnum tierPlan = null; + + @JsonProperty("stopOnQuotaReach") + private Boolean stopOnQuotaReach = null; + + public Tier name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "Platinum", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tier description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "Allows 50 request(s) per minute.", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Tier tierLevel(TierLevelEnum tierLevel) { + this.tierLevel = tierLevel; + return this; + } + + /** + * Get tierLevel + * @return tierLevel + **/ + @ApiModelProperty(example = "api", value = "") + public TierLevelEnum getTierLevel() { + return tierLevel; + } + + public void setTierLevel(TierLevelEnum tierLevel) { + this.tierLevel = tierLevel; + } + + public Tier attributes(Map attributes) { + this.attributes = attributes; + return this; + } + + public Tier putAttributesItem(String key, String attributesItem) { + this.attributes.put(key, attributesItem); + return this; + } + + /** + * Custom attributes added to the tier policy + * @return attributes + **/ + @ApiModelProperty(example = "null", value = "Custom attributes added to the tier policy ") + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public Tier requestCount(Long requestCount) { + this.requestCount = requestCount; + return this; + } + + /** + * Maximum number of requests which can be sent within a provided unit time + * @return requestCount + **/ + @ApiModelProperty(example = "50", required = true, value = "Maximum number of requests which can be sent within a provided unit time ") + public Long getRequestCount() { + return requestCount; + } + + public void setRequestCount(Long requestCount) { + this.requestCount = requestCount; + } + + public Tier unitTime(Long unitTime) { + this.unitTime = unitTime; + return this; + } + + /** + * Get unitTime + * @return unitTime + **/ + @ApiModelProperty(example = "60000", required = true, value = "") + public Long getUnitTime() { + return unitTime; + } + + public void setUnitTime(Long unitTime) { + this.unitTime = unitTime; + } + + public Tier timeUnit(String timeUnit) { + this.timeUnit = timeUnit; + return this; + } + + /** + * Get timeUnit + * @return timeUnit + **/ + @ApiModelProperty(example = "min", value = "") + public String getTimeUnit() { + return timeUnit; + } + + public void setTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + } + + public Tier tierPlan(TierPlanEnum tierPlan) { + this.tierPlan = tierPlan; + return this; + } + + /** + * This attribute declares whether this tier is available under commercial or free + * @return tierPlan + **/ + @ApiModelProperty(example = "FREE", required = true, value = "This attribute declares whether this tier is available under commercial or free ") + public TierPlanEnum getTierPlan() { + return tierPlan; + } + + public void setTierPlan(TierPlanEnum tierPlan) { + this.tierPlan = tierPlan; + } + + public Tier stopOnQuotaReach(Boolean stopOnQuotaReach) { + this.stopOnQuotaReach = stopOnQuotaReach; + return this; + } + + /** + * By making this attribute to false, you are capabale of sending requests even if the request count exceeded within a unit time + * @return stopOnQuotaReach + **/ + @ApiModelProperty(example = "true", required = true, value = "By making this attribute to false, you are capabale of sending requests even if the request count exceeded within a unit time ") + public Boolean getStopOnQuotaReach() { + return stopOnQuotaReach; + } + + public void setStopOnQuotaReach(Boolean stopOnQuotaReach) { + this.stopOnQuotaReach = stopOnQuotaReach; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tier tier = (Tier) o; + return Objects.equals(this.name, tier.name) && + Objects.equals(this.description, tier.description) && + Objects.equals(this.tierLevel, tier.tierLevel) && + Objects.equals(this.attributes, tier.attributes) && + Objects.equals(this.requestCount, tier.requestCount) && + Objects.equals(this.unitTime, tier.unitTime) && + Objects.equals(this.timeUnit, tier.timeUnit) && + Objects.equals(this.tierPlan, tier.tierPlan) && + Objects.equals(this.stopOnQuotaReach, tier.stopOnQuotaReach); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, tierLevel, attributes, requestCount, unitTime, timeUnit, tierPlan, stopOnQuotaReach); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tier {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" tierLevel: ").append(toIndentedString(tierLevel)).append("\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); + sb.append(" unitTime: ").append(toIndentedString(unitTime)).append("\n"); + sb.append(" timeUnit: ").append(toIndentedString(timeUnit)).append("\n"); + sb.append(" tierPlan: ").append(toIndentedString(tierPlan)).append("\n"); + sb.append(" stopOnQuotaReach: ").append(toIndentedString(stopOnQuotaReach)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierList.java new file mode 100644 index 00000000000..a93c73e401a --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * TierList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class TierList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public TierList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Tiers returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Tiers returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public TierList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/tiers/api?limit=1&offset=2", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public TierList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/tiers/api?limit=1&offset=0", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public TierList list(List list) { + this.list = list; + return this; + } + + public TierList addListItem(Tier listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TierList tierList = (TierList) o; + return Objects.equals(this.count, tierList.count) && + Objects.equals(this.next, tierList.next) && + Objects.equals(this.previous, tierList.previous) && + Objects.equals(this.list, tierList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TierList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierPermission.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierPermission.java new file mode 100644 index 00000000000..8069b9d1c99 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/model/TierPermission.java @@ -0,0 +1,160 @@ +/** + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.publisher.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * TierPermission + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:49.624+05:30") +public class TierPermission { + /** + * Gets or Sets permissionType + */ + public enum PermissionTypeEnum { + ALLOW("allow"), + + DENY("deny"); + + private String value; + + PermissionTypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static PermissionTypeEnum fromValue(String text) { + for (PermissionTypeEnum b : PermissionTypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("permissionType") + private PermissionTypeEnum permissionType = null; + + @JsonProperty("roles") + private List roles = new ArrayList(); + + public TierPermission permissionType(PermissionTypeEnum permissionType) { + this.permissionType = permissionType; + return this; + } + + /** + * Get permissionType + * @return permissionType + **/ + @ApiModelProperty(example = "deny", required = true, value = "") + public PermissionTypeEnum getPermissionType() { + return permissionType; + } + + public void setPermissionType(PermissionTypeEnum permissionType) { + this.permissionType = permissionType; + } + + public TierPermission roles(List roles) { + this.roles = roles; + return this; + } + + public TierPermission addRolesItem(String rolesItem) { + this.roles.add(rolesItem); + return this; + } + + /** + * Get roles + * @return roles + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TierPermission tierPermission = (TierPermission) o; + return Objects.equals(this.permissionType, tierPermission.permissionType) && + Objects.equals(this.roles, tierPermission.roles); + } + + @Override + public int hashCode() { + return Objects.hash(permissionType, roles); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TierPermission {\n"); + + sb.append(" permissionType: ").append(toIndentedString(permissionType)).append("\n"); + sb.append(" roles: ").append(toIndentedString(roles)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java index 922aec75c34..0ac7e4616f5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java @@ -18,8 +18,8 @@ package org.wso2.carbon.apimgt.integration.client.service; -import org.wso2.carbon.apimgt.integration.client.PublisherClient; -import org.wso2.carbon.apimgt.integration.client.StoreClient; +import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; +import org.wso2.carbon.apimgt.integration.client.store.StoreClient; /** * This is a service that can be called upon to access store and publisher. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java similarity index 69% rename from components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java rename to components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java index f7957ea147d..da22e8ef7bf 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/StoreClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java @@ -15,17 +15,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.apimgt.integration.client; +package org.wso2.carbon.apimgt.integration.client.store; import feign.Feign; import feign.RequestInterceptor; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; -import feign.jaxrs.JAXRSContract; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.store.client.api.*; -import org.wso2.carbon.apimgt.store.client.invoker.ApiClient; +import org.wso2.carbon.apimgt.integration.client.store.api.*; +import org.wso2.carbon.core.util.Utils; /** * API Store client, created using swagger gen. @@ -47,21 +46,18 @@ public class StoreClient { public StoreClient(RequestInterceptor requestInterceptor) { Feign.Builder builder = Feign.builder().requestInterceptor(requestInterceptor) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()); - - ApiClient client = new ApiClient(); - client.setBasePath(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); - client.setFeignBuilder(builder); - - apis = client.buildClient(ApisAPIApi.class); - individualApi = client.buildClient(APIindividualApi.class); - applications = client.buildClient(ApplicationCollectionApi.class); - individualApplication = client.buildClient(ApplicationindividualApi.class); - subscriptions = client.buildClient(SubscriptionCollectionApi.class); - individualSubscription = client.buildClient(SubscriptionindividualApi.class); - tags = client.buildClient(TagCollectionApi.class); - tiers = client.buildClient(TierCollectionApi.class); - individualTier = client.buildClient(TierindividualApi.class); + .encoder(new GsonEncoder()).decoder(new GsonDecoder()); + String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); + + apis = builder.target(ApisAPIApi.class, basePath); + individualApi = builder.target(APIindividualApi.class, basePath); + applications = builder.target(ApplicationCollectionApi.class, basePath); + individualApplication = builder.target(ApplicationindividualApi.class, basePath); + subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); + individualSubscription = builder.target(SubscriptionindividualApi.class, basePath); + tags = builder.target(TagCollectionApi.class, basePath); + tiers = builder.target(TierCollectionApi.class, basePath); + individualTier = builder.target(TierindividualApi.class, basePath); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java new file mode 100644 index 00000000000..ff7789724a1 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java @@ -0,0 +1,170 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.API; +import org.wso2.carbon.apimgt.integration.client.store.model.Document; +import org.wso2.carbon.apimgt.integration.client.store.model.DocumentList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface APIindividualApi { + + + /** + * Downloads a FILE type document/get the inline content or source url of a certain document. + * Downloads a FILE type document/get the inline content or source url of a certain document. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/documents/{documentId}/content") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + void apisApiIdDocumentsDocumentIdContentGet(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("xWSO2Tenant") String xWSO2Tenant, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Get a particular document associated with an API. + * Get a particular document associated with an API. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param documentId **Document Identifier** (required) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Document + */ + @RequestLine("GET /apis/{apiId}/documents/{documentId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Document apisApiIdDocumentsDocumentIdGet(@Param("apiId") String apiId, @Param("documentId") String documentId, + @Param("xWSO2Tenant") String xWSO2Tenant, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Get a list of documents belonging to an API. + * Get a list of documents belonging to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return DocumentList + */ + @RequestLine("GET /apis/{apiId}/documents?limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + DocumentList apisApiIdDocumentsGet(@Param("apiId") String apiId, @Param("limit") Integer limit, + @Param("offset") Integer offset, @Param("xWSO2Tenant") String xWSO2Tenant, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch); + + /** + * Get Details of API + * Get details of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @return API + */ + @RequestLine("GET /apis/{apiId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}", + + "X-WSO2-Tenant: {xWSO2Tenant}" + }) + API apisApiIdGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince, + @Param("xWSO2Tenant") String xWSO2Tenant); + + /** + * Get the swagger of an API + * Get the swagger of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/swagger") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}", + + "X-WSO2-Tenant: {xWSO2Tenant}" + }) + void apisApiIdSwaggerGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince, + @Param("xWSO2Tenant") String xWSO2Tenant); + + /** + * Get the thumbnail image + * Downloads a thumbnail image of an API + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. Should be formatted as **provider-name-version**. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly + * retrieved variant of the resource. (optional) + * @return void + */ + @RequestLine("GET /apis/{apiId}/thumbnail") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + void apisApiIdThumbnailGet(@Param("apiId") String apiId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, @Param("ifModifiedSince") String ifModifiedSince); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java new file mode 100644 index 00000000000..5558af1ef71 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java @@ -0,0 +1,37 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.APIList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface ApisAPIApi { + + + /** + * Retrieving APIs + * Get a list of available APIs qualifying under a given search condition. + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param query **Search condition**. You can search in attributes by using an **\"attribute:\"** modifier. Eg. \"provider:wso2\" will match an API if the provider of the API is exactly \"wso2\". Additionally you can use wildcards. Eg. \"provider:wso2\\*\" will match an API if the provider of the API starts with \"wso2\". Supported attribute modifiers are [**version, context, status, description, subcontext, doc, provider, tag**] If no advanced attribute modifier has been specified, search will match the given query string against API Name. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return APIList + */ + @RequestLine("GET /apis?limit={limit}&offset={offset}&query={query}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + APIList apisGet(@Param("limit") Integer limit, @Param("offset") Integer offset, + @Param("xWSO2Tenant") String xWSO2Tenant, @Param("query") String query, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java new file mode 100644 index 00000000000..05e3fa68586 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java @@ -0,0 +1,35 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.ApplicationList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface ApplicationCollectionApi { + + + /** + * Get a list of applications + * Get a list of applications + * @param groupId Application Group Id (optional) + * @param query **Search condition**. You can search for an application by specifying the name as \"query\" attribute. Eg. \"app1\" will match an application if the name is exactly \"app1\". Currently this does not support wildcards. Given name must exactly match the application name. (optional) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return ApplicationList + */ + @RequestLine("GET /applications?groupId={groupId}&query={query}&limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + ApplicationList applicationsGet(@Param("groupId") String groupId, @Param("query") String query, + @Param("limit") Integer limit, @Param("offset") Integer offset, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java new file mode 100644 index 00000000000..b6f3b9e0b0f --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java @@ -0,0 +1,121 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.Application; +import org.wso2.carbon.apimgt.integration.client.store.model.ApplicationKey; +import org.wso2.carbon.apimgt.integration.client.store.model.ApplicationKeyGenerateRequest; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface ApplicationindividualApi { + + + /** + * Remove an application + * Remove an application + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("DELETE /applications/{applicationId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void applicationsApplicationIdDelete(@Param("applicationId") String applicationId, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get application details + * Get application details + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Application + */ + @RequestLine("GET /applications/{applicationId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Application applicationsApplicationIdGet(@Param("applicationId") String applicationId, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); + + /** + * Update application details + * Update application details + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param body Application object that needs to be updated (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return Application + */ + @RequestLine("PUT /applications/{applicationId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + Application applicationsApplicationIdPut(@Param("applicationId") String applicationId, Application body, + @Param("contentType") String contentType, @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Generate keys for application + * Generate keys for application + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param body Application object the keys of which are to be generated (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return ApplicationKey + */ + @RequestLine("POST /applications/generate-keys?applicationId={applicationId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}", + + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + ApplicationKey applicationsGenerateKeysPost(@Param("applicationId") String applicationId, + ApplicationKeyGenerateRequest body, + @Param("contentType") String contentType, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Create a new application. + * Create a new application. + * @param body Application object that is to be created. (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @return Application + */ + @RequestLine("POST /applications") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}" + }) + Application applicationsPost(Application body, @Param("contentType") String contentType); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java new file mode 100644 index 00000000000..c1ca6701e8e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java @@ -0,0 +1,37 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.SubscriptionList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface SubscriptionCollectionApi { + + + /** + * Get subscription list. + * Get subscription list. The API Identifier or Application Identifier the subscriptions of which are to be returned are passed as parameters. + * @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. Should be formatted as **provider-name-version**. (required) + * @param applicationId **Application Identifier** consisting of the UUID of the Application. (required) + * @param groupId Application Group Id (optional) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return SubscriptionList + */ + @RequestLine("GET /subscriptions?apiId={apiId}&applicationId={applicationId}&groupId={groupId}&offset={offset}&limit={limit}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + SubscriptionList subscriptionsGet(@Param("apiId") String apiId, @Param("applicationId") String applicationId, + @Param("groupId") String groupId, @Param("offset") Integer offset, + @Param("limit") Integer limit, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java new file mode 100644 index 00000000000..e5b23bab708 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java @@ -0,0 +1,70 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.Subscription; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface SubscriptionindividualApi { + + + /** + * Add a new subscription + * Add a new subscription + * @param body Subscription object that should to be added (required) + * @param contentType Media type of the entity in the body. Default is JSON. (required) + * @return Subscription + */ + @RequestLine("POST /subscriptions") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Content-Type: {contentType}" + }) + Subscription subscriptionsPost(Subscription body, @Param("contentType") String contentType); + + /** + * Remove subscription + * Remove subscription + * @param subscriptionId Subscription Id (required) + * @param ifMatch Validator for conditional requests; based on ETag. (optional) + * @param ifUnmodifiedSince Validator for conditional requests; based on Last Modified header. (optional) + * @return void + */ + @RequestLine("DELETE /subscriptions/{subscriptionId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "If-Match: {ifMatch}", + + "If-Unmodified-Since: {ifUnmodifiedSince}" + }) + void subscriptionsSubscriptionIdDelete(@Param("subscriptionId") String subscriptionId, + @Param("ifMatch") String ifMatch, + @Param("ifUnmodifiedSince") String ifUnmodifiedSince); + + /** + * Get subscription details + * Get subscription details + * @param subscriptionId Subscription Id (required) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Subscription + */ + @RequestLine("GET /subscriptions/{subscriptionId}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Subscription subscriptionsSubscriptionIdGet(@Param("subscriptionId") String subscriptionId, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java new file mode 100644 index 00000000000..adedc6d4d1b --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java @@ -0,0 +1,36 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.TagList; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface TagCollectionApi { + + + /** + * Get a list of tags that are already added to APIs + * Get a list of tags that are already added to APIs + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return TagList + */ + @RequestLine("GET /tags?limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + TagList tagsGet(@Param("limit") Integer limit, @Param("offset") Integer offset, + @Param("xWSO2Tenant") String xWSO2Tenant, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java new file mode 100644 index 00000000000..5e41d015091 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java @@ -0,0 +1,39 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.TierList; + + +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface TierCollectionApi { + + + /** + * Get available tiers + * Get available tiers + * @param tierLevel List API or Application type tiers. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @return List + */ + @RequestLine("GET /tiers/{tierLevel}?limit={limit}&offset={offset}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}" + }) + List tiersTierLevelGet(@Param("tierLevel") String tierLevel, @Param("limit") Integer limit, + @Param("offset") Integer offset, @Param("xWSO2Tenant") String xWSO2Tenant, + @Param("accept") String accept, @Param("ifNoneMatch") String ifNoneMatch); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java new file mode 100644 index 00000000000..e5ae77afb76 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java @@ -0,0 +1,40 @@ +package org.wso2.carbon.apimgt.integration.client.store.api; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import org.wso2.carbon.apimgt.integration.client.store.model.Tier; + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public interface TierindividualApi { + + + /** + * Get tier details + * Get tier details + * @param tierName Tier name (required) + * @param tierLevel List API or Application type tiers. (required) + * @param xWSO2Tenant For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. (optional) + * @param accept Media types acceptable for the response. Default is JSON. (optional, default to JSON) + * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. (optional) + * @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. (optional) + * @return Tier + */ + @RequestLine("GET /tiers/{tierLevel}/{tierName}") + @Headers({ + "Content-type: application/json", + "Accept: application/json", + "X-WSO2-Tenant: {xWSO2Tenant}", + + "Accept: {accept}", + + "If-None-Match: {ifNoneMatch}", + + "If-Modified-Since: {ifModifiedSince}" + }) + Tier tiersTierLevelTierNameGet(@Param("tierName") String tierName, @Param("tierLevel") String tierLevel, + @Param("xWSO2Tenant") String xWSO2Tenant, @Param("accept") String accept, + @Param("ifNoneMatch") String ifNoneMatch, + @Param("ifModifiedSince") String ifModifiedSince); +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/API.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/API.java new file mode 100644 index 00000000000..90ea61fe6f8 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/API.java @@ -0,0 +1,466 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * API + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class API { + @JsonProperty("id") + private String id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("context") + private String context = null; + + @JsonProperty("version") + private String version = null; + + @JsonProperty("provider") + private String provider = null; + + @JsonProperty("apiDefinition") + private String apiDefinition = null; + + @JsonProperty("wsdlUri") + private String wsdlUri = null; + + @JsonProperty("status") + private String status = null; + + @JsonProperty("isDefaultVersion") + private Boolean isDefaultVersion = null; + + @JsonProperty("transport") + private List transport = new ArrayList(); + + @JsonProperty("tags") + private List tags = new ArrayList(); + + @JsonProperty("tiers") + private List tiers = new ArrayList(); + + @JsonProperty("thumbnailUrl") + private String thumbnailUrl = null; + + @JsonProperty("endpointURLs") + private List endpointURLs = new ArrayList(); + + @JsonProperty("businessInformation") + private APIBusinessInformation businessInformation = null; + + public API id(String id) { + this.id = id; + return this; + } + + /** + * UUID of the api registry artifact + * @return id + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "UUID of the api registry artifact ") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public API name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorAPI", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public API description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "A calculator API that supports basic operations", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public API context(String context) { + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @ApiModelProperty(example = "CalculatorAPI", required = true, value = "") + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public API version(String version) { + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @ApiModelProperty(example = "1.0.0", required = true, value = "") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public API provider(String provider) { + this.provider = provider; + return this; + } + + /** + * If the provider value is not given user invoking the api will be used as the provider. + * @return provider + **/ + @ApiModelProperty(example = "admin", required = true, value = "If the provider value is not given user invoking the api will be used as the provider. ") + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public API apiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + return this; + } + + /** + * Swagger definition of the API which contains details about URI templates and scopes + * @return apiDefinition + **/ + @ApiModelProperty(example = "", required = true, value = "Swagger definition of the API which contains details about URI templates and scopes ") + public String getApiDefinition() { + return apiDefinition; + } + + public void setApiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + } + + public API wsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + return this; + } + + /** + * WSDL URL if the API is based on a WSDL endpoint + * @return wsdlUri + **/ + @ApiModelProperty(example = "http://www.webservicex.com/globalweather.asmx?wsdl", value = "WSDL URL if the API is based on a WSDL endpoint ") + public String getWsdlUri() { + return wsdlUri; + } + + public void setWsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + } + + public API status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "PUBLISHED", required = true, value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public API isDefaultVersion(Boolean isDefaultVersion) { + this.isDefaultVersion = isDefaultVersion; + return this; + } + + /** + * Get isDefaultVersion + * @return isDefaultVersion + **/ + @ApiModelProperty(example = "false", value = "") + public Boolean getIsDefaultVersion() { + return isDefaultVersion; + } + + public void setIsDefaultVersion(Boolean isDefaultVersion) { + this.isDefaultVersion = isDefaultVersion; + } + + public API transport(List transport) { + this.transport = transport; + return this; + } + + public API addTransportItem(String transportItem) { + this.transport.add(transportItem); + return this; + } + + /** + * Get transport + * @return transport + **/ + @ApiModelProperty(example = "null", value = "") + public List getTransport() { + return transport; + } + + public void setTransport(List transport) { + this.transport = transport; + } + + public API tags(List tags) { + this.tags = tags; + return this; + } + + public API addTagsItem(String tagsItem) { + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @ApiModelProperty(example = "null", value = "") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public API tiers(List tiers) { + this.tiers = tiers; + return this; + } + + public API addTiersItem(String tiersItem) { + this.tiers.add(tiersItem); + return this; + } + + /** + * Get tiers + * @return tiers + **/ + @ApiModelProperty(example = "null", value = "") + public List getTiers() { + return tiers; + } + + public void setTiers(List tiers) { + this.tiers = tiers; + } + + public API thumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + return this; + } + + /** + * Get thumbnailUrl + * @return thumbnailUrl + **/ + @ApiModelProperty(example = "", value = "") + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public API endpointURLs(List endpointURLs) { + this.endpointURLs = endpointURLs; + return this; + } + + public API addEndpointURLsItem(APIEndpointURLs endpointURLsItem) { + this.endpointURLs.add(endpointURLsItem); + return this; + } + + /** + * Get endpointURLs + * @return endpointURLs + **/ + @ApiModelProperty(example = "null", value = "") + public List getEndpointURLs() { + return endpointURLs; + } + + public void setEndpointURLs(List endpointURLs) { + this.endpointURLs = endpointURLs; + } + + public API businessInformation(APIBusinessInformation businessInformation) { + this.businessInformation = businessInformation; + return this; + } + + /** + * Get businessInformation + * @return businessInformation + **/ + @ApiModelProperty(example = "null", value = "") + public APIBusinessInformation getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(APIBusinessInformation businessInformation) { + this.businessInformation = businessInformation; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + API API = (org.wso2.carbon.apimgt.integration.client.store.model.API) o; + return Objects.equals(this.id, API.id) && + Objects.equals(this.name, API.name) && + Objects.equals(this.description, API.description) && + Objects.equals(this.context, API.context) && + Objects.equals(this.version, API.version) && + Objects.equals(this.provider, API.provider) && + Objects.equals(this.apiDefinition, API.apiDefinition) && + Objects.equals(this.wsdlUri, API.wsdlUri) && + Objects.equals(this.status, API.status) && + Objects.equals(this.isDefaultVersion, API.isDefaultVersion) && + Objects.equals(this.transport, API.transport) && + Objects.equals(this.tags, API.tags) && + Objects.equals(this.tiers, API.tiers) && + Objects.equals(this.thumbnailUrl, API.thumbnailUrl) && + Objects.equals(this.endpointURLs, API.endpointURLs) && + Objects.equals(this.businessInformation, API.businessInformation); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, context, version, provider, apiDefinition, wsdlUri, status, isDefaultVersion, transport, tags, tiers, thumbnailUrl, endpointURLs, businessInformation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class API {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" apiDefinition: ").append(toIndentedString(apiDefinition)).append("\n"); + sb.append(" wsdlUri: ").append(toIndentedString(wsdlUri)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" isDefaultVersion: ").append(toIndentedString(isDefaultVersion)).append("\n"); + sb.append(" transport: ").append(toIndentedString(transport)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" tiers: ").append(toIndentedString(tiers)).append("\n"); + sb.append(" thumbnailUrl: ").append(toIndentedString(thumbnailUrl)).append("\n"); + sb.append(" endpointURLs: ").append(toIndentedString(endpointURLs)).append("\n"); + sb.append(" businessInformation: ").append(toIndentedString(businessInformation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIBusinessInformation.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIBusinessInformation.java new file mode 100644 index 00000000000..dea7cc81fec --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIBusinessInformation.java @@ -0,0 +1,168 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIBusinessInformation + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class APIBusinessInformation { + @JsonProperty("businessOwner") + private String businessOwner = null; + + @JsonProperty("businessOwnerEmail") + private String businessOwnerEmail = null; + + @JsonProperty("technicalOwner") + private String technicalOwner = null; + + @JsonProperty("technicalOwnerEmail") + private String technicalOwnerEmail = null; + + public APIBusinessInformation businessOwner(String businessOwner) { + this.businessOwner = businessOwner; + return this; + } + + /** + * Get businessOwner + * @return businessOwner + **/ + @ApiModelProperty(example = "businessowner", value = "") + public String getBusinessOwner() { + return businessOwner; + } + + public void setBusinessOwner(String businessOwner) { + this.businessOwner = businessOwner; + } + + public APIBusinessInformation businessOwnerEmail(String businessOwnerEmail) { + this.businessOwnerEmail = businessOwnerEmail; + return this; + } + + /** + * Get businessOwnerEmail + * @return businessOwnerEmail + **/ + @ApiModelProperty(example = "businessowner@wso2.com", value = "") + public String getBusinessOwnerEmail() { + return businessOwnerEmail; + } + + public void setBusinessOwnerEmail(String businessOwnerEmail) { + this.businessOwnerEmail = businessOwnerEmail; + } + + public APIBusinessInformation technicalOwner(String technicalOwner) { + this.technicalOwner = technicalOwner; + return this; + } + + /** + * Get technicalOwner + * @return technicalOwner + **/ + @ApiModelProperty(example = "technicalowner", value = "") + public String getTechnicalOwner() { + return technicalOwner; + } + + public void setTechnicalOwner(String technicalOwner) { + this.technicalOwner = technicalOwner; + } + + public APIBusinessInformation technicalOwnerEmail(String technicalOwnerEmail) { + this.technicalOwnerEmail = technicalOwnerEmail; + return this; + } + + /** + * Get technicalOwnerEmail + * @return technicalOwnerEmail + **/ + @ApiModelProperty(example = "technicalowner@wso2.com", value = "") + public String getTechnicalOwnerEmail() { + return technicalOwnerEmail; + } + + public void setTechnicalOwnerEmail(String technicalOwnerEmail) { + this.technicalOwnerEmail = technicalOwnerEmail; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIBusinessInformation aPIBusinessInformation = (APIBusinessInformation) o; + return Objects.equals(this.businessOwner, aPIBusinessInformation.businessOwner) && + Objects.equals(this.businessOwnerEmail, aPIBusinessInformation.businessOwnerEmail) && + Objects.equals(this.technicalOwner, aPIBusinessInformation.technicalOwner) && + Objects.equals(this.technicalOwnerEmail, aPIBusinessInformation.technicalOwnerEmail); + } + + @Override + public int hashCode() { + return Objects.hash(businessOwner, businessOwnerEmail, technicalOwner, technicalOwnerEmail); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIBusinessInformation {\n"); + + sb.append(" businessOwner: ").append(toIndentedString(businessOwner)).append("\n"); + sb.append(" businessOwnerEmail: ").append(toIndentedString(businessOwnerEmail)).append("\n"); + sb.append(" technicalOwner: ").append(toIndentedString(technicalOwner)).append("\n"); + sb.append(" technicalOwnerEmail: ").append(toIndentedString(technicalOwnerEmail)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEndpointURLs.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEndpointURLs.java new file mode 100644 index 00000000000..28d2f870984 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEndpointURLs.java @@ -0,0 +1,145 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIEndpointURLs + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class APIEndpointURLs { + @JsonProperty("environmentName") + private String environmentName = null; + + @JsonProperty("environmentType") + private String environmentType = null; + + @JsonProperty("environmentURLs") + private APIEnvironmentURLs environmentURLs = null; + + public APIEndpointURLs environmentName(String environmentName) { + this.environmentName = environmentName; + return this; + } + + /** + * Get environmentName + * @return environmentName + **/ + @ApiModelProperty(example = "Production and Sandbox", value = "") + public String getEnvironmentName() { + return environmentName; + } + + public void setEnvironmentName(String environmentName) { + this.environmentName = environmentName; + } + + public APIEndpointURLs environmentType(String environmentType) { + this.environmentType = environmentType; + return this; + } + + /** + * Get environmentType + * @return environmentType + **/ + @ApiModelProperty(example = "hybrid", value = "") + public String getEnvironmentType() { + return environmentType; + } + + public void setEnvironmentType(String environmentType) { + this.environmentType = environmentType; + } + + public APIEndpointURLs environmentURLs(APIEnvironmentURLs environmentURLs) { + this.environmentURLs = environmentURLs; + return this; + } + + /** + * Get environmentURLs + * @return environmentURLs + **/ + @ApiModelProperty(example = "null", value = "") + public APIEnvironmentURLs getEnvironmentURLs() { + return environmentURLs; + } + + public void setEnvironmentURLs(APIEnvironmentURLs environmentURLs) { + this.environmentURLs = environmentURLs; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIEndpointURLs aPIEndpointURLs = (APIEndpointURLs) o; + return Objects.equals(this.environmentName, aPIEndpointURLs.environmentName) && + Objects.equals(this.environmentType, aPIEndpointURLs.environmentType) && + Objects.equals(this.environmentURLs, aPIEndpointURLs.environmentURLs); + } + + @Override + public int hashCode() { + return Objects.hash(environmentName, environmentType, environmentURLs); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIEndpointURLs {\n"); + + sb.append(" environmentName: ").append(toIndentedString(environmentName)).append("\n"); + sb.append(" environmentType: ").append(toIndentedString(environmentType)).append("\n"); + sb.append(" environmentURLs: ").append(toIndentedString(environmentURLs)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEnvironmentURLs.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEnvironmentURLs.java new file mode 100644 index 00000000000..339c4a16ebf --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIEnvironmentURLs.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIEnvironmentURLs + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class APIEnvironmentURLs { + @JsonProperty("http") + private String http = null; + + @JsonProperty("https") + private String https = null; + + public APIEnvironmentURLs http(String http) { + this.http = http; + return this; + } + + /** + * HTTP environment URL + * @return http + **/ + @ApiModelProperty(example = "http://192.168.56.1:8280/phoneverify/1.0.0", value = "HTTP environment URL") + public String getHttp() { + return http; + } + + public void setHttp(String http) { + this.http = http; + } + + public APIEnvironmentURLs https(String https) { + this.https = https; + return this; + } + + /** + * HTTPS environment URL + * @return https + **/ + @ApiModelProperty(example = "https://192.168.56.1:8243/phoneverify/1.0.0", value = "HTTPS environment URL") + public String getHttps() { + return https; + } + + public void setHttps(String https) { + this.https = https; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIEnvironmentURLs aPIEnvironmentURLs = (APIEnvironmentURLs) o; + return Objects.equals(this.http, aPIEnvironmentURLs.http) && + Objects.equals(this.https, aPIEnvironmentURLs.https); + } + + @Override + public int hashCode() { + return Objects.hash(http, https); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIEnvironmentURLs {\n"); + + sb.append(" http: ").append(toIndentedString(http)).append("\n"); + sb.append(" https: ").append(toIndentedString(https)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIInfo.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIInfo.java new file mode 100644 index 00000000000..b6ac4f45485 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIInfo.java @@ -0,0 +1,237 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * APIInfo + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class APIInfo { + @JsonProperty("id") + private String id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("context") + private String context = null; + + @JsonProperty("version") + private String version = null; + + @JsonProperty("provider") + private String provider = null; + + @JsonProperty("status") + private String status = null; + + public APIInfo id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public APIInfo name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorAPI", value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public APIInfo description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "A calculator API that supports basic operations", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public APIInfo context(String context) { + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @ApiModelProperty(example = "CalculatorAPI", value = "") + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public APIInfo version(String version) { + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @ApiModelProperty(example = "1.0.0", value = "") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public APIInfo provider(String provider) { + this.provider = provider; + return this; + } + + /** + * If the provider value is not given, the user invoking the API will be used as the provider. + * @return provider + **/ + @ApiModelProperty(example = "admin", value = "If the provider value is not given, the user invoking the API will be used as the provider. ") + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public APIInfo status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "PUBLISHED", value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIInfo aPIInfo = (APIInfo) o; + return Objects.equals(this.id, aPIInfo.id) && + Objects.equals(this.name, aPIInfo.name) && + Objects.equals(this.description, aPIInfo.description) && + Objects.equals(this.context, aPIInfo.context) && + Objects.equals(this.version, aPIInfo.version) && + Objects.equals(this.provider, aPIInfo.provider) && + Objects.equals(this.status, aPIInfo.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, context, version, provider, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIInfo {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIList.java new file mode 100644 index 00000000000..1801088d6cd --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/APIList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * APIList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class APIList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public APIList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of APIs returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of APIs returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public APIList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/apis?limit=1&offset=2&query=", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public APIList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/apis?limit=1&offset=0&query=", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public APIList list(List list) { + this.list = list; + return this; + } + + public APIList addListItem(APIInfo listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIList aPIList = (APIList) o; + return Objects.equals(this.count, aPIList.count) && + Objects.equals(this.next, aPIList.next) && + Objects.equals(this.previous, aPIList.previous) && + Objects.equals(this.list, aPIList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class APIList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Application.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Application.java new file mode 100644 index 00000000000..6dd92ccddfb --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Application.java @@ -0,0 +1,290 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * Application + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Application { + @JsonProperty("applicationId") + private String applicationId = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("subscriber") + private String subscriber = null; + + @JsonProperty("throttlingTier") + private String throttlingTier = null; + + @JsonProperty("callbackUrl") + private String callbackUrl = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("status") + private String status = ""; + + @JsonProperty("groupId") + private String groupId = null; + + @JsonProperty("keys") + private List keys = new ArrayList(); + + public Application applicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get applicationId + * @return applicationId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public Application name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorApp", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Application subscriber(String subscriber) { + this.subscriber = subscriber; + return this; + } + + /** + * If subscriber is not given user invoking the API will be taken as the subscriber. + * @return subscriber + **/ + @ApiModelProperty(example = "admin", value = "If subscriber is not given user invoking the API will be taken as the subscriber. ") + public String getSubscriber() { + return subscriber; + } + + public void setSubscriber(String subscriber) { + this.subscriber = subscriber; + } + + public Application throttlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + return this; + } + + /** + * Get throttlingTier + * @return throttlingTier + **/ + @ApiModelProperty(example = "Unlimited", required = true, value = "") + public String getThrottlingTier() { + return throttlingTier; + } + + public void setThrottlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + } + + public Application callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Get callbackUrl + * @return callbackUrl + **/ + @ApiModelProperty(example = "", value = "") + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public Application description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "Sample calculator application", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Application status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "APPROVED", value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Application groupId(String groupId) { + this.groupId = groupId; + return this; + } + + /** + * Get groupId + * @return groupId + **/ + @ApiModelProperty(example = "", value = "") + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public Application keys(List keys) { + this.keys = keys; + return this; + } + + public Application addKeysItem(ApplicationKey keysItem) { + this.keys.add(keysItem); + return this; + } + + /** + * Get keys + * @return keys + **/ + @ApiModelProperty(example = "null", value = "") + public List getKeys() { + return keys; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Application application = (Application) o; + return Objects.equals(this.applicationId, application.applicationId) && + Objects.equals(this.name, application.name) && + Objects.equals(this.subscriber, application.subscriber) && + Objects.equals(this.throttlingTier, application.throttlingTier) && + Objects.equals(this.callbackUrl, application.callbackUrl) && + Objects.equals(this.description, application.description) && + Objects.equals(this.status, application.status) && + Objects.equals(this.groupId, application.groupId) && + Objects.equals(this.keys, application.keys); + } + + @Override + public int hashCode() { + return Objects.hash(applicationId, name, subscriber, throttlingTier, callbackUrl, description, status, groupId, keys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Application {\n"); + + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" subscriber: ").append(toIndentedString(subscriber)).append("\n"); + sb.append(" throttlingTier: ").append(toIndentedString(throttlingTier)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append(" keys: ").append(toIndentedString(keys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationInfo.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationInfo.java new file mode 100644 index 00000000000..f1307b93384 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationInfo.java @@ -0,0 +1,237 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * ApplicationInfo + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class ApplicationInfo { + @JsonProperty("applicationId") + private String applicationId = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("subscriber") + private String subscriber = null; + + @JsonProperty("throttlingTier") + private String throttlingTier = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("status") + private String status = null; + + @JsonProperty("groupId") + private String groupId = null; + + public ApplicationInfo applicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get applicationId + * @return applicationId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public ApplicationInfo name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorApp", value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ApplicationInfo subscriber(String subscriber) { + this.subscriber = subscriber; + return this; + } + + /** + * Get subscriber + * @return subscriber + **/ + @ApiModelProperty(example = "admin", value = "") + public String getSubscriber() { + return subscriber; + } + + public void setSubscriber(String subscriber) { + this.subscriber = subscriber; + } + + public ApplicationInfo throttlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + return this; + } + + /** + * Get throttlingTier + * @return throttlingTier + **/ + @ApiModelProperty(example = "Unlimited", value = "") + public String getThrottlingTier() { + return throttlingTier; + } + + public void setThrottlingTier(String throttlingTier) { + this.throttlingTier = throttlingTier; + } + + public ApplicationInfo description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "Sample calculator application", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ApplicationInfo status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "APPROVED", value = "") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public ApplicationInfo groupId(String groupId) { + this.groupId = groupId; + return this; + } + + /** + * Get groupId + * @return groupId + **/ + @ApiModelProperty(example = "", value = "") + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationInfo applicationInfo = (ApplicationInfo) o; + return Objects.equals(this.applicationId, applicationInfo.applicationId) && + Objects.equals(this.name, applicationInfo.name) && + Objects.equals(this.subscriber, applicationInfo.subscriber) && + Objects.equals(this.throttlingTier, applicationInfo.throttlingTier) && + Objects.equals(this.description, applicationInfo.description) && + Objects.equals(this.status, applicationInfo.status) && + Objects.equals(this.groupId, applicationInfo.groupId); + } + + @Override + public int hashCode() { + return Objects.hash(applicationId, name, subscriber, throttlingTier, description, status, groupId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApplicationInfo {\n"); + + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" subscriber: ").append(toIndentedString(subscriber)).append("\n"); + sb.append(" throttlingTier: ").append(toIndentedString(throttlingTier)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKey.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKey.java new file mode 100644 index 00000000000..a49d1522a6a --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKey.java @@ -0,0 +1,252 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * ApplicationKey + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class ApplicationKey { + @JsonProperty("consumerKey") + private String consumerKey = null; + + @JsonProperty("consumerSecret") + private String consumerSecret = null; + + @JsonProperty("supportedGrantTypes") + private List supportedGrantTypes = new ArrayList(); + + @JsonProperty("keyState") + private String keyState = null; + + /** + * Key type + */ + public enum KeyTypeEnum { + PRODUCTION("PRODUCTION"), + + SANDBOX("SANDBOX"); + + private String value; + + KeyTypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KeyTypeEnum fromValue(String text) { + for (KeyTypeEnum b : KeyTypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("keyType") + private KeyTypeEnum keyType = null; + + @JsonProperty("token") + private Token token = null; + + public ApplicationKey consumerKey(String consumerKey) { + this.consumerKey = consumerKey; + return this; + } + + /** + * Consumer key of the application + * @return consumerKey + **/ + @ApiModelProperty(example = "vYDoc9s7IgAFdkSyNDaswBX7ejoa", value = "Consumer key of the application") + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public ApplicationKey consumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + return this; + } + + /** + * Consumer secret of the application + * @return consumerSecret + **/ + @ApiModelProperty(example = "TIDlOFkpzB7WjufO3OJUhy1fsvAa", value = "Consumer secret of the application") + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public ApplicationKey supportedGrantTypes(List supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + return this; + } + + public ApplicationKey addSupportedGrantTypesItem(String supportedGrantTypesItem) { + this.supportedGrantTypes.add(supportedGrantTypesItem); + return this; + } + + /** + * Supported grant types for the application + * @return supportedGrantTypes + **/ + @ApiModelProperty(example = "null", value = "Supported grant types for the application") + public List getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(List supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } + + public ApplicationKey keyState(String keyState) { + this.keyState = keyState; + return this; + } + + /** + * State of the key generation of the application + * @return keyState + **/ + @ApiModelProperty(example = "APPROVED", value = "State of the key generation of the application") + public String getKeyState() { + return keyState; + } + + public void setKeyState(String keyState) { + this.keyState = keyState; + } + + public ApplicationKey keyType(KeyTypeEnum keyType) { + this.keyType = keyType; + return this; + } + + /** + * Key type + * @return keyType + **/ + @ApiModelProperty(example = "PRODUCTION", value = "Key type") + public KeyTypeEnum getKeyType() { + return keyType; + } + + public void setKeyType(KeyTypeEnum keyType) { + this.keyType = keyType; + } + + public ApplicationKey token(Token token) { + this.token = token; + return this; + } + + /** + * Get token + * @return token + **/ + @ApiModelProperty(example = "null", value = "") + public Token getToken() { + return token; + } + + public void setToken(Token token) { + this.token = token; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationKey applicationKey = (ApplicationKey) o; + return Objects.equals(this.consumerKey, applicationKey.consumerKey) && + Objects.equals(this.consumerSecret, applicationKey.consumerSecret) && + Objects.equals(this.supportedGrantTypes, applicationKey.supportedGrantTypes) && + Objects.equals(this.keyState, applicationKey.keyState) && + Objects.equals(this.keyType, applicationKey.keyType) && + Objects.equals(this.token, applicationKey.token); + } + + @Override + public int hashCode() { + return Objects.hash(consumerKey, consumerSecret, supportedGrantTypes, keyState, keyType, token); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApplicationKey {\n"); + + sb.append(" consumerKey: ").append(toIndentedString(consumerKey)).append("\n"); + sb.append(" consumerSecret: ").append(toIndentedString(consumerSecret)).append("\n"); + sb.append(" supportedGrantTypes: ").append(toIndentedString(supportedGrantTypes)).append("\n"); + sb.append(" keyState: ").append(toIndentedString(keyState)).append("\n"); + sb.append(" keyType: ").append(toIndentedString(keyType)).append("\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKeyGenerateRequest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKeyGenerateRequest.java new file mode 100644 index 00000000000..8b7cf21d9d4 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationKeyGenerateRequest.java @@ -0,0 +1,234 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * ApplicationKeyGenerateRequest + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class ApplicationKeyGenerateRequest { + /** + * Gets or Sets keyType + */ + public enum KeyTypeEnum { + PRODUCTION("PRODUCTION"), + + SANDBOX("SANDBOX"); + + private String value; + + KeyTypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KeyTypeEnum fromValue(String text) { + for (KeyTypeEnum b : KeyTypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("keyType") + private KeyTypeEnum keyType = null; + + @JsonProperty("validityTime") + private String validityTime = null; + + @JsonProperty("callbackUrl") + private String callbackUrl = null; + + @JsonProperty("accessAllowDomains") + private List accessAllowDomains = new ArrayList(); + + @JsonProperty("scopes") + private List scopes = new ArrayList(); + + public ApplicationKeyGenerateRequest keyType(KeyTypeEnum keyType) { + this.keyType = keyType; + return this; + } + + /** + * Get keyType + * @return keyType + **/ + @ApiModelProperty(example = "PRODUCTION", required = true, value = "") + public KeyTypeEnum getKeyType() { + return keyType; + } + + public void setKeyType(KeyTypeEnum keyType) { + this.keyType = keyType; + } + + public ApplicationKeyGenerateRequest validityTime(String validityTime) { + this.validityTime = validityTime; + return this; + } + + /** + * Get validityTime + * @return validityTime + **/ + @ApiModelProperty(example = "3600", required = true, value = "") + public String getValidityTime() { + return validityTime; + } + + public void setValidityTime(String validityTime) { + this.validityTime = validityTime; + } + + public ApplicationKeyGenerateRequest callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Callback URL + * @return callbackUrl + **/ + @ApiModelProperty(example = "", value = "Callback URL") + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ApplicationKeyGenerateRequest accessAllowDomains(List accessAllowDomains) { + this.accessAllowDomains = accessAllowDomains; + return this; + } + + public ApplicationKeyGenerateRequest addAccessAllowDomainsItem(String accessAllowDomainsItem) { + this.accessAllowDomains.add(accessAllowDomainsItem); + return this; + } + + /** + * Allowed domains for the access token + * @return accessAllowDomains + **/ + @ApiModelProperty(example = "null", required = true, value = "Allowed domains for the access token") + public List getAccessAllowDomains() { + return accessAllowDomains; + } + + public void setAccessAllowDomains(List accessAllowDomains) { + this.accessAllowDomains = accessAllowDomains; + } + + public ApplicationKeyGenerateRequest scopes(List scopes) { + this.scopes = scopes; + return this; + } + + public ApplicationKeyGenerateRequest addScopesItem(String scopesItem) { + this.scopes.add(scopesItem); + return this; + } + + /** + * Allowed scopes for the access token + * @return scopes + **/ + @ApiModelProperty(example = "null", value = "Allowed scopes for the access token") + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationKeyGenerateRequest applicationKeyGenerateRequest = (ApplicationKeyGenerateRequest) o; + return Objects.equals(this.keyType, applicationKeyGenerateRequest.keyType) && + Objects.equals(this.validityTime, applicationKeyGenerateRequest.validityTime) && + Objects.equals(this.callbackUrl, applicationKeyGenerateRequest.callbackUrl) && + Objects.equals(this.accessAllowDomains, applicationKeyGenerateRequest.accessAllowDomains) && + Objects.equals(this.scopes, applicationKeyGenerateRequest.scopes); + } + + @Override + public int hashCode() { + return Objects.hash(keyType, validityTime, callbackUrl, accessAllowDomains, scopes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApplicationKeyGenerateRequest {\n"); + + sb.append(" keyType: ").append(toIndentedString(keyType)).append("\n"); + sb.append(" validityTime: ").append(toIndentedString(validityTime)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" accessAllowDomains: ").append(toIndentedString(accessAllowDomains)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationList.java new file mode 100644 index 00000000000..b89c62e6a74 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ApplicationList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * ApplicationList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class ApplicationList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public ApplicationList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of applications returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of applications returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public ApplicationList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/applications?limit=1&offset=2&groupId=", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public ApplicationList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/applications?limit=1&offset=0&groupId=", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public ApplicationList list(List list) { + this.list = list; + return this; + } + + public ApplicationList addListItem(ApplicationInfo listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationList applicationList = (ApplicationList) o; + return Objects.equals(this.count, applicationList.count) && + Objects.equals(this.next, applicationList.next) && + Objects.equals(this.previous, applicationList.previous) && + Objects.equals(this.list, applicationList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApplicationList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Document.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Document.java new file mode 100644 index 00000000000..39d67609335 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Document.java @@ -0,0 +1,310 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Document + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Document { + @JsonProperty("documentId") + private String documentId = null; + + @JsonProperty("name") + private String name = null; + + /** + * Gets or Sets type + */ + public enum TypeEnum { + HOWTO("HOWTO"), + + SAMPLES("SAMPLES"), + + PUBLIC_FORUM("PUBLIC_FORUM"), + + SUPPORT_FORUM("SUPPORT_FORUM"), + + API_MESSAGE_FORMAT("API_MESSAGE_FORMAT"), + + SWAGGER_DOC("SWAGGER_DOC"), + + OTHER("OTHER"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String text) { + for (TypeEnum b : TypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("type") + private TypeEnum type = null; + + @JsonProperty("summary") + private String summary = null; + + /** + * Gets or Sets sourceType + */ + public enum SourceTypeEnum { + INLINE("INLINE"), + + URL("URL"), + + FILE("FILE"); + + private String value; + + SourceTypeEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static SourceTypeEnum fromValue(String text) { + for (SourceTypeEnum b : SourceTypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("sourceType") + private SourceTypeEnum sourceType = null; + + @JsonProperty("sourceUrl") + private String sourceUrl = null; + + @JsonProperty("otherTypeName") + private String otherTypeName = null; + + public Document documentId(String documentId) { + this.documentId = documentId; + return this; + } + + /** + * Get documentId + * @return documentId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public Document name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "CalculatorDoc", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Document type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(example = "HOWTO", required = true, value = "") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public Document summary(String summary) { + this.summary = summary; + return this; + } + + /** + * Get summary + * @return summary + **/ + @ApiModelProperty(example = "Summary of Calculator Documentation", value = "") + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public Document sourceType(SourceTypeEnum sourceType) { + this.sourceType = sourceType; + return this; + } + + /** + * Get sourceType + * @return sourceType + **/ + @ApiModelProperty(example = "INLINE", required = true, value = "") + public SourceTypeEnum getSourceType() { + return sourceType; + } + + public void setSourceType(SourceTypeEnum sourceType) { + this.sourceType = sourceType; + } + + public Document sourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + return this; + } + + /** + * Get sourceUrl + * @return sourceUrl + **/ + @ApiModelProperty(example = "", value = "") + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public Document otherTypeName(String otherTypeName) { + this.otherTypeName = otherTypeName; + return this; + } + + /** + * Get otherTypeName + * @return otherTypeName + **/ + @ApiModelProperty(example = "", value = "") + public String getOtherTypeName() { + return otherTypeName; + } + + public void setOtherTypeName(String otherTypeName) { + this.otherTypeName = otherTypeName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Document document = (Document) o; + return Objects.equals(this.documentId, document.documentId) && + Objects.equals(this.name, document.name) && + Objects.equals(this.type, document.type) && + Objects.equals(this.summary, document.summary) && + Objects.equals(this.sourceType, document.sourceType) && + Objects.equals(this.sourceUrl, document.sourceUrl) && + Objects.equals(this.otherTypeName, document.otherTypeName); + } + + @Override + public int hashCode() { + return Objects.hash(documentId, name, type, summary, sourceType, sourceUrl, otherTypeName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Document {\n"); + + sb.append(" documentId: ").append(toIndentedString(documentId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); + sb.append(" sourceUrl: ").append(toIndentedString(sourceUrl)).append("\n"); + sb.append(" otherTypeName: ").append(toIndentedString(otherTypeName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/DocumentList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/DocumentList.java new file mode 100644 index 00000000000..f3cb981965c --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/DocumentList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * DocumentList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class DocumentList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public DocumentList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Documents returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Documents returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public DocumentList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public DocumentList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public DocumentList list(List list) { + this.list = list; + return this; + } + + public DocumentList addListItem(Document listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentList documentList = (DocumentList) o; + return Objects.equals(this.count, documentList.count) && + Objects.equals(this.next, documentList.next) && + Objects.equals(this.previous, documentList.previous) && + Objects.equals(this.list, documentList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Error.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Error.java new file mode 100644 index 00000000000..6b234db0a8d --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Error.java @@ -0,0 +1,198 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * Error + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Error { + @JsonProperty("code") + private Long code = null; + + @JsonProperty("message") + private String message = null; + + @JsonProperty("description") + private String description = null; + + @JsonProperty("moreInfo") + private String moreInfo = null; + + @JsonProperty("error") + private List error = new ArrayList(); + + public Error code(Long code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public Long getCode() { + return code; + } + + public void setCode(Long code) { + this.code = code; + } + + public Error message(String message) { + this.message = message; + return this; + } + + /** + * Error message. + * @return message + **/ + @ApiModelProperty(example = "null", required = true, value = "Error message.") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Error description(String description) { + this.description = description; + return this; + } + + /** + * A detail description about the error message. + * @return description + **/ + @ApiModelProperty(example = "null", value = "A detail description about the error message. ") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Error moreInfo(String moreInfo) { + this.moreInfo = moreInfo; + return this; + } + + /** + * Preferably an url with more details about the error. + * @return moreInfo + **/ + @ApiModelProperty(example = "null", value = "Preferably an url with more details about the error. ") + public String getMoreInfo() { + return moreInfo; + } + + public void setMoreInfo(String moreInfo) { + this.moreInfo = moreInfo; + } + + public Error error(List error) { + this.error = error; + return this; + } + + public Error addErrorItem(ErrorListItem errorItem) { + this.error.add(errorItem); + return this; + } + + /** + * If there are more than one error list them out. For example, list out validation errors by each field. + * @return error + **/ + @ApiModelProperty(example = "null", value = "If there are more than one error list them out. For example, list out validation errors by each field. ") + public List getError() { + return error; + } + + public void setError(List error) { + this.error = error; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.moreInfo, error.moreInfo) && + Objects.equals(this.error, error.error); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, moreInfo, error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" moreInfo: ").append(toIndentedString(moreInfo)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ErrorListItem.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ErrorListItem.java new file mode 100644 index 00000000000..7bbe4a336fc --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/ErrorListItem.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * ErrorListItem + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class ErrorListItem { + @JsonProperty("code") + private String code = null; + + @JsonProperty("message") + private String message = null; + + public ErrorListItem code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(example = "null", required = true, value = "") + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public ErrorListItem message(String message) { + this.message = message; + return this; + } + + /** + * Description about individual errors occurred + * @return message + **/ + @ApiModelProperty(example = "null", required = true, value = "Description about individual errors occurred ") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorListItem errorListItem = (ErrorListItem) o; + return Objects.equals(this.code, errorListItem.code) && + Objects.equals(this.message, errorListItem.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorListItem {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Subscription.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Subscription.java new file mode 100644 index 00000000000..d2275ce76ce --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Subscription.java @@ -0,0 +1,228 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Subscription + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Subscription { + @JsonProperty("subscriptionId") + private String subscriptionId = null; + + @JsonProperty("applicationId") + private String applicationId = null; + + @JsonProperty("apiIdentifier") + private String apiIdentifier = null; + + @JsonProperty("tier") + private String tier = null; + + /** + * Gets or Sets status + */ + public enum StatusEnum { + BLOCKED("BLOCKED"), + + PROD_ONLY_BLOCKED("PROD_ONLY_BLOCKED"), + + UNBLOCKED("UNBLOCKED"), + + ON_HOLD("ON_HOLD"), + + REJECTED("REJECTED"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + public Subscription subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Get subscriptionId + * @return subscriptionId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + public String getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + public Subscription applicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get applicationId + * @return applicationId + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", required = true, value = "") + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public Subscription apiIdentifier(String apiIdentifier) { + this.apiIdentifier = apiIdentifier; + return this; + } + + /** + * Get apiIdentifier + * @return apiIdentifier + **/ + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", required = true, value = "") + public String getApiIdentifier() { + return apiIdentifier; + } + + public void setApiIdentifier(String apiIdentifier) { + this.apiIdentifier = apiIdentifier; + } + + public Subscription tier(String tier) { + this.tier = tier; + return this; + } + + /** + * Get tier + * @return tier + **/ + @ApiModelProperty(example = "Unlimited", required = true, value = "") + public String getTier() { + return tier; + } + + public void setTier(String tier) { + this.tier = tier; + } + + public Subscription status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @ApiModelProperty(example = "UNBLOCKED", value = "") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Subscription subscription = (Subscription) o; + return Objects.equals(this.subscriptionId, subscription.subscriptionId) && + Objects.equals(this.applicationId, subscription.applicationId) && + Objects.equals(this.apiIdentifier, subscription.apiIdentifier) && + Objects.equals(this.tier, subscription.tier) && + Objects.equals(this.status, subscription.status); + } + + @Override + public int hashCode() { + return Objects.hash(subscriptionId, applicationId, apiIdentifier, tier, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Subscription {\n"); + + sb.append(" subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n"); + sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n"); + sb.append(" apiIdentifier: ").append(toIndentedString(apiIdentifier)).append("\n"); + sb.append(" tier: ").append(toIndentedString(tier)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/SubscriptionList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/SubscriptionList.java new file mode 100644 index 00000000000..b6688838ec7 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/SubscriptionList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * SubscriptionList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class SubscriptionList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public SubscriptionList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Subscriptions returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Subscriptions returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public SubscriptionList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public SubscriptionList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public SubscriptionList list(List list) { + this.list = list; + return this; + } + + public SubscriptionList addListItem(Subscription listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscriptionList subscriptionList = (SubscriptionList) o; + return Objects.equals(this.count, subscriptionList.count) && + Objects.equals(this.next, subscriptionList.next) && + Objects.equals(this.previous, subscriptionList.previous) && + Objects.equals(this.list, subscriptionList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubscriptionList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tag.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tag.java new file mode 100644 index 00000000000..7370df7c68e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tag.java @@ -0,0 +1,122 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + + +/** + * Tag + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Tag { + @JsonProperty("name") + private String name = null; + + @JsonProperty("weight") + private Integer weight = null; + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "tag1", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tag weight(Integer weight) { + this.weight = weight; + return this; + } + + /** + * Get weight + * @return weight + **/ + @ApiModelProperty(example = "5", required = true, value = "") + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.name, tag.name) && + Objects.equals(this.weight, tag.weight); + } + + @Override + public int hashCode() { + return Objects.hash(name, weight); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" weight: ").append(toIndentedString(weight)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TagList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TagList.java new file mode 100644 index 00000000000..543a6c83f2e --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TagList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * TagList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class TagList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public TagList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Tags returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Tags returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public TagList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/tags?limit=1&offset=2", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public TagList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/tags?limit=1&offset=0", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public TagList list(List list) { + this.list = list; + return this; + } + + public TagList addListItem(Tag listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TagList tagList = (TagList) o; + return Objects.equals(this.count, tagList.count) && + Objects.equals(this.next, tagList.next) && + Objects.equals(this.previous, tagList.previous) && + Objects.equals(this.list, tagList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TagList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tier.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tier.java new file mode 100644 index 00000000000..1f44116b022 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Tier.java @@ -0,0 +1,328 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + + +/** + * Tier + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Tier { + @JsonProperty("name") + private String name = null; + + @JsonProperty("description") + private String description = null; + + /** + * Gets or Sets tierLevel + */ + public enum TierLevelEnum { + API("api"), + + APPLICATION("application"); + + private String value; + + TierLevelEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TierLevelEnum fromValue(String text) { + for (TierLevelEnum b : TierLevelEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("tierLevel") + private TierLevelEnum tierLevel = null; + + @JsonProperty("attributes") + private Map attributes = new HashMap(); + + @JsonProperty("requestCount") + private Long requestCount = null; + + @JsonProperty("unitTime") + private Long unitTime = null; + + /** + * This attribute declares whether this tier is available under commercial or free + */ + public enum TierPlanEnum { + FREE("FREE"), + + COMMERCIAL("COMMERCIAL"); + + private String value; + + TierPlanEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TierPlanEnum fromValue(String text) { + for (TierPlanEnum b : TierPlanEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("tierPlan") + private TierPlanEnum tierPlan = null; + + @JsonProperty("stopOnQuotaReach") + private Boolean stopOnQuotaReach = null; + + public Tier name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "Platinum", required = true, value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tier description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @ApiModelProperty(example = "Allows 50 request(s) per minute.", value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Tier tierLevel(TierLevelEnum tierLevel) { + this.tierLevel = tierLevel; + return this; + } + + /** + * Get tierLevel + * @return tierLevel + **/ + @ApiModelProperty(example = "api", value = "") + public TierLevelEnum getTierLevel() { + return tierLevel; + } + + public void setTierLevel(TierLevelEnum tierLevel) { + this.tierLevel = tierLevel; + } + + public Tier attributes(Map attributes) { + this.attributes = attributes; + return this; + } + + public Tier putAttributesItem(String key, String attributesItem) { + this.attributes.put(key, attributesItem); + return this; + } + + /** + * Custom attributes added to the tier policy + * @return attributes + **/ + @ApiModelProperty(example = "null", value = "Custom attributes added to the tier policy ") + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public Tier requestCount(Long requestCount) { + this.requestCount = requestCount; + return this; + } + + /** + * Maximum number of requests which can be sent within a provided unit time + * @return requestCount + **/ + @ApiModelProperty(example = "50", required = true, value = "Maximum number of requests which can be sent within a provided unit time ") + public Long getRequestCount() { + return requestCount; + } + + public void setRequestCount(Long requestCount) { + this.requestCount = requestCount; + } + + public Tier unitTime(Long unitTime) { + this.unitTime = unitTime; + return this; + } + + /** + * Get unitTime + * @return unitTime + **/ + @ApiModelProperty(example = "60000", required = true, value = "") + public Long getUnitTime() { + return unitTime; + } + + public void setUnitTime(Long unitTime) { + this.unitTime = unitTime; + } + + public Tier tierPlan(TierPlanEnum tierPlan) { + this.tierPlan = tierPlan; + return this; + } + + /** + * This attribute declares whether this tier is available under commercial or free + * @return tierPlan + **/ + @ApiModelProperty(example = "FREE", required = true, value = "This attribute declares whether this tier is available under commercial or free ") + public TierPlanEnum getTierPlan() { + return tierPlan; + } + + public void setTierPlan(TierPlanEnum tierPlan) { + this.tierPlan = tierPlan; + } + + public Tier stopOnQuotaReach(Boolean stopOnQuotaReach) { + this.stopOnQuotaReach = stopOnQuotaReach; + return this; + } + + /** + * If this attribute is set to false, you are capabale of sending requests even if the request count exceeded within a unit time + * @return stopOnQuotaReach + **/ + @ApiModelProperty(example = "true", required = true, value = "If this attribute is set to false, you are capabale of sending requests even if the request count exceeded within a unit time ") + public Boolean getStopOnQuotaReach() { + return stopOnQuotaReach; + } + + public void setStopOnQuotaReach(Boolean stopOnQuotaReach) { + this.stopOnQuotaReach = stopOnQuotaReach; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tier tier = (Tier) o; + return Objects.equals(this.name, tier.name) && + Objects.equals(this.description, tier.description) && + Objects.equals(this.tierLevel, tier.tierLevel) && + Objects.equals(this.attributes, tier.attributes) && + Objects.equals(this.requestCount, tier.requestCount) && + Objects.equals(this.unitTime, tier.unitTime) && + Objects.equals(this.tierPlan, tier.tierPlan) && + Objects.equals(this.stopOnQuotaReach, tier.stopOnQuotaReach); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, tierLevel, attributes, requestCount, unitTime, tierPlan, stopOnQuotaReach); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tier {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" tierLevel: ").append(toIndentedString(tierLevel)).append("\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); + sb.append(" unitTime: ").append(toIndentedString(unitTime)).append("\n"); + sb.append(" tierPlan: ").append(toIndentedString(tierPlan)).append("\n"); + sb.append(" stopOnQuotaReach: ").append(toIndentedString(stopOnQuotaReach)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TierList.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TierList.java new file mode 100644 index 00000000000..82bdb76a0c9 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/TierList.java @@ -0,0 +1,175 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * TierList + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class TierList { + @JsonProperty("count") + private Integer count = null; + + @JsonProperty("next") + private String next = null; + + @JsonProperty("previous") + private String previous = null; + + @JsonProperty("list") + private List list = new ArrayList(); + + public TierList count(Integer count) { + this.count = count; + return this; + } + + /** + * Number of Tiers returned. + * @return count + **/ + @ApiModelProperty(example = "1", value = "Number of Tiers returned. ") + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public TierList next(String next) { + this.next = next; + return this; + } + + /** + * Link to the next subset of resources qualified. Empty if no more resources are to be returned. + * @return next + **/ + @ApiModelProperty(example = "/tiers/api?limit=1&offset=2", value = "Link to the next subset of resources qualified. Empty if no more resources are to be returned. ") + public String getNext() { + return next; + } + + public void setNext(String next) { + this.next = next; + } + + public TierList previous(String previous) { + this.previous = previous; + return this; + } + + /** + * Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. + * @return previous + **/ + @ApiModelProperty(example = "/tiers/api?limit=1&offset=0", value = "Link to the previous subset of resources qualified. Empty if current subset is the first subset returned. ") + public String getPrevious() { + return previous; + } + + public void setPrevious(String previous) { + this.previous = previous; + } + + public TierList list(List list) { + this.list = list; + return this; + } + + public TierList addListItem(Tier listItem) { + this.list.add(listItem); + return this; + } + + /** + * Get list + * @return list + **/ + @ApiModelProperty(example = "null", value = "") + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TierList tierList = (TierList) o; + return Objects.equals(this.count, tierList.count) && + Objects.equals(this.next, tierList.next) && + Objects.equals(this.previous, tierList.previous) && + Objects.equals(this.list, tierList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, next, previous, list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TierList {\n"); + + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" next: ").append(toIndentedString(next)).append("\n"); + sb.append(" previous: ").append(toIndentedString(previous)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Token.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Token.java new file mode 100644 index 00000000000..f90d15d7c3f --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/model/Token.java @@ -0,0 +1,152 @@ +/** + * WSO2 API Manager - Store + * This document specifies a **RESTful API** for WSO2 **API Manager** - Store. It is written with [swagger 2](http://swagger.io/). + * + * OpenAPI spec version: 0.10.0 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed 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 org.wso2.carbon.apimgt.integration.client.store.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +/** + * Token + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30") +public class Token { + @JsonProperty("accessToken") + private String accessToken = null; + + @JsonProperty("tokenScopes") + private List tokenScopes = new ArrayList(); + + @JsonProperty("validityTime") + private Long validityTime = null; + + public Token accessToken(String accessToken) { + this.accessToken = accessToken; + return this; + } + + /** + * Access token + * @return accessToken + **/ + @ApiModelProperty(example = "1.2345678901234568E30", value = "Access token") + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public Token tokenScopes(List tokenScopes) { + this.tokenScopes = tokenScopes; + return this; + } + + public Token addTokenScopesItem(String tokenScopesItem) { + this.tokenScopes.add(tokenScopesItem); + return this; + } + + /** + * Valid scopes for the access token + * @return tokenScopes + **/ + @ApiModelProperty(example = "null", value = "Valid scopes for the access token") + public List getTokenScopes() { + return tokenScopes; + } + + public void setTokenScopes(List tokenScopes) { + this.tokenScopes = tokenScopes; + } + + public Token validityTime(Long validityTime) { + this.validityTime = validityTime; + return this; + } + + /** + * Maximum validity time for the access token + * @return validityTime + **/ + @ApiModelProperty(example = "3600", value = "Maximum validity time for the access token") + public Long getValidityTime() { + return validityTime; + } + + public void setValidityTime(Long validityTime) { + this.validityTime = validityTime; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Token token = (Token) o; + return Objects.equals(this.accessToken, token.accessToken) && + Objects.equals(this.tokenScopes, token.tokenScopes) && + Objects.equals(this.validityTime, token.validityTime); + } + + @Override + public int hashCode() { + return Objects.hash(accessToken, tokenScopes, validityTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Token {\n"); + + sb.append(" accessToken: ").append(toIndentedString(accessToken)).append("\n"); + sb.append(" tokenScopes: ").append(toIndentedString(tokenScopes)).append("\n"); + sb.append(" validityTime: ").append(toIndentedString(validityTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml deleted file mode 100644 index 682bb05aeb1..00000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/pom.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - apimgt-extensions - org.wso2.carbon.devicemgt - 2.0.8-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.publisher.client - bundle - org.wso2.carbon.apimgt.publisher.client - - - - - io.swagger - swagger-codegen-maven-plugin - - - - generate - - - ${project.basedir}/src/main/resources/publisher-api.yaml - java - - ${project.artifactId}.api - ${project.artifactId}.model - ${project.artifactId}.invoker - - feign - - - - - - maven-antrun-plugin - - - copy - process-resources - - - - - - - - - - - - - - run - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${project.version} - APIM publisher client - - org.wso2.carbon.apimgt.publisher.client.model, - org.wso2.carbon.apimgt.publisher.client.api, - org.wso2.carbon.apimgt.publisher.client.invoker - - - org.osgi.framework, - org.osgi.service.component, - org.wso2.carbon.logging, - io.swagger, - junit, - javax.ws.rs, - feign, - feign.jackson, - feign.codec, - feign.auth, - feign.gson, - feign.slf4j, - com.google.gson, - com.fasterxml.jackson.core, - com.fasterxml.jackson.annotation, - com.fasterxml.jackson.databind, - com.fasterxml.jackson.datatype.joda, i - o.swagger.annotations, - javax.net.ssl, - org.apache.oltu.oauth2.client.*, - org.apache.oltu.oauth2.common.*, - org.junit;resolution:=optional - - - - - - - - - - - - - - io.swagger - swagger-annotations - - - junit - junit - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - org.wso2.orbit.joda-time - joda-time - - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - - - io.github.openfeign - feign-jackson - - - io.github.openfeign - feign-slf4j - - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml deleted file mode 100644 index 665d73ea53e..00000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.publisher.client/src/main/resources/publisher-api.yaml +++ /dev/null @@ -1,2747 +0,0 @@ -swagger: '2.0' -###################################################### -# Prolog -###################################################### -info: - version: "0.10.0" - title: "WSO2 API Manager - Publisher API" - description: | - This document specifies a **RESTful API** for WSO2 **API Manager** - Publisher. - - It is written with [swagger 2](http://swagger.io/). - - contact: - name: "WSO2" - url: "http://wso2.com/products/api-manager/" - email: "architecture@wso2.com" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" - -###################################################### -# The fixed parts of the URLs of the API -###################################################### - -# The schemes supported by the API -schemes: - - https - -# The domain of the API. -# This is configured by the customer during deployment. -# The given host is just an example. -host: apis.wso2.com - -# The base path of the API. -# Will be prefixed to all paths. -basePath: /api/am/publisher/v0.10 - -# The following media types can be passed as input in message bodies of the API. -# The actual media type must be specified in the Content-Type header field of the request. -# The default is json, i.e. the Content-Type header is not needed to -# be set, but supporting it serves extensibility. -consumes: - - application/json - -# The following media types may be passed as output in message bodies of the API. -# The media type(s) consumable by the requestor is specified in the Accept header field -# of the corresponding request. -# The actual media type returned will be specfied in the Content-Type header field -# of the of the response. -# The default of the Accept header is json, i.e. there is not needed to -# set the value, but supporting it serves extensibility. -produces: - - application/json - - -x-wso2-security: - apim: - x-wso2-scopes: - - description: "" - roles: admin - name: apim:api_view - key: apim:api_view - - description: "" - roles: admin - name: apim:api_create - key: apim:api_create - - description: "" - roles: admin - name: apim:api_publish - key: apim:api_publish - - description: "" - roles: admin - name: apim:tier_view - key: apim:tier_view - - description: "" - roles: admin - name: apim:tier_manage - key: apim:tier_manage - - description: "" - roles: admin - name: apim:subscription_view - key: apim:subscription_view - - description: "" - roles: admin - name: apim:subscription_block - key: apim:subscription_block - -###################################################### -# The "API Collection" resource APIs -###################################################### -paths: - /apis: - -#----------------------------------------------------- -# Retrieving the list of all APIs qualifying under a given search condition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This sample API provides Account Status Validation\",\n \"name\": \"AccountVal\",\n \"context\": \"/account\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\",\n \"status\": \"PUBLISHED\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"name\": \"api1\",\n \"context\": \"/api1\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\",\n \"status\": \"PUBLISHED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: | - Get all APIs - description: | - Get a list of available APIs qualifying under a given search condition. - parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query - in: query - description: | - **Search condition**. - - You can search in attributes by using an **"attribute:"** modifier. - - Eg. "provider:wso2" will match an API if the provider of the API contains "wso2". - - Supported attribute modifiers are [**version, context, status, - description, subcontext, doc, provider**] - - If no advanced attribute modifier has been specified, search will match the - given query string against API Name. - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - APIs - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/APIList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new API -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer 40e486e50ce43407181fb4c570d2cac7\" -H \"Content-Type: application/json\" -X POST -d @data.json http://127.0.0.1:9763/api/am/publisher/v0.10/apis" - x-wso2-request: "{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b\nContent-Type: application/json\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"890a4f4d-09eb-4877-a323-57f6ce2ed79b\",\n \"status\": \"CREATED\"\n}" - summary: Create a new API - description: | - Create a new API - parameters: - - in: body - name: body - description: | - API object that needs to be added - required: true - schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - tags: - - APIs - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/API' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported Media Type. - The entity of the request was in a not supported format. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API" resource APIs -###################################################### - /apis/{apiId}: - -#----------------------------------------------------- -# Retrieve the details of an API definition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b" - x-wso2-response: "HTTP/1.1 200 OK\nDate: Mon, 22 Feb 2016 13:27:08 GMT\nContent-Type: application/json\nTransfer-Encoding: chunked\nServer: WSO2 Carbon Server\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"890a4f4d-09eb-4877-a323-57f6ce2ed79b\",\n \"status\": \"PUBLISHED\"\n}" - summary: Get API details - description: | - Get details of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Requested API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - schema: - $ref: '#/definitions/API' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the definition of an API -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d @data.json http://127.0.0.1:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060" - x-wso2-request: "{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"verification\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Use this API to verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nDate: Mon, 22 Feb 2016 13:31:35 GMT\nContent-Type: application/json\nTransfer-Encoding: chunked\nServer: WSO2 Carbon Server\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": false,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"verification\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Use this API to verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" - summary: Update an existing API - description: | - Update an existing API - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - API object that needs to be added - required: true - schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Successful response with updated API object - schema: - $ref: '#/definitions/API' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete the definition of an API -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X DELETE http://127.0.0.1:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete API - description: | - Delete an existing API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Resource successfully deleted. - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The swagger resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/swagger: -#----------------------------------------------------- -# Retrieve the API swagger definition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\nContent-Length: 329\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Get API Definition - description: | - Get the swagger of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the API swagger definition -#----------------------------------------------------- - put: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -F apiDefinition=\"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\" -X PUT \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger\"" - x-wso2-request: "{\n \"paths\": {\n \"\\/*\": {\n \"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\n \"200\": {\n \"description\": \"OK\"\n }\n }\n }\n }\n },\n \"x-wso2-security\": {\n \"apim\": {\n \"x-wso2-scopes\": []\n }\n },\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Update API Definition - description: | - Update an existing swagger definition of an API - parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: apiDefinition - description: Swagger definition of the API - type: string - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Successful response with updated Swagger definition - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The thumbnail resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/thumbnail: -#------------------------------------------------------------------------------------------------- -# Downloads a thumbnail image of an API -#------------------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail > image.jpg" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" - summary: Get the thumbnail image - description: | - Downloads a thumbnail image of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Thumbnail image returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#---------------------------------------------------------------------------- -# Upload a thumbnail image to a certain API -#---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -X POST -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" http://127.0.0.1:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail -F file=@image.jpg" - x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail\r\nContent-Type: application/json\r\n\r\n{\r\n \"relativePath\": \"/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail\",\r\n \"mediaType\": \"image/jpeg\"\r\n}" - summary: Upload a thumbnail image - description: | - Upload a thumbnail image to an API. - parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: file - description: Image to upload - type: file - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Image updated - schema: - $ref : '#/definitions/FileInfo' - headers: - Location: - description: | - The URL of the uploaded thumbnail image of the API. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Copy API" Processing Function resource API -###################################################### - /apis/copy-api: - -#----------------------------------------------------- -# Create a new API based on an already existing one -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0\"" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/6fb74674-4ab8-4b52-9886-f9a376985060\nContent-Type: application/json\n\n{\n \"sequences\": [],\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"visibility\": \"PUBLIC\",\n \"visibleRoles\": [],\n \"visibleTenants\": [],\n \"cacheTimeout\": 300,\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\" http://ws.cdyne.com/phoneverify/phoneverify.asmx\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\n \"subscriptionAvailability\": null,\n \"subscriptionAvailableTenants\": [],\n \"destinationStatsEnabled\": \"Disabled\",\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"responseCaching\": \"Disabled\",\n \"isDefaultVersion\": true,\n \"gatewayEnvironments\": \"Production and Sandbox\",\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify\",\n \"id\": \"6fb74674-4ab8-4b52-9886-f9a376985060\",\n \"status\": \"CREATED\"\n}" - summary: Copy API - description: | - Create a new API by copying an existing API - parameters: - - name: newVersion - description: Version of the new API. - type: string - in: query - required: true - - $ref: '#/parameters/apiId-Q' - tags: - - APIs - responses: - 201: - description: | - Created. - Successful response with the newly created API as entity in the body. Location header contains URL of newly created API. - headers: - Location: - description: | - The URL of the newly created API. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - API to copy does not exist. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Change Lifecycle" Processing Function resource API -###################################################### - /apis/change-lifecycle: - -#----------------------------------------------------- -# Change the lifecycle of an API -#----------------------------------------------------- - post: - x-scope: apim:api_publish - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish\"" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Change API Status - description: | - Change the lifecycle of an API - parameters: - - name: action - description: | - The action to demote or promote the state of the API. - - Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] - - in: query - type: string - required: true - enum: - - Publish - - Deploy as a Prototype - - Demote to Created - - Demote to Prototyped - - Block - - Deprecate - - Re-Publish - - Retire - - name: lifecycleChecklist - description: | - - You can specify additional checklist items by using an **"attribute:"** modifier. - - Eg: "Deprecate Old Versions:true" will deprecate older versions of a particular API when it is promoted to - Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" - format. - - Supported checklist items are as follows. - 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. - 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. - - type: string - in: query - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - APIs - responses: - 200: - description: | - OK. - Lifecycle changed successfully. - headers: - ETag: - description: | - Entity Tag of the changed API. Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the API lifecycle has been modified the last time. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Document Collection" resource APIs -###################################################### - /apis/{apiId}/documents: - -#----------------------------------------------------- -# Retrieve the documents associated with an API that qualify under a search condition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"4145df31-04f1-440c-8d08-68952874622c\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: Get API Documents - description: | - Get a list of documents belonging to an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - API Document - responses: - 200: - description: | - OK. - Document list is returned. - schema: - $ref: '#/definitions/DocumentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Add a document to a certain API -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer cdcc8cf6016ed10620edf3a1d3c5ef2b\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\"" - x-wso2-request: "{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - summary: Add a new document - description: | - Add a new document to an API - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - tags: - - API Document - responses: - 201: - description: | - Created. - Successful response with the newly created Document object as entity in the body. - Location header contains URL of newly added document. - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - Location to the newly created Document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Document" resource APIs -###################################################### - '/apis/{apiId}/documents/{documentId}': - -#----------------------------------------------------- -# Retrieve a particular document of a certain API -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Get an API Document - description: | - Get a particular document associated with an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API Document - responses: - 200: - description: | - OK. - Document returned. - schema: - $ref: '#/definitions/Document' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a particular document of a certain API -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-request: "{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Update an API Document - description: | - Update document details. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API Document - responses: - 200: - description: | - OK. - Document updated - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - The URL of the updated document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a particular document of a certain API -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X DELETE http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete an API Document - description: | - Delete a document of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API Document - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The content resource of "Individual Document" resource APIs -################################################################ - - '/apis/{apiId}/documents/{documentId}/content': - - #------------------------------------------------------------------------------------------------- - # Downloads a FILE type document/get the inline content or source url of a certain document - #------------------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\" > sample.pdf" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" - summary: Get document content - description: | - Downloads a FILE type document/get the inline content or source url of a certain document. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API Document - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - #---------------------------------------------------------------------------- - # Upload a file or add inline content to a document of a certain API - #---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -F file=@\"sample.pdf\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\"" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\nContent-Type: application/json\n\n{\n \"visibility\":\"API_LEVEL\",\n \"sourceType\":\"FILE\",\n \"sourceUrl\":null,\n \"otherTypeName\":null,\n \"documentId\":\"daf732d3-bda2-46da-b381-2c39d901ea61\",\n \"summary\":\"This is a sample documentation pdf\",\n \"name\":\"Introduction to PhoneVerification API PDF\",\n \"type\":\"HOWTO\"\n}" - summary: Update API document content. - description: | - Upload a file to a document or add inline content to the document. - - Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. - Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. - - Only one of **file** or **inlineContent** can be specified at one time. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: formData - name: file - description: Document to upload - type: file - required: false - - in: formData - name: inlineContent - description: Inline content of the document - type: string - required: false - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API Document - responses: - 200: - description: | - OK. - Document updated - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - The URL of the updated content of the document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Application" resource APIs -###################################################### - '/applications/{applicationId}': - -#----------------------------------------------------- -# Retrieve the details about a certain application -#----------------------------------------------------- - get: - x-scope: apim:api_create - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/applications/896658a0-b4ee-4535-bbfa-806c894a4015" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"name\": \"DefaultApplication\"\n}" - summary: Get Application - description: | - Get application details - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Applications - responses: - 200: - description: | - OK. - Application returned. - schema: - $ref: '#/definitions/Application' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Subscription Collection" resource APIs -###################################################### - /subscriptions: - -#----------------------------------------------------- -# Retrieve all subscriptions of a certain API -#----------------------------------------------------- - get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"previous\": \"\",\n \"list\": [\n {\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"subscriptionId\": \"7ac22c34-8745-4cfe-91e0-262c50b2f2e3\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: Get All Subscriptions - description: | - Get subscription list. - The API Identifier and corresponding Application Identifier - the subscriptions of which are to be returned are passed as parameters. - parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Subscriptions - responses: - 200: - description: | - OK. - Subscription list returned. - schema: - $ref: '#/definitions/SubscriptionList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Subscription" resource APIs -###################################################### - '/subscriptions/{subscriptionId}': - -#----------------------------------------------------- -# Retrieve a certain subscription -#----------------------------------------------------- - get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n}" - summary: Get a Subscription - description: | - Get subscription details - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Subscriptions - responses: - 200: - description: | - OK. - Subscription returned - schema: - $ref: '#/definitions/Subscription' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: 'Entity Tag of the response resource. Used by caches, or in conditional requests.' - type: string - Last-Modified: - description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.' - type: string - '304': - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - '404': - description: | - Not Found. - Requested Subscription does not exist. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Block Subscription" Processing Function resource API -###################################################### - /subscriptions/block-subscription: - -#----------------------------------------------------- -# Block a certain subscription -#----------------------------------------------------- - post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"PROD_ONLY_BLOCKED\"\n}" - summary: Block a subscription - parameters: - - $ref: '#/parameters/subscriptionId-Q' - - name: blockState - in: query - description: | - Subscription block state. - type: string - required: true - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - description: | - Block a subscription. - tags: - - Subscriptions - responses: - 200: - description: | - OK. - Subscription was blocked successfully. - headers: - ETag: - description: | - Entity Tag of the blocked subscription. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the subscription has been blocked. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Unblock Subscription" Processing Function resource API -###################################################### - /subscriptions/unblock-subscription: - -#----------------------------------------------------- -# Unblock a certain subscription -#----------------------------------------------------- - post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n} " - summary: Unblock a Subscription - parameters: - - $ref: '#/parameters/subscriptionId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - description: | - Unblock a subscription. - tags: - - Subscriptions - responses: - 200: - description: | - OK. - Subscription was unblocked successfully. - headers: - ETag: - description: | - Entity Tag of the unblocked subscription. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the subscription has been unblocked. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tier Collection" resource APIs -###################################################### - '/tiers/{tierLevel}': - -#----------------------------------------------------- -# Retrieve the list of all available tiers -#----------------------------------------------------- - get: - x-scope: apim:tier_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"next\": \"\",\n \"count\": 4\n}" - summary: List Tiers - description: | - Get available tiers - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Tiers - responses: - 200: - description: | - OK. - List of tiers returned. - schema: - $ref: '#/definitions/TierList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api\"" - x-wso2-request: "{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\":10,\n \"b\":30\n }\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/publisher/v0.10/tiers/Low\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"30\",\n \"a\": \"10\"\n }\n}" - summary: Add a new Tier - description: | - Add a new tier - parameters: - - in: body - name: body - description: | - Tier object that should to be added - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Content-Type' - tags: - - Tiers - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Tier' - headers: - Location: - description: | - Location of the newly created tier. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request' - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Tier" resource APIs -###################################################### - '/tiers/{tierLevel}/{tierName}': - -#----------------------------------------------------- -# Retrieve a certain tier -#----------------------------------------------------- - get: - x-scope: apim:tier_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Bronze" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" - summary: Get a Tier - description: | - Get tier details - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Tiers - responses: - 200: - description: | - OK. - Tier returned - schema: - $ref: '#/definitions/Tier' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Tier does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a certain tier -#----------------------------------------------------- - put: - x-scope: apim:tier_manage - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Low\"" - x-wso2-request: "{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\": \"30\",\n \"b\": \"10\",\n \"c\": \"20\"\n }\n}\n" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"10\",\n \"c\": \"20\",\n \"a\": \"30\"\n }\n}" - summary: Update a Tier - description: | - Update tier details - parameters: - - $ref: '#/parameters/tierName' - - in: body - name: body - description: | - Tier object that needs to be modified - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Tiers - responses: - 200: - description: | - OK. - Subscription updated. - schema: - $ref: '#/definitions/Tier' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain tier -#----------------------------------------------------- - delete: - x-scope: apim:tier_manage - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -X POST \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/api/Low\"" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete a Tier - description: | - Remove a tier - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Tiers - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Update Permission" Processing Function resource API -###################################################### - '/tiers/update-permission': - -#----------------------------------------------------- -# Update the permission of a certain tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/publisher/v0.10/tiers/update-permission?tierName=Bronze&tierLevel=api\"" - x-wso2-request: "{\n \"permissionType\":\"deny\",\n \"roles\": [\"Internal/everyone\",\"admin\"]\n}" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Update Tier Permission - description: | - Update tier permission - parameters: - - $ref: '#/parameters/tierName-Q' - - $ref: '#/parameters/tierLevel-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - - in: body - name: permissions - schema: - $ref: '#/definitions/TierPermission' - tags: - - Tiers - responses: - 200: - description: | - OK. - Successfully updated tier permissions - schema: - type: array - items: - $ref: '#/definitions/Tier' - headers: - ETag: - description: | - Entity Tag of the modified tier. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the tier has been modified. - Used by caches, or in conditional requests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested tier does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Environment Collection" resource API -###################################################### - /environments: - -#----------------------------------------------------- -# Retrieve the list of environments configured for a certain API -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -H \"Authorization: Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"http://127.0.0.1:9763/api/am/publisher/v0.10/environments\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"list\": [ {\n \"showInApiConsole\": true,\n \"serverUrl\": \"https://192.168.56.1:9444//services/\",\n \"endpoints\": {\n \"http\": \"http://192.168.56.1:8281\",\n \"https\": \"https://192.168.56.1:8244\"\n },\n \"name\": \"Production and Sandbox\",\n \"type\": \"hybrid\"\n }],\n \"count\": 1\n}" - summary: Get gateway environments - description: | - Get a list of gateway environments configured previously. - parameters: - - in: query - name: apiId - description: | - Will return environment list for the provided API. - type: string - tags: - - Environments - responses: - 200: - description: | - OK. - Environment list is returned. - schema: - $ref: '#/definitions/EnvironmentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' -###################################################### -# Parameters - required by some of the APIs above -###################################################### -parameters: - -# API Identifier -# Specified as part of the path expression - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. - Should be formatted as **provider-name-version**. - required: true - type: string - -# API Identifier -# Specified as part of the query string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - type: string - - -# Document Identifier -# Specified as part of the path expression - documentId: - name: documentId - in: path - description: | - **Document Identifier** - required: true - type: string - -# Application Identifier -# Specified as part of the path expression - applicationId: - name: applicationId - in: path - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - type: string - -# Subscription Identifier -# Specified as part of the path expression - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - type: string - -# Subscription Identifier -# Specified as part of the query string - subscriptionId-Q: - name: subscriptionId - in: query - description: | - Subscription Id - required: true - type: string - -# Tier Name -# Specified as part of the path expression - tierName: - name: tierName - in: path - description: | - Tier name - required: true - type: string - -# Tier Name -# Specified as part of the query string - tierName-Q: - name: tierName - in: query - description: | - Name of the tier - required: true - type: string - -# Tier Type -# Specified as part of the path expression - tierLevel: - name: tierLevel - in: path - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Tier Type -# Specified as part of the query string - tierLevel-Q: - name: tierLevel - in: query - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Used for pagination: -# The maximum number of resoures to be returned by a GET - limit: - name: limit - in: query - description: | - Maximum size of resource array to return. - default: 25 - type: integer - -# Used for pagination: -# The order number of an instance in a qualified set of resoures -# at which to start to return the next batch of qualified resources - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - default: 0 - type: integer - -# The HTTP Accept header - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is JSON. - default: JSON - type: string - -# The HTTP Content-Type header - Content-Type: - name: Content-Type - in: header - description: | - Media type of the entity in the body. Default is JSON. - default: JSON - required: true - type : string - -# The HTTP If-None-Match header -# Used to avoid retrieving data that are already cached - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resourec. - type : string - -# The HTTP If-Modified-Since header -# Used to avoid retrieving data that are already cached - If-Modified-Since: - name: If-Modified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header of the - formerly retrieved variant of the resource. - type: string - -# The HTTP If-Match header -# Used to avoid concurrent updates - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag. - type: string - -# The HTTP If-Unmodified-Since header -# Used to avoid concurrent updates - If-Unmodified-Since: - name: If-Unmodified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header. - type: string - -###################################################### -# The resources used by some of the APIs above within the message body -###################################################### -definitions: - -#----------------------------------------------------- -# The API List resource -#----------------------------------------------------- - APIList: - title: API List - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis?limit=1&offset=2&query=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis?limit=1&offset=0&query=" - list: - type: array - items: - $ref: '#/definitions/APIInfo' - -#----------------------------------------------------- -# The API Info resource -#----------------------------------------------------- - APIInfo: - title: API Info object with basic API details. - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - type: string - example: admin - status: - type: string - example: CREATED - -#----------------------------------------------------- -# The API resource -#----------------------------------------------------- - API: - title: API object - required: - - name - - context - - version - - apiDefinition - - tiers - - isDefaultVersion - - transport - - endpointConfig - - visibility - properties: - id: - type: string - description: | - UUID of the api registry artifact - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given user invoking the api will be used as the provider. - type: string - example: admin - apiDefinition: - description: | - Swagger definition of the API which contains details about URI templates and scopes - type: string - wsdlUri: - description: | - WSDL URL if the API is based on a WSDL endpoint - type: string - example: "http://www.webservicex.com/globalweather.asmx?wsdl" - status: - type: string - example: CREATED - responseCaching: - type: string - example: Disabled - cacheTimeout: - type: integer - example: 300 - destinationStatsEnabled: - type: string - example: Disabled - isDefaultVersion: - type: boolean - example: false - transport: - description: | - Supported transports for the API (http and/or https). - type: array - items: - type: string - example: ["http","https"] - tags: - type: array - items: - type: string - example: ["substract","add"] - tiers: - type: array - items: - type: string - example: ["Unlimited"] - maxTps: - properties: - production: - type: integer - format: int64 - example: 1000 - sandbox: - type: integer - format: int64 - example: 1000 - thumbnailUri: - type: string - example: "/apis/01234567-0123-0123-0123-012345678901/thumbnail" - visibility: - type: string - enum: - - PUBLIC - - PRIVATE - - RESTRICTED - - CONTROLLED - example: PUBLIC - visibleRoles: - type: array - items: - type: string - example: [] - visibleTenants: - type: array - items: - type: string - example: [] - endpointConfig: - type: string - example: "{\"production_endpoints\":{\"url\":\"http://localhost:9763/am/sample/calculator/v1/api\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}" - endpointSecurity: - properties: - type: - type: string - example: basic - enum: - - basic - - digest - username: - type: string - example: admin - password: - type: string - example: password - gatewayEnvironments: - description: | - Comma separated list of gateway environments. - type: string - example: Production and Sandbox - sequences: - type: array - items: - $ref: '#/definitions/Sequence' - example: [] - subscriptionAvailability: - type: string - enum: - - current_tenant - - all_tenants - - specific_tenants - example: current_tenant - subscriptionAvailableTenants: - type: array - items: - type: string - example: [] - businessInformation: - properties: - businessOwner: - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - corsConfiguration: - description: | - CORS configuration for the API - properties: - corsConfigurationEnabled: - type: boolean - default: false - accessControlAllowOrigins: - type: array - items: - type: string - accessControlAllowCredentials: - type: boolean - default: false - accessControlAllowHeaders: - type: array - items: - type: string - accessControlAllowMethods: - type: array - items: - type: string - -#----------------------------------------------------- -# The Application resource -#----------------------------------------------------- - Application: - title: Application - required: - - name - - throttlingTier - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - description: - type: string - example: Sample calculator application - groupId: - type: string - example: "" - -#----------------------------------------------------- -# The Document List resource -#----------------------------------------------------- - DocumentList: - title: Document List - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Document' - -#----------------------------------------------------- -# The Document resource -#----------------------------------------------------- - Document: - title: Document - required: - - name - - type - - sourceType - - visibility - properties: - documentId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorDoc - type: - type: string - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - example: HOWTO - summary: - type: string - example: "Summary of Calculator Documentation" - sourceType: - type: string - enum: - - INLINE - - URL - - FILE - example: INLINE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - visibility: - type: string - enum: - - OWNER_ONLY - - PRIVATE - - API_LEVEL - example: API_LEVEL - -#----------------------------------------------------- -# The Tier List resource -#----------------------------------------------------- - TierList: - title: Tier List - properties: - count: - type: integer - description: | - Number of Tiers returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tiers/api?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tiers/api?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tier' - -#----------------------------------------------------- -# The Tier resource -#----------------------------------------------------- - Tier: - title: Tier - required: - - name - - tierPlan - - requestCount - - unitTime - - stopOnQuotaReach - properties: - name: - type: string - example: Platinum - description: - type: string - example: "Allows 50 request(s) per minute." - tierLevel: - type: string - enum: - - api - - application - - resource - example: api - attributes: - description: | - Custom attributes added to the tier policy - type: object - additionalProperties: - type: string - example: {} - requestCount: - description: | - Maximum number of requests which can be sent within a provided unit time - type: integer - format: int64 - example: 50 - unitTime: - type: integer - format: int64 - example: 60000 - timeUnit: - type: string - example: "min" - tierPlan: - description: | - This attribute declares whether this tier is available under commercial or free - type: string - enum: - - FREE - - COMMERCIAL - example: FREE - stopOnQuotaReach: - description: | - By making this attribute to false, you are capabale of sending requests - even if the request count exceeded within a unit time - type: boolean - example: true - -#----------------------------------------------------- -# The Tier Permission resource -#----------------------------------------------------- - TierPermission: - title: tierPermission - required: - - permissionType - - roles - properties: - permissionType: - type: string - enum: - - allow - - deny - example: deny - roles: - type: array - items: - type: string - example: ["Internal/everyone"] - -#----------------------------------------------------- -# The Subscription List resource -#----------------------------------------------------- - SubscriptionList: - title: Subscription List - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" - list: - type: array - items: - $ref: '#/definitions/Subscription' - -#----------------------------------------------------- -# The Subscription resource -#----------------------------------------------------- - Subscription: - title: Subscription - required: - - applicationId - - apiIdentifier - - tier - properties: - subscriptionId: - type: string - example: 01234567-0123-0123-0123-012345678901 - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - apiIdentifier: - type: string - example: 01234567-0123-0123-0123-012345678901 - tier: - type: string - example: Unlimited - status: - type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - example: UNBLOCKED - -#----------------------------------------------------- -# The Sequence resource -#----------------------------------------------------- - Sequence: - title: Sequence - required: - - name - properties: - name: - type: string - example: log_in_message - config: - type: string - example: "" - type: - type: string - example: in - -#----------------------------------------------------- -# The Error resource -#----------------------------------------------------- - Error: - title: Error object returned with 4XX HTTP status - required: - - code - - message - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/definitions/ErrorListItem' - -#----------------------------------------------------- -# The Error List Item resource -#----------------------------------------------------- - ErrorListItem: - title: Description of individual errors that may have occurred during a request. - required: - - code - - message - properties: - code: - type: string - message: - type: string - description: | - Description about individual errors occurred - -#----------------------------------------------------- -# The Environment resource -#----------------------------------------------------- - Environment: - title: Environment - required: - - name - - type - - serverUrl - - endpoints - - showInApiConsole - properties: - name: - type: string - example: Production and Sandbox - type: - type: string - example: hybrid - serverUrl: - type: string - example: "https://localhost:9443//services/" - showInApiConsole: - type: boolean - example: true - endpoints: - $ref: '#/definitions/EnvironmentEndpoints' - -#----------------------------------------------------- -# The Environment List resource -#----------------------------------------------------- - EnvironmentList: - title: Environment List - properties: - count: - type: integer - description: | - Number of Environments returned. - example: 1 - list: - type: array - items: - $ref: '#/definitions/Environment' - - -#----------------------------------------------------- -# The Environment Endpoint resource -#----------------------------------------------------- - EnvironmentEndpoints : - title: Environment Endpoints - properties: - http: - type: string - description: HTTP environment URL - example: "http://localhost:8280" - https: - type: string - description: HTTPS environment URL - example: "https://localhost:8244" - -#----------------------------------------------------- -# The File Information resource -#----------------------------------------------------- - FileInfo : - title: File Information including meta data - properties: - relativePath: - type: string - description: relative location of the file (excluding the base context and host of the Publisher API) - example: "apis/01234567-0123-0123-0123-012345678901/thumbnail" - mediaType: - type: string - description: media-type of the file - example: "image/jpeg" diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml deleted file mode 100644 index 47514272218..00000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/pom.xml +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - apimgt-extensions - org.wso2.carbon.devicemgt - 2.0.8-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.store.client - bundle - org.wso2.carbon.apimgt.store.client - - - - - io.swagger - swagger-codegen-maven-plugin - 2.2.1 - - - - generate - - - ${project.basedir}/src/main/resources/store-api.yaml - java - - ${project.artifactId}.api - ${project.artifactId}.model - ${project.artifactId}.invoker - - feign - - - - - - maven-antrun-plugin - 1.4 - - - copy - process-resources - - - - - - - - - - - - - - run - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${project.version} - APIM Integration - - org.wso2.carbon.apimgt.store.client.model, - org.wso2.carbon.apimgt.store.client.api, - org.wso2.carbon.apimgt.store.client.invoker - - - org.osgi.framework, - org.osgi.service.component, - org.wso2.carbon.logging, - io.swagger, - junit, - javax.ws.rs, - feign, - feign.jackson, - feign.codec, - feign.auth, - feign.gson, - feign.slf4j, - feign.jaxrs, - com.google.gson, - com.fasterxml.jackson.core, - com.fasterxml.jackson.annotation, - com.fasterxml.jackson.databind, - com.fasterxml.jackson.datatype.joda, i - o.swagger.annotations, - javax.net.ssl, - org.apache.oltu.oauth2.client.*, - org.apache.oltu.oauth2.common.*, - org.junit;resolution:=optional - - - - - - - - - - - - - - io.swagger - swagger-annotations - - - junit - junit - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - org.wso2.orbit.joda-time - joda-time - - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - - - io.github.openfeign - feign-jackson - - - io.github.openfeign - feign-slf4j - - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml deleted file mode 100644 index b591fc3597c..00000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.store.client/src/main/resources/store-api.yaml +++ /dev/null @@ -1,2098 +0,0 @@ -swagger: '2.0' -###################################################### -# Prolog -###################################################### -info: - version: "0.10.0" - title: "WSO2 API Manager - Store" - description: | - This document specifies a **RESTful API** for WSO2 **API Manager** - Store. - - It is written with [swagger 2](http://swagger.io/). - - contact: - name: "WSO2" - url: "http://wso2.com/products/api-manager/" - email: "architecture@wso2.com" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" - -###################################################### -# The fixed parts of the URLs of the API -###################################################### - -# The schemes supported by the API -schemes: - - https - -# The domain of the API. -# This is configured by the customer during deployment. -# The given host is just an example. -host: apis.wso2.com - -# The base path of the API. -# Will be prefixed to all paths. -basePath: /api/am/store/v0.10 - -# The following media types can be passed as input in message bodies of the API. -# The actual media type must be specified in the Content-Type header field of the request. -# The default is json, i.e. the Content-Type header is not needed to -# be set, but supporting it serves extensibility. -consumes: - - application/json - -# The following media types may be passed as output in message bodies of the API. -# The media type(s) consumable by the requestor is specified in the Accept header field -# of the corresponding request. -# The actual media type returned will be specfied in the Content-Type header field -# of the of the response. -# The default of the Accept header is json, i.e. there is not needed to -# set the value, but supporting it serves extensibility. -produces: - - application/json - -x-wso2-security: - apim: - x-wso2-scopes: - - description: "" - roles: Internal/subscriber - name: apim:subscribe - key: apim:subscribe - -###################################################### -# The "API Collection" resource APIs -###################################################### -paths: - /apis: - -#----------------------------------------------------- -# Retrieving the list of all APIs qualifying under a given search condition -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This API provide Account Status Validation.\",\n \"status\": \"PUBLISHED\",\n \"name\": \"AccountVal\",\n \"context\": \"/account/1.0.0\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"status\": \"PUBLISHED\",\n \"name\": \"api1\",\n \"context\": \"/api1/1.0.0\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"status\": \"PUBLISHED\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify/2.0.0\",\n \"id\": \"c43a325c-260b-4302-81cb-768eafaa3aed\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - summary: | - Retrieving APIs - description: | - Get a list of available APIs qualifying under a given search condition. - parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - $ref : '#/parameters/requestedTenant' - - name : query - in: query - description: | - **Search condition**. - - You can search in attributes by using an **"attribute:"** modifier. - - Eg. - "provider:wso2" will match an API if the provider of the API is exactly "wso2". - - Additionally you can use wildcards. - - Eg. - "provider:wso2\*" will match an API if the provider of the API starts with "wso2". - - Supported attribute modifiers are [**version, context, status, - description, subcontext, doc, provider, tag**] - - If no advanced attribute modifier has been specified, search will match the - given query string against API Name. - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - apisAPI - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/APIList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API" resource APIs -###################################################### - /apis/{apiId}: - -#----------------------------------------------------- -# Retrieve the details of an API definition -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"tiers\": [\n \"Bronze\",\n \"Gold\"\n ],\n \"thumbnailUrl\": null,\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\n \"isDefaultVersion\": false,\n \"businessInformation\": {\n \"technicalOwner\": \"xx\",\n \"technicalOwnerEmail\": \"ggg@ww.com\",\n \"businessOwner\": \"xx\",\n \"businessOwnerEmail\": \"xx@ee.com\"\n },\n \"transport\": [\n \"http\",\n \"https\"\n ],\n \"tags\": [\n \"phone\",\n \"multimedia\",\n \"mobile\"\n ],\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"status\": \"PUBLISHED\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify/2.0.0\",\n \"id\": \"c43a325c-260b-4302-81cb-768eafaa3aed\"\n}" - summary: | - Get Details of API - description: | - Get details of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - - $ref: '#/parameters/requestedTenant' - tags: - - API (individual) - responses: - 200: - description: | - OK. - Requested API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - schema: - $ref: '#/definitions/API' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - - /apis/{apiId}/swagger: -#----------------------------------------------------- -# Retrieve the API swagger definition -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/swagger" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"2.0.0\"\n }\n}\n" - summary: | - Get the swagger of an API - description: | - Get the swagger of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - - $ref: '#/parameters/requestedTenant' - tags: - - API (individual) - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Document Collection" resource APIs -###################################################### - /apis/{apiId}/documents: - -#----------------------------------------------------- -# Retrieve the documents associated with an API that qualify under a search condition -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"98e18be8-5861-43c7-ba26-8cbbccd3a76f\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n },\n {\n \"sourceType\": \"FILE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"b66451ff-c6c2-4f6a-b91d-3821dc119b04\",\n \"summary\": \"This is a sample documentation pdf\",\n \"name\": \"Introduction to PhoneVerification API PDF\",\n \"type\": \"HOWTO\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - summary: | - Get a list of documents belonging to an API. - description: | - Get a list of documents belonging to an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - API (individual) - responses: - 200: - description: | - OK. - Document list is returned. - schema: - $ref: '#/definitions/DocumentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Document" resource APIs -###################################################### - '/apis/{apiId}/documents/{documentId}': - -#----------------------------------------------------- -# Retrieve a particular document of a certain API -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: | - Get a particular document associated with an API. - description: | - Get a particular document associated with an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (individual) - responses: - 200: - description: | - OK. - Document returned. - schema: - $ref: '#/definitions/Document' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - -################################################################ -# The content resource of "Individual Document" resource APIs -################################################################ - - '/apis/{apiId}/documents/{documentId}/content': - - #------------------------------------------------------------------------------------------------- - # Downloads a FILE type document/get the inline content or source url of a certain document - #------------------------------------------------------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content\" > sample.pdf" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" - summary: | - Downloads a FILE type document/get the inline content or source url of a certain document. - description: | - Downloads a FILE type document/get the inline content or source url of a certain document. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (individual) - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -################################################################ -# The thumbnail resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/thumbnail: -#------------------------------------------------------------------------------------------------- -# Downloads a thumbnail image of an API -#------------------------------------------------------------------------------------------------- - get: - x-wso2-curl: "curl http://127.0.0.1:9763/api/am/store/v0.10/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail > image.jpg" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" - summary: Get the thumbnail image - description: | - Downloads a thumbnail image of an API - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (individual) - responses: - 200: - description: | - OK. - Thumbnail image returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Application Collection" resource APIs -###################################################### - /applications: - -#----------------------------------------------------- -# Retrieve a list of all applications of a certain subscriber -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/applications\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"description\": \"\",\n \"status\": \"APPROVED\",\n \"name\": \"app1\"\n },\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" - summary: | - Get a list of applications - description: | - Get a list of applications - parameters: - - $ref: '#/parameters/groupId' - - name : query - in: query - description: | - **Search condition**. - - You can search for an application by specifying the name as "query" attribute. - - Eg. - "app1" will match an application if the name is exactly "app1". - - Currently this does not support wildcards. Given name must exactly match the application name. - type: string - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Application Collection - responses: - 200: - description: | - OK. - Application list returned. - schema: - $ref: '#/definitions/ApplicationList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new application -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications\"" - x-wso2-request: "{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"description\": \"sample app description\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/store/v0.10/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": null,\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" - summary: | - Create a new application. - description: | - Create a new application. - parameters: - - in: body - name: body - description: | - Application object that is to be created. - required: true - schema: - $ref: '#/definitions/Application' - - $ref: '#/parameters/Content-Type' - tags: - - Application (individual) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Application' - headers: - Location: - description: | - Location of the newly created Application. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 409: - description: | - Conflict. - Application already exists. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Application" resource APIs -###################################################### - '/applications/{applicationId}': - -#----------------------------------------------------- -# Retrieve the details about a certain application -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/applications/896658a0-b4ee-4535-bbfa-806c894a4015\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"callbackUrl\": null,\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\",\n \"keys\": [ {\n \"consumerKey\": \"AVoREWiB16kY_GTIzscl40GYYZQa\",\n \"consumerSecret\": \"KXQxmS8W3xDvvJH4AfR6xrhKIeIa\",\n \"keyState\": \"COMPLETED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": null,\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"3887da6d111f0429c6dff47a46e87209\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n }]\n}" - summary: | - Get application details - description: | - Get application details - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Application (individual) - responses: - 200: - description: | - OK. - Application returned. - schema: - $ref: '#/definitions/Application' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a certain application -#----------------------------------------------------- - put: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" - x-wso2-request: "{\n \"groupId\": null,\n \"callbackUrl\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Bronze\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description updated\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Bronze\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description updated\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" - summary: | - Update application details - description: | - Update application details - parameters: - - $ref: '#/parameters/applicationId' - - in: body - name: body - description: | - Application object that needs to be updated - required: true - schema: - $ref: '#/definitions/Application' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (individual) - responses: - 200: - description: | - OK. - Application updated. - schema: - $ref: '#/definitions/Application' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain application -#----------------------------------------------------- - delete: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -X DELETE \"http://127.0.0.1:9763/api/am/store/v0.10/applications/367a2361-8db5-4140-8133-c6c8dc7fa0c4\"" - x-wso2-response: "HTTP/1.1 200 OK" - summary: | - Remove an application - description: | - Remove an application - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Generate Keys" Processing Function resource API -###################################################### - '/applications/generate-keys': - -#----------------------------------------------------- -# Generate keys for an application -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/applications/generate-keys?applicationId=c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" - x-wso2-request: "{\n \"validityTime\": \"3600\",\n \"keyType\": \"PRODUCTION\",\n \"accessAllowDomains\": [\"ALL\"\n ]\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"consumerSecret\": \"8V7DDKtKGtuG_9GDjaOJ5sijdX0a\",\n \"consumerKey\": \"LOFL8He72MSGVil4SS_bsh9O8MQa\",\n \"keyState\": \"APPROVED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": [\n \"urn:ietf:params:oauth:grant-type:saml2-bearer\",\n \"iwa:ntlm\",\n \"refresh_token\",\n \"client_credentials\",\n \"password\"\n ],\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"fd2cdc4906fbc162e033d57f85a71c21\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n}" - description: | - Generate keys for application - summary: | - Generate keys for application - parameters: - - $ref: '#/parameters/applicationId-Q' - - in: body - name: body - description: | - Application object the keys of which are to be generated - required: true - schema: - $ref: '#/definitions/ApplicationKeyGenerateRequest' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (individual) - responses: - 200: - description: | - OK. - Keys are generated. - schema: - $ref: '#/definitions/ApplicationKey' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests.‚ - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Subscription Collection" resource APIs -###################################################### - /subscriptions: - -#----------------------------------------------------- -# Retrieve all subscriptions of a certain API and application -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"03b8ef2b-5ae5-41f5-968e-52fa7fbd5d33\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"5ed42650-9f5e-4dd4-94f3-3f09f1b17354\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"846118a5-3b25-4c22-a983-2d0278936f09\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" - summary: | - Get subscription list. - description: | - Get subscription list. - The API Identifier or Application Identifier - the subscriptions of which are to be returned are passed as parameters. - parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/applicationId-Q' - - $ref: '#/parameters/groupId' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Subscription Collection - responses: - 200: - description: | - OK. - Subscription list returned. - schema: - $ref: '#/definitions/SubscriptionList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new subscription -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -H \"Content-Type: application/json\" -X POST -d @data.json \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions\"" - x-wso2-request: "{\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"c43a325c-260b-4302-81cb-768eafaa3aed\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: http://localhost:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" - summary: | - Add a new subscription - description: | - Add a new subscription - parameters: - - in: body - name: body - description: | - Subscription object that should to be added - required: true - schema: - $ref: '#/definitions/Subscription' - - $ref: '#/parameters/Content-Type' - tags: - - Subscription (individual) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Subscription' - headers: - Location: - description: | - Location to the newly created subscription. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Subscription" resource APIs -###################################################### - '/subscriptions/{subscriptionId}': - -#----------------------------------------------------- -# Retrieve a certain subscription -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" - description: | - Get subscription details - summary: | - Get subscription details - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Subscription (individual) - responses: - 200: - description: | - OK. - Subscription returned - schema: - $ref: '#/definitions/Subscription' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: 'Entity Tag of the response resource. Used by caches, or in conditional requests.' - type: string - Last-Modified: - description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.' - type: string - '304': - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - '404': - description: | - Not Found. - Requested Subscription does not exist. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain subscription -#----------------------------------------------------- - delete: - x-scope: apim:subscribe - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" -X DELETE \"http://127.0.0.1:9763/api/am/store/v0.10/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" - x-wso2-response: "HTTP/1.1 200 OK" - summary: | - Remove subscription - description: | - Remove subscription - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Subscription (individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tier Collection" resource APIs -###################################################### - /tiers/{tierLevel}: - -#----------------------------------------------------- -# Retrieve the list of all available tiers -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tiers/api\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"count\": 4,\n \"next\": \"\"\n}" - description: | - Get available tiers - summary: | - Get available tiers - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Tier Collection - responses: - 200: - description: | - OK. - List of tiers returned. - schema: - type: array - items: - $ref: '#/definitions/TierList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Tier" resource APIs -###################################################### - '/tiers/{tierLevel}/{tierName}': - -#----------------------------------------------------- -# Retrieve a certain tier -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tiers/api/Bronze\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" - description: | - Get tier details - summary: | - Get tier details - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Tier (individual) - responses: - 200: - description: | - OK. - Tier returned - schema: - $ref: '#/definitions/Tier' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Tier does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tag Collection" resource API -###################################################### - /tags: - -#----------------------------------------------------- -# Retrieve the list of tags qualifying under a search condition -#----------------------------------------------------- - get: - x-wso2-curl: "curl -H \"Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d\" \"http://127.0.0.1:9763/api/am/store/v0.10/tags\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"weight\": 1,\n \"name\": \"mobile\"\n },\n {\n \"weight\": 1,\n \"name\": \"multimedia\"\n },\n {\n \"weight\": 1,\n \"name\": \"phone\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - description: | - Get a list of tags that are already added to APIs - summary: | - Get a list of tags that are already added to APIs - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Tag Collection - responses: - 200: - description: | - OK. - Tag list is returned. - schema: - $ref: '#/definitions/TagList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# Parameters - required by some of the APIs above -###################################################### -parameters: - -# Requested Tenant domain -# Specified as a header parameter - requestedTenant: - name: X-WSO2-Tenant - in: header - description: | - For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be - retirieved from. - required: false - type: string - -# API Identifier -# Specified as part of the path expression - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. - Should be formatted as **provider-name-version**. - required: true - type: string - -# API Identifier -# Specified as part of the query string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - type: string - - -# Document Identifier -# Specified as part of the path expression - documentId: - name: documentId - in: path - description: | - **Document Identifier** - required: true - type: string - -# Application Identifier -# Specified as part of the path expression - applicationId: - name: applicationId - in: path - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - type: string - -# Application Identifier -# Specified as part of the query string - applicationId-Q: - name: applicationId - in: query - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - type: string - -# Group Identifier of the application - groupId: - name: groupId - in: query - description: | - Application Group Id - required: false - type: string - -# Subscription Identifier -# Specified as part of the path expression - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - type: string - -# Tier Name -# Specified as part of the path expression - tierName: - name: tierName - in: path - description: | - Tier name - required: true - type: string - -# Tier Type -# Specified as part of the path expression - tierLevel: - name: tierLevel - in: path - description: | - List API or Application type tiers. - type: string - enum: - - api - - application - required: true - -# Used for pagination: -# The maximum number of resoures to be returned by a GET - limit: - name: limit - in: query - description: | - Maximum size of resource array to return. - default: 25 - type: integer - -# Used for pagination: -# The order number of an instance in a qualified set of resoures -# at which to start to return the next batch of qualified resources - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - default: 0 - type: integer - -# The HTTP Accept header - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is JSON. - default: JSON - type: string - -# The HTTP Content-Type header - Content-Type: - name: Content-Type - in: header - description: | - Media type of the entity in the body. Default is JSON. - default: JSON - required: true - type : string - -# The HTTP If-None-Match header -# Used to avoid retrieving data that are already cached - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resourec. - type : string - -# The HTTP If-Modified-Since header -# Used to avoid retrieving data that are already cached - If-Modified-Since: - name: If-Modified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header of the - formerly retrieved variant of the resource. - type: string - -# The HTTP If-Match header -# Used to avoid concurrent updates - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag. - type: string - -# The HTTP If-Unmodified-Since header -# Used to avoid concurrent updates - If-Unmodified-Since: - name: If-Unmodified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header. - type: string - -###################################################### -# The resources used by some of the APIs above within the message body -###################################################### -definitions: - -#----------------------------------------------------- -# The API List resource -#----------------------------------------------------- - APIList: - title: API List - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis?limit=1&offset=2&query=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis?limit=1&offset=0&query=" - list: - type: array - items: - $ref: '#/definitions/APIInfo' - -#----------------------------------------------------- -# The API Info resource -#----------------------------------------------------- - APIInfo: - title: API Info object with basic API details. - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - type: string - example: admin - status: - type: string - example: PUBLISHED - -#----------------------------------------------------- -# The API resource -#----------------------------------------------------- - API: - title: API object - required: - - name - - context - - version - - provider - - status - - apiDefinition - properties: - id: - type: string - description: | - UUID of the api registry artifact - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given user invoking the api will be used as the provider. - type: string - example: admin - apiDefinition: - description: | - Swagger definition of the API which contains details about URI templates and scopes - type: string - example: "" - wsdlUri: - description: | - WSDL URL if the API is based on a WSDL endpoint - type: string - example: "http://www.webservicex.com/globalweather.asmx?wsdl" - status: - type: string - example: PUBLISHED - isDefaultVersion: - type: boolean - example: false - transport: - type: array - items: - description: | - Supported transports for the API (http and/or https). - type: string - example: ["http","https"] - tags: - type: array - items: - type: string - example: ["substract","add"] - tiers: - type: array - items: - type: string - example: ["Unlimited"] - thumbnailUrl: - type: string - example: "" - endpointURLs: - type: array - items: - properties: - environmentName: - type: string - example: Production and Sandbox - environmentType: - type: string - example: hybrid - environmentURLs: - properties: - http: - type: string - description: HTTP environment URL - example: "http://192.168.56.1:8280/phoneverify/1.0.0" - https: - type: string - description: HTTPS environment URL - example: "https://192.168.56.1:8243/phoneverify/1.0.0" - businessInformation: - properties: - businessOwner: - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - -#----------------------------------------------------- -# The Application List resource -#----------------------------------------------------- - ApplicationList: - title: Application List - properties: - count: - type: integer - description: | - Number of applications returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/applications?limit=1&offset=2&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/applications?limit=1&offset=0&groupId=" - list: - type: array - items: - $ref: '#/definitions/ApplicationInfo' - -#----------------------------------------------------- -# The Application resource -#----------------------------------------------------- - Application: - title: Application - required: - - name - - throttlingTier - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - description: | - If subscriber is not given user invoking the API will be taken as the subscriber. - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - callbackUrl: - type: string - example: "" - description: - type: string - example: Sample calculator application - status: - type: string - example: APPROVED - default: "" - groupId: - type: string - example: "" - keys: - type: array - items: - $ref: '#/definitions/ApplicationKey' - example: [] - -#----------------------------------------------------- -# The Application Info resource -#----------------------------------------------------- - ApplicationInfo: - title: Application info object with basic application details - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - description: - type: string - example: Sample calculator application - status: - type: string - example: APPROVED - groupId: - type: string - example: "" - -#----------------------------------------------------- -# The Document List resource -#----------------------------------------------------- - DocumentList: - title: Document List - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Document' - -#----------------------------------------------------- -# The Document resource -#----------------------------------------------------- - Document: - title: Document - required: - - name - - type - - sourceType - properties: - documentId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorDoc - type: - type: string - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - example: HOWTO - summary: - type: string - example: "Summary of Calculator Documentation" - sourceType: - type: string - enum: - - INLINE - - URL - - FILE - example: INLINE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - -#----------------------------------------------------- -# The Tier List resource -#----------------------------------------------------- - TierList: - title: Tier List - properties: - count: - type: integer - description: | - Number of Tiers returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tiers/api?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tiers/api?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tier' - -#----------------------------------------------------- -# The Tier resource -#----------------------------------------------------- - Tier: - title: Tier - required: - - name - - tierPlan - - requestCount - - unitTime - - stopOnQuotaReach - properties: - name: - type: string - example: Platinum - description: - type: string - example: "Allows 50 request(s) per minute." - tierLevel: - type: string - enum: - - api - - application - example: api - attributes: - description: | - Custom attributes added to the tier policy - type: object - additionalProperties: - type: string - example: {} - requestCount: - description: | - Maximum number of requests which can be sent within a provided unit time - type: integer - format: int64 - example: 50 - unitTime: - type: integer - format: int64 - example: 60000 - tierPlan: - description: | - This attribute declares whether this tier is available under commercial or free - type: string - enum: - - FREE - - COMMERCIAL - example: FREE - stopOnQuotaReach: - description: | - If this attribute is set to false, you are capabale of sending requests - even if the request count exceeded within a unit time - type: boolean - example: true - -#----------------------------------------------------- -# The Subscription List resource -#----------------------------------------------------- - SubscriptionList: - title: Subscription List - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" - list: - type: array - items: - $ref: '#/definitions/Subscription' - -#----------------------------------------------------- -# The Subscription resource -#----------------------------------------------------- - Subscription: - title: Subscription - required: - - applicationId - - apiIdentifier - - tier - properties: - subscriptionId: - type: string - example: 01234567-0123-0123-0123-012345678901 - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - apiIdentifier: - type: string - example: 01234567-0123-0123-0123-012345678901 - tier: - type: string - example: Unlimited - status: - type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - example: UNBLOCKED - -#----------------------------------------------------- -# The Tag resource -#----------------------------------------------------- - Tag: - title: Tag - required: - - name - - weight - properties: - name: - type: string - example: tag1 - weight: - type: integer - example: 5 - -#----------------------------------------------------- -# The Tag List resource -#----------------------------------------------------- - TagList: - title: Tag List - properties: - count: - type: integer - description: | - Number of Tags returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tags?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tags?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tag' - -#----------------------------------------------------- -# The Error resource -#----------------------------------------------------- - Error: - title: Error object returned with 4XX HTTP status - required: - - code - - message - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/definitions/ErrorListItem' - -#----------------------------------------------------- -# The Error List Item resource -#----------------------------------------------------- - ErrorListItem: - title: Description of individual errors that may have occurred during a request. - required: - - code - - message - properties: - code: - type: string - message: - type: string - description: | - Description about individual errors occurred - -#----------------------------------------------------- -# The Token resource -#----------------------------------------------------- - Token : - title: Token details for invoking APIs - properties: - accessToken: - type: string - description: Access token - example: 01234567890123456789012345678901 - tokenScopes: - type: array - items: - type: string - description: Valid scopes for the access token - example: ["default"] - validityTime: - type: integer - format: int64 - description: Maximum validity time for the access token - example: 3600 - -#----------------------------------------------------- -# The Application Key resource -#----------------------------------------------------- - ApplicationKey : - title: Application key details - properties: - consumerKey: - type: string - description: Consumer key of the application - example: vYDoc9s7IgAFdkSyNDaswBX7ejoa - consumerSecret: - type: string - description: Consumer secret of the application - example: TIDlOFkpzB7WjufO3OJUhy1fsvAa - supportedGrantTypes: - type: array - items: - type: string - description: Supported grant types for the application - example: ["client_credentials","password"] - keyState: - type: string - description: State of the key generation of the application - example: APPROVED - keyType: - description: Key type - type: string - enum: - - PRODUCTION - - SANDBOX - example: PRODUCTION - token: - $ref: '#/definitions/Token' - -#----------------------------------------------------- -# The Application Key Generation Request schema -#----------------------------------------------------- - ApplicationKeyGenerateRequest : - title: Application key generation request object - required: - - keyType - - validityTime - - accessAllowDomains - properties: - keyType: - type: string - enum: - - PRODUCTION - - SANDBOX - example: PRODUCTION - validityTime: - type: string - example: 3600 - callbackUrl: - type: string - description: Callback URL - example: "" - accessAllowDomains: - type: array - items: - type: string - description: Allowed domains for the access token - example: ["ALL"] - scopes: - type: array - items: - type: string - description: Allowed scopes for the access token - example: ["am_application_scope","default"] - -#----------------------------------------------------- -# END-OF-FILE -#----------------------------------------------------- diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index cde47a7f605..f94e8bad157 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -47,14 +47,6 @@ org.testng testng - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - org.wso2.tomcat tomcat @@ -111,6 +103,10 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.integration.client + @@ -147,22 +143,30 @@ com.google.gson.*, org.apache.catalina, org.apache.catalina.core, - org.wso2.carbon.apimgt.api, - org.wso2.carbon.apimgt.api.model, - org.wso2.carbon.apimgt.impl, org.apache.axis2.*;version="${axis2.osgi.version.range}", org.wso2.carbon.core, org.apache.commons.lang, org.wso2.carbon.utils, org.wso2.carbon.apimgt.annotations.*, org.wso2.carbon.governance.lcm.util.*, - org.wso2.carbon.registry.core.* + org.wso2.carbon.registry.core.*, + io.swagger.annotations, + javax.net.ssl, + org.scannotation, + org.scannotation.archiveiterator, + org.w3c.dom, + org.wso2.carbon.apimgt.integration.client.*, + org.wso2.carbon.context, + org.wso2.carbon.core.util, + org.wso2.carbon.user.api, + org.wso2.carbon.user.core.*, + org.wso2.carbon.utils.multitenancy javax.ws.rs-api, scribe;scope=compile|runtime;inline=false; - * + * diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java index 02200f1c763..ca020bd83a6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java @@ -18,17 +18,11 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.APIProvider; -import org.wso2.carbon.apimgt.api.model.URITemplate; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiScope; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; -import java.util.List; import java.util.Set; /** @@ -53,26 +47,16 @@ public class APIConfig { private String name; private String owner; private String context; - private String contextTemplate; private String endpoint; private String version; private String policy; private String transports; - private APIProvider provider; private boolean isSecured; - private Set uriTemplates; - private List tenants; + private Set uriTemplates; private boolean isSharedWithAllTenants; private String tenantDomain; private String[] tags; - - public void init() throws APIManagementException { - try { - this.provider = APIManagerFactory.getInstance().getAPIProvider(owner); - } catch (APIManagementException e) { - throw new APIManagementException("Error occurred while initializing API provider", e); - } - } + private Set scopes; @XmlElement(name = "Policy", required = true) public String getPolicy() { @@ -84,20 +68,6 @@ public class APIConfig { this.policy = policy; } - @XmlElement(name = "ContextTemplate", required = true) - public String getContextTemplate() { - return contextTemplate; - } - - public void setContextTemplate(String contextTemplate) { - this.contextTemplate = contextTemplate; - } - - @XmlTransient - public APIProvider getProvider() { - return provider; - } - @XmlElement(name = "Name", required = true) public String getName() { return name; @@ -168,12 +138,12 @@ public class APIConfig { } @XmlElement(name = "UriTemplates", required = false) - public Set getUriTemplates() { + public Set getUriTemplates() { return uriTemplates; } @SuppressWarnings("unused") - public void setUriTemplates(Set uriTemplates) { + public void setUriTemplates(Set uriTemplates) { this.uriTemplates = uriTemplates; } @@ -206,4 +176,12 @@ public class APIConfig { public void setTags(String[] tags) { this.tags = tags; } + + public Set getScopes() { + return scopes; + } + + public void setScopes(Set scopes) { + this.scopes = scopes; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java index de3cc18668a..81a3a608594 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java @@ -18,18 +18,12 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.FaultGatewaysException; -import org.wso2.carbon.apimgt.api.model.API; -import org.wso2.carbon.apimgt.api.model.APIIdentifier; -import java.util.List; + +import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; /** * This interface represents all methods related to API manipulation that's done as part of API-Management tasks. * - * Note: Ideally, this has to come from the API-Management components. However, due to lack of clean APIs - * (as OSGi declarative services, etc) provided for API publishing and related tasks, this was introduced at the device - * management core implementation layer. */ public interface APIPublisherService { @@ -37,8 +31,8 @@ public interface APIPublisherService { * This method registers an API within the underlying API-Management infrastructure. * * @param api An instance of the bean that passes metadata related to the API being published - * @throws APIManagementException Is thrown if some unexpected event occurs while publishing the API + * @throws APIManagerPublisherException Is thrown if some unexpected event occurs while publishing the API */ - void publishAPI(API api) throws APIManagementException, FaultGatewaysException; + void publishAPI(APIConfig api) throws APIManagerPublisherException; } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 14a922b355d..ee4801f5454 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -18,28 +18,15 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.APIProvider; -import org.wso2.carbon.apimgt.api.FaultGatewaysException; -import org.wso2.carbon.apimgt.api.model.*; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; +import feign.FeignException; +import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; +import org.wso2.carbon.apimgt.integration.client.publisher.model.*; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; +import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; +import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.governance.lcm.util.CommonUtil; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; - -import javax.xml.stream.XMLStreamException; -import java.io.FileNotFoundException; import java.util.*; /** @@ -47,176 +34,116 @@ import java.util.*; * API publishing related operations. */ public class APIPublisherServiceImpl implements APIPublisherService { - - private static final Log log = LogFactory.getLog(APIPublisherServiceImpl.class); + private static final String UNLIMITED_TIER = "Unlimited"; + private static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; + private static final String CONTENT_TYPE = "application/json"; + private static final String PUBLISHED_STATUS = "PUBLISHED"; + private static final String CREATED_STATUS = "CREATED"; private static final String PUBLISH_ACTION = "Publish"; @Override - public void publishAPI(final API api) throws APIManagementException, FaultGatewaysException { - String tenantDomain = MultitenantUtils.getTenantDomain(api.getApiOwner()); + public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException { + String tenantDomain = MultitenantUtils.getTenantDomain(apiConfig.getOwner()); PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner()); try { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - // Below code snippet is added to load API Lifecycle in tenant mode. - RegistryService registryService = APIPublisherDataHolder.getInstance().getRegistryService(); - CommonUtil.addDefaultLifecyclesIfNotAvailable(registryService.getConfigSystemRegistry(tenantId), - CommonUtil.getRootSystemRegistry(tenantId)); - APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(api.getApiOwner()); - MultitenantUtils.getTenantDomain(api.getApiOwner()); - processHttpVerbs(api); - if (provider != null) { - if (provider.isDuplicateContextTemplate(api.getContext())) { - throw new APIManagementException( - "Error occurred while adding the API. A duplicate API" + - " context already exists for " + api.getContext()); + PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService() + .getPublisherClient(); + API api = getAPI(apiConfig); + APIList apiList = publisherClient.getApi().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null); + + if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) { + api = publisherClient.getApi().apisPost(api, CONTENT_TYPE); + if (CREATED_STATUS.equals(api.getStatus())) { + publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); } - if (!provider.isAPIAvailable(api.getId())) { - provider.addAPI(api); - provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION); - if (log.isDebugEnabled()) { - log.debug("Successfully published API '" + api.getId().getApiName() + - "' with context '" + api.getContext() + "' and version '" - + api.getId().getVersion() + "'"); - } - } else { - if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { - if (provider.getAPI(api.getId()).getStatus() == APIStatus.CREATED) { - provider.changeLifeCycleStatus(api.getId(), PUBLISH_ACTION); - } - api.setStatus(APIStatus.PUBLISHED); - provider.updateAPI(api); - if (log.isDebugEnabled()) { - log.debug("An API already exists with the name '" + api.getId().getApiName() + - "', context '" + api.getContext() + "' and version '" - + api.getId().getVersion() + "'. Thus, the API config is updated"); + } else { + if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { + for (APIInfo apiInfo : apiList.getList()) { + if (api.getVersion().equals(apiInfo.getVersion())) { + api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, + null); + if (CREATED_STATUS.equals(api.getStatus())) { + publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, + null); + } } + } } - provider.saveSwagger20Definition(api.getId(), createSwaggerDefinition(api)); - } else { - throw new APIManagementException("API provider configured for the given API configuration " + - "is null. Thus, the API is not published"); } - } catch (FileNotFoundException e) { - throw new APIManagementException("Failed to retrieve life cycle file ", e); - } catch (RegistryException e) { - throw new APIManagementException("Failed to access the registry ", e); - } catch (XMLStreamException e) { - throw new APIManagementException("Failed parsing the lifecycle xml.", e); + } catch (FeignException e) { + throw new APIManagerPublisherException(e); } finally { PrivilegedCarbonContext.endTenantFlow(); } } - private String createSwaggerDefinition(API api) { - Map httpVerbsMap = new HashMap<>(); - List scopes = new ArrayList<>(); - - for (URITemplate uriTemplate : api.getUriTemplates()) { - JsonObject response = new JsonObject(); - response.addProperty("200", ""); - - JsonObject responses = new JsonObject(); - responses.add("responses", response); - JsonObject httpVerbs = httpVerbsMap.get(uriTemplate.getUriTemplate()); - if (httpVerbs == null) { - httpVerbs = new JsonObject(); - } - JsonObject httpVerb = new JsonObject(); - httpVerb.add("responses", response); - - httpVerb.addProperty("x-auth-type", "Application%20%26%20Application%20User"); - httpVerb.addProperty("x-throttling-tier", "Unlimited"); - if (uriTemplate.getScope() != null) { - httpVerb.addProperty("x-scope", uriTemplate.getScope().getName()); - scopes.add(uriTemplate.getScope()); - } - httpVerbs.add(uriTemplate.getHTTPVerb().toLowerCase(), httpVerb); - httpVerbsMap.put(uriTemplate.getUriTemplate(), httpVerbs); - } - - Iterator it = httpVerbsMap.entrySet().iterator(); - JsonObject paths = new JsonObject(); - while (it.hasNext()) { - Map.Entry pair = (Map.Entry) it.next(); - paths.add(pair.getKey(), pair.getValue()); - it.remove(); - } - - JsonObject info = new JsonObject(); - info.addProperty("title", api.getId().getApiName()); - info.addProperty("version", api.getId().getVersion()); - - JsonObject swaggerDefinition = new JsonObject(); - swaggerDefinition.add("paths", paths); - swaggerDefinition.addProperty("swagger", "2.0"); - swaggerDefinition.add("info", info); - - // adding scopes to swagger definition - if (!api.getScopes().isEmpty()) { - Gson gson = new Gson(); - JsonElement element = gson.toJsonTree(api.getScopes(), new TypeToken>() { - }.getType()); - if (element != null) { - JsonArray apiScopes = element.getAsJsonArray(); - JsonObject apim = new JsonObject(); - apim.add("x-wso2-scopes", apiScopes); - JsonObject wso2Security = new JsonObject(); - wso2Security.add("apim", apim); - swaggerDefinition.add("x-wso2-security", wso2Security); - } - } - if (log.isDebugEnabled()) { - log.debug("API swagger definition: " + swaggerDefinition.toString()); - } - return swaggerDefinition.toString(); - } - - /** - * Sometimes the httpVerb string attribute is not existing in - * the list of httpVerbs attribute of uriTemplate. In such cases when creating the api in the - * synapse configuration, it doesn't have http methods correctly assigned for the resources. - * Therefore this method takes care of such inconsistency issue. - * - * @param api The actual API model object - */ - private void processHttpVerbs(API api) { - for (URITemplate uriTemplate : api.getUriTemplates()) { - String httpVerbString = uriTemplate.getHTTPVerb(); - if (httpVerbString != null && !httpVerbString.isEmpty()) { - uriTemplate.setHttpVerbs(httpVerbString); - } - } - } + private API getAPI(APIConfig config) { - @Override - public void removeAPI(APIIdentifier id) throws APIManagementException { - if (log.isDebugEnabled()) { - log.debug("Removing API '" + id.getApiName() + "'"); - } - APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(id.getProviderName()); - provider.deleteAPI(id); - if (log.isDebugEnabled()) { - log.debug("API '" + id.getApiName() + "' has been successfully removed"); - } - } + API api = new API(); + api.setName(config.getName()); + api.setDescription(""); - @Override - public void publishAPIs(List apis) throws APIManagementException, FaultGatewaysException { - if (log.isDebugEnabled()) { - log.debug("Publishing a batch of APIs"); - } - for (API api : apis) { - try { - this.publishAPI(api); - } catch (APIManagementException e) { - log.error("Error occurred while publishing API '" + api.getId().getApiName() + "'", e); - } + String context = config.getContext(); + context = context.startsWith("/") ? context : ("/" + context); + String providerDomain = config.getTenantDomain(); + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(providerDomain)) { + //Create tenant aware context for API + context = "/t/" + providerDomain + context; } - if (log.isDebugEnabled()) { - log.debug("End of publishing the batch of APIs"); + api.setContext(context); + api.setVersion(config.getVersion()); + api.setProvider(config.getOwner()); + api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config)); + api.setWsdlUri(null); + api.setStatus(PUBLISHED_STATUS); + api.responseCaching("DISABLED"); + api.destinationStatsEnabled("false"); + api.isDefaultVersion(true); + List transport = new ArrayList<>(); + transport.add("https"); + transport.add("http"); + api.transport(transport); + api.setTags(Arrays.asList(config.getTags())); + api.addTiersItem(UNLIMITED_TIER); + api.setGatewayEnvironments(API_PUBLISH_ENVIRONMENT); + if (config.isSharedWithAllTenants()) { + api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.all_tenants); + api.setVisibility(API.VisibilityEnum.PUBLIC); + } else { + api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.current_tenant); + api.setVisibility(API.VisibilityEnum.PRIVATE); } + String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + + "\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}"; + + + api.setEndpointConfig(endpointConfig); + APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration(); + List accessControlAllowOrigins = new ArrayList<>(); + accessControlAllowOrigins.add("*"); + apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins); + + List accessControlAllowHeaders = new ArrayList<>(); + accessControlAllowHeaders.add("authorization"); + accessControlAllowHeaders.add("Access-Control-Allow-Origin"); + accessControlAllowHeaders.add("Content-Type"); + accessControlAllowHeaders.add("SOAPAction"); + apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders); + + List accessControlAllowMethods = new ArrayList<>(); + accessControlAllowMethods.add("GET"); + accessControlAllowMethods.add("PUT"); + accessControlAllowMethods.add("DELETE"); + accessControlAllowMethods.add("POST"); + accessControlAllowMethods.add("PATCH"); + accessControlAllowMethods.add("OPTIONS"); + apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods); + apiCorsConfiguration.setAccessControlAllowCredentials(false); + apiCorsConfiguration.corsConfigurationEnabled(false); + api.setCorsConfiguration(apiCorsConfiguration); + return api; } - } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index df9102e3513..928b6d22be8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -21,7 +21,7 @@ package org.wso2.carbon.apimgt.webapp.publisher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.model.API; +import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.core.ServerStartupObserver; @@ -33,8 +33,8 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static int retryTime = 2000; private static final int CONNECTION_RETRY_FACTOR = 2; private static final int MAX_RETRY_COUNT = 5; - private static Stack failedAPIsStack = new Stack<>(); - private static Stack currentAPIsStack; + private static Stack failedAPIsStack = new Stack<>(); + private static Stack currentAPIsStack; private APIPublisherService publisher; @@ -64,7 +64,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { } catch (InterruptedException te) { //do nothing. } - Stack failedApis; + Stack failedApis; if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { publishAPIs(currentAPIsStack, failedAPIsStack); failedApis = failedAPIsStack; @@ -77,8 +77,8 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { StringBuilder error = new StringBuilder(); error.append("Error occurred while publishing API ['"); while (!failedApis.isEmpty()) { - API api = failedApis.pop(); - error.append(api.getId().getApiName() + ","); + APIConfig api = failedApis.pop(); + error.append(api.getName() + ","); } error.append("']"); log.error(error.toString()); @@ -90,12 +90,13 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { t.start(); } - private void publishAPIs(Stack apis, Stack failedStack) { + private void publishAPIs(Stack apis, Stack failedStack) { while (!apis.isEmpty()) { - API api = apis.pop(); + APIConfig api = apis.pop(); try { publisher.publishAPI(api); - } catch (Exception e) { + } catch (APIManagerPublisherException e) { + log.error("failed to publish api.", e); failedStack.push(api); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 8ae3c531c19..839658ec2a1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -18,22 +18,24 @@ package org.wso2.carbon.apimgt.webapp.publisher; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.APIProvider; -import org.wso2.carbon.apimgt.api.model.*; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiScope; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate; import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.servlet.ServletContext; import java.util.*; @@ -41,7 +43,6 @@ import java.util.*; public class APIPublisherUtil { public static final String API_VERSION_PARAM = "{version}"; - public static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; private static final Log log = LogFactory.getLog(APIPublisherUtil.class); private static final String DEFAULT_API_VERSION = "1.0.0"; private static final String API_CONFIG_DEFAULT_VERSION = "1.0.0"; @@ -55,101 +56,6 @@ public class APIPublisherUtil { private static final String NON_SECURED_RESOURCES = "nonSecuredEndPoints"; private static final String AUTH_TYPE_NON_SECURED = "None"; - - public static API getAPI(APIConfig config) throws APIManagementException { - - APIProvider provider = config.getProvider(); - String apiVersion = config.getVersion(); - APIIdentifier id = new APIIdentifier(replaceEmailDomain(config.getOwner()), config.getName(), apiVersion); - API api = new API(id); - - api.setApiOwner(config.getOwner()); - String context = config.getContext(); - context = context.startsWith("/") ? context : ("/" + context); - String providerDomain = config.getTenantDomain(); - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(providerDomain)) { - //Create tenant aware context for API - context = "/t/" + providerDomain + context; - } - - // This is to support the new Pluggable version strategy - // if the context does not contain any {version} segment, we use the default version strategy. - context = checkAndSetVersionParam(context); - api.setContextTemplate(context); - context = updateContextWithVersion(config.getVersion(), context); - api.setContext(context); - - api.setUrl(config.getEndpoint()); - api.addAvailableTiers(provider.getTiers()); - api.setEndpointSecured(false); - api.setStatus(APIStatus.CREATED); - api.setTransports(config.getTransports()); - api.setApiLevelPolicy(config.getPolicy()); - api.setContextTemplate(config.getContextTemplate()); - Set environments = new HashSet<>(); - environments.add(API_PUBLISH_ENVIRONMENT); - api.setEnvironments(environments); - Set tiers = new HashSet<>(); - - tiers.add(new Tier(APIConstants.UNLIMITED_TIER)); - api.addAvailableTiers(tiers); - - if (config.isSharedWithAllTenants()) { - api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_ALL_TENANTS); - api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY); - } else { - api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT); - api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY); - } - api.setResponseCache(APIConstants.DISABLED); - - String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + - "\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}"; - - api.setEndpointConfig(endpointConfig); - - if ("".equals(id.getVersion()) || (DEFAULT_API_VERSION.equals(id.getVersion()))) { - api.setAsDefaultVersion(Boolean.TRUE); - api.setAsPublishedDefaultVersion(Boolean.TRUE); - } - if (config.getTags() != null && config.getTags().length > 0) { - Set tags = new HashSet<>(Arrays.asList(config.getTags())); - api.addTags(tags); - } - - // adding scopes to the api - Set uriTemplates = config.getUriTemplates(); - Map apiScopes = new HashMap<>(); - if (uriTemplates != null) { - // this creates distinct scopes list - for (URITemplate template : uriTemplates) { - Scope scope = template.getScope(); - if (scope != null) { - if (apiScopes.get(scope.getKey()) == null) { - apiScopes.put(scope.getKey(), scope); - } - } - } - Set scopes = new HashSet<>(apiScopes.values()); - // set current scopes to API - api.setScopes(scopes); - - // this has to be done because of the use of pass by reference - // where same object reference of scope should be available for both - // api scope and uri template scope - for (Scope scope : scopes) { - for (URITemplate template : uriTemplates) { - if (template.getScope() != null && scope.getKey().equals(template.getScope().getKey())) { - template.setScope(scope); - } - } - } - api.setUriTemplates(uriTemplates); - } - api.setCorsConfiguration(APIUtil.getDefaultCorsConfiguration()); - return api; - } - public static String getServerBaseUrl() { WebappPublisherConfig webappPublisherConfig = WebappPublisherConfig.getInstance(); return Utils.replaceSystemProperty(webappPublisherConfig.getHost()); @@ -159,39 +65,6 @@ public class APIPublisherUtil { return getServerBaseUrl() + context; } - /** - * When an input is having '@',replace it with '-AT-' - * [This is required to persist API data in registry,as registry paths don't allow '@' sign.] - * - * @param input inputString - * @return String modifiedString - */ - private static String replaceEmailDomain(String input) { - if (input != null && input.contains(APIConstants.EMAIL_DOMAIN_SEPARATOR)) { - input = input.replace(APIConstants.EMAIL_DOMAIN_SEPARATOR, APIConstants.EMAIL_DOMAIN_SEPARATOR_REPLACEMENT); - } - return input; - } - - private static String updateContextWithVersion(String version, String context) { - // This condition should not be true for any occasion but we keep it so that there are no loopholes in - // the flow. - context = context.replace(API_VERSION_PARAM, version); - return context; - } - - private static String checkAndSetVersionParam(String context) { - // This is to support the new Pluggable version strategy - // if the context does not contain any {version} segment, we use the default version strategy. - if (!context.contains(API_VERSION_PARAM)) { - if (!context.endsWith("/")) { - context = context + "/"; - } - context = context + API_VERSION_PARAM; - } - return context; - } - /** * Build the API Configuration to be passed to APIM, from a given list of URL templates * @@ -245,11 +118,6 @@ public class APIPublisherUtil { tenantDomain = (tenantDomain != null && !tenantDomain.isEmpty()) ? tenantDomain : MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; apiConfig.setTenantDomain(tenantDomain); - String contextTemplate = context + "/" + APIConstants.VERSION_PLACEHOLDER; - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - contextTemplate = context + "/t/" + tenantDomain + "/" + APIConstants.VERSION_PLACEHOLDER; - } - apiConfig.setContextTemplate(contextTemplate); String endpoint = servletContext.getInitParameter(PARAM_MANAGED_API_ENDPOINT); if (endpoint == null || endpoint.isEmpty()) { @@ -292,17 +160,33 @@ public class APIPublisherUtil { } apiConfig.setSharedWithAllTenants(isSharedWithAllTenants); - Set uriTemplates = new LinkedHashSet<>(); + Set uriTemplates = new LinkedHashSet<>(); for (APIResource apiResource : apiDef.getResources()) { - URITemplate template = new URITemplate(); + ApiUriTemplate template = new ApiUriTemplate(); template.setAuthType(apiResource.getAuthType()); - template.setHTTPVerb(apiResource.getHttpVerb()); + template.setHttpVerb(apiResource.getHttpVerb()); template.setResourceURI(apiResource.getUri()); template.setUriTemplate(apiResource.getUriTemplate()); template.setScope(apiResource.getScope()); uriTemplates.add(template); } apiConfig.setUriTemplates(uriTemplates); + // adding scopes to the api + Map apiScopes = new HashMap<>(); + if (uriTemplates != null) { + // this creates distinct scopes list + for (ApiUriTemplate template : uriTemplates) { + ApiScope scope = template.getScope(); + if (scope != null) { + if (apiScopes.get(scope.getKey()) == null) { + apiScopes.put(scope.getKey(), scope); + } + } + } + Set scopes = new HashSet<>(apiScopes.values()); + // set current scopes to API + apiConfig.setScopes(scopes); + } String policy = servletContext.getInitParameter(PARAM_MANAGED_API_POLICY); if (policy == null || policy.isEmpty()) { @@ -317,6 +201,70 @@ public class APIPublisherUtil { return apiConfig; } + public static String getSwaggerDefinition(APIConfig apiConfig) { + Map httpVerbsMap = new HashMap<>(); + List scopes = new ArrayList<>(); + + for (ApiUriTemplate uriTemplate : apiConfig.getUriTemplates()) { + JsonObject response = new JsonObject(); + response.addProperty("200", ""); + + JsonObject responses = new JsonObject(); + responses.add("responses", response); + JsonObject httpVerbs = httpVerbsMap.get(uriTemplate.getUriTemplate()); + if (httpVerbs == null) { + httpVerbs = new JsonObject(); + } + JsonObject httpVerb = new JsonObject(); + httpVerb.add("responses", response); + + httpVerb.addProperty("x-auth-type", "Application%20%26%20Application%20User"); + httpVerb.addProperty("x-throttling-tier", "Unlimited"); + if (uriTemplate.getScope() != null) { + httpVerb.addProperty("x-scope", uriTemplate.getScope().getKey()); + scopes.add(uriTemplate.getScope()); + } + httpVerbs.add(uriTemplate.getHttpVerb().toLowerCase(), httpVerb); + httpVerbsMap.put(uriTemplate.getUriTemplate(), httpVerbs); + } + + Iterator it = httpVerbsMap.entrySet().iterator(); + JsonObject paths = new JsonObject(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + paths.add(pair.getKey(), pair.getValue()); + it.remove(); + } + + JsonObject info = new JsonObject(); + info.addProperty("title", apiConfig.getName()); + info.addProperty("version", apiConfig.getVersion()); + + JsonObject swaggerDefinition = new JsonObject(); + swaggerDefinition.add("paths", paths); + swaggerDefinition.addProperty("swagger", "2.0"); + swaggerDefinition.add("info", info); + + // adding scopes to swagger definition + if (!apiConfig.getScopes().isEmpty()) { + Gson gson = new Gson(); + JsonElement element = gson.toJsonTree(apiConfig.getScopes(), new TypeToken>() { + }.getType()); + if (element != null) { + JsonArray apiScopes = element.getAsJsonArray(); + JsonObject apim = new JsonObject(); + apim.add("x-wso2-scopes", apiScopes); + JsonObject wso2Security = new JsonObject(); + wso2Security.add("apim", apim); + swaggerDefinition.add("x-wso2-security", wso2Security); + } + } + if (log.isDebugEnabled()) { + log.debug("API swagger definition: " + swaggerDefinition.toString()); + } + return swaggerDefinition.toString(); + } + public static void setResourceAuthTypes(ServletContext servletContext, APIConfig apiConfig) { List resourcesList = null; @@ -324,9 +272,9 @@ public class APIPublisherUtil { if(null != nonSecuredResources){ resourcesList = Arrays.asList(nonSecuredResources.split(",")); } - Set templates = apiConfig.getUriTemplates(); + Set templates = apiConfig.getUriTemplates(); if(null != resourcesList) { - for (URITemplate template : templates) { + for (ApiUriTemplate template : templates) { String fullPaath = ""; if( template.getUriTemplate() != AnnotationProcessor.WILD_CARD ) { fullPaath = apiConfig.getContext() + template.getUriTemplate(); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/APIResource.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/APIResource.java index 577f4efecb9..ff439e68cfb 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/APIResource.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/config/APIResource.java @@ -18,7 +18,7 @@ package org.wso2.carbon.apimgt.webapp.publisher.config; -import org.wso2.carbon.apimgt.api.model.Scope; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiScope; public class APIResource { @@ -28,7 +28,7 @@ public class APIResource { private String UriTemplate; private String consumes; private String produces; - private Scope scope; + private ApiScope scope; public String getAuthType() { return AuthType; @@ -78,11 +78,11 @@ public class APIResource { this.produces = produces; } - public Scope getScope() { + public ApiScope getScope() { return scope; } - public void setScope(Scope scope) { + public void setScope(ApiScope scope) { this.scope = scope; } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiScope.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiScope.java new file mode 100644 index 00000000000..016dbff37f0 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiScope.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.webapp.publisher.dto; + +public class ApiScope { + + String key; + String name; + String roles; + String description; + int id; + + public ApiScope() { + } + + public String getKey() { + return this.key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoles() { + return this.roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiUriTemplate.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiUriTemplate.java new file mode 100644 index 00000000000..89ef7900cc2 --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/dto/ApiUriTemplate.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.webapp.publisher.dto; + +/** + * This hold the api uri template information. + */ +public class ApiUriTemplate { + + private String authType; + private String httpVerb; + private String resourceURI; + private String uriTemplate; + private ApiScope scope; + + public ApiUriTemplate() {} + + public String getAuthType() { + return authType; + } + + public void setAuthType(String authType) { + this.authType = authType; + } + + public String getHttpVerb() { + return httpVerb; + } + + public void setHttpVerb(String httpVerb) { + this.httpVerb = httpVerb; + } + + public String getResourceURI() { + return resourceURI; + } + + public void setResourceURI(String resourceURI) { + this.resourceURI = resourceURI; + } + + public String getUriTemplate() { + return uriTemplate; + } + + public void setUriTemplate(String uriTemplate) { + this.uriTemplate = uriTemplate; + } + + public ApiScope getScope() { + return scope; + } + + public void setScope(ApiScope scope) { + this.scope = scope; + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/exception/APIManagerPublisherException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/exception/APIManagerPublisherException.java new file mode 100644 index 00000000000..b98aef3c9aa --- /dev/null +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/exception/APIManagerPublisherException.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.webapp.publisher.exception; + +/** + * Handles the exceptions related to API management. + */ +public class APIManagerPublisherException extends Exception { + + private static final long serialVersionUID = -8933142342423122660L; + + public APIManagerPublisherException(String msg, Exception nestedEx) { + super(msg, nestedEx); + } + + public APIManagerPublisherException(String message, Throwable cause) { + super(message, cause); + } + + public APIManagerPublisherException(String msg) { + super(msg); + } + + public APIManagerPublisherException() { + super(); + } + + public APIManagerPublisherException(Throwable cause) { + super(cause); + } + +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index b06bc1a4ca6..639c2fe217a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -18,8 +18,8 @@ */ package org.wso2.carbon.apimgt.webapp.publisher.internal; - -import org.wso2.carbon.apimgt.api.model.API; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +import org.wso2.carbon.apimgt.webapp.publisher.APIConfig; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; @@ -36,7 +36,8 @@ public class APIPublisherDataHolder { private TenantManager tenantManager; private RegistryService registryService; private boolean isServerStarted; - private Stack unpublishedApis = new Stack<>(); + private Stack unpublishedApis = new Stack<>(); + private IntegrationClientService integrationClientService; private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder(); @@ -108,11 +109,20 @@ public class APIPublisherDataHolder { isServerStarted = serverStarted; } - public Stack getUnpublishedApis() { + public Stack getUnpublishedApis() { return unpublishedApis; } - public void setUnpublishedApis(Stack unpublishedApis) { + public void setUnpublishedApis(Stack unpublishedApis) { this.unpublishedApis = unpublishedApis; } + + public IntegrationClientService getIntegrationClientService() { + return integrationClientService; + } + + public void setIntegrationClientService( + IntegrationClientService integrationClientService) { + this.integrationClientService = integrationClientService; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index 44c2c6d7992..dd5736570c5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; +import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler; @@ -30,16 +30,9 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; /** * @scr.component name="org.wso2.carbon.apimgt.webapp.publisher" immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" * @scr.reference name="user.realmservice.default" * interface="org.wso2.carbon.user.core.service.RealmService" * cardinality="1..1" @@ -52,6 +45,11 @@ import org.wso2.carbon.utils.ConfigurationContextService; * policy="dynamic" * bind="setRegistryService" * unbind="unsetRegistryService" + * interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService" + * cardinality="1..1" + * policy="dynamic" + * bind="setIntegrationClientService" + * unbind="unsetIntegrationClientService" */ public class APIPublisherServiceComponent { @@ -97,28 +95,6 @@ public class APIPublisherServiceComponent { bundleContext.registerService(ServerStartupObserver.class, new APIPublisherStartupHandler(), null); } - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Setting ConfigurationContextService"); - } - APIPublisherDataHolder.getInstance().setConfigurationContextService(configurationContextService); - } - - protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Un-setting ConfigurationContextService"); - } - APIPublisherDataHolder.getInstance().setConfigurationContextService(null); - } - protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); @@ -143,4 +119,15 @@ public class APIPublisherServiceComponent { protected void unsetRegistryService(RegistryService registryService) { APIPublisherDataHolder.getInstance().setRegistryService(null); } + + protected void setIntegrationClientService(IntegrationClientService integrationClientService) { + if (integrationClientService != null && log.isDebugEnabled()) { + log.debug("integrationClientService initialized"); + } + APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService); + } + + protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { + APIPublisherDataHolder.getInstance().setIntegrationClientService(null); + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index adf73f0d17b..24c73c739df 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -24,7 +24,6 @@ import org.apache.catalina.LifecycleListener; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.webapp.publisher.APIConfig; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil; @@ -77,8 +76,6 @@ public class APIPublisherLifecycleListener implements LifecycleListener { boolean isTenantActive = APIPublisherDataHolder.getInstance(). getTenantManager().isTenantActive(tenantId); if (isTenantActive) { - apiConfig.init(); - API api = APIPublisherUtil.getAPI(apiConfig); boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted(); if (isServerStarted) { APIPublisherService apiPublisherService = @@ -87,13 +84,13 @@ public class APIPublisherLifecycleListener implements LifecycleListener { throw new IllegalStateException( "API Publisher service is not initialized properly"); } - apiPublisherService.publishAPI(api); + apiPublisherService.publishAPI(apiConfig); } else { if (log.isDebugEnabled()) { log.debug("Server has not started yet. Hence adding API '" + - api.getId().getApiName() + "' to the queue"); + apiConfig.getName() + "' to the queue"); } - APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api); + APIPublisherDataHolder.getInstance().getUnpublishedApis().push(apiConfig); } } else { log.error("No tenant [" + apiConfig.getTenantDomain() + "] " + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index 2c2f21f19c8..52dc1477903 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -21,10 +21,10 @@ import io.swagger.annotations.SwaggerDefinition; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.model.Scope; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiScope; import javax.servlet.ServletContext; import javax.ws.rs.Consumes; @@ -96,7 +96,7 @@ public class AnnotationProcessor { private Class apiOperation; private Class scopeClass; private Class scopesClass; - private Map apiScopes; + private Map apiScopes; public AnnotationProcessor(final StandardContext context) { servletContext = context.getServletContext(); @@ -206,20 +206,20 @@ public class AnnotationProcessor { return apiResourceConfigs; } - private Map processAPIScopes(Annotation annotation) throws Throwable { - Map scopes = new HashMap<>(); + private Map processAPIScopes(Annotation annotation) throws Throwable { + Map scopes = new HashMap<>(); InvocationHandler methodHandler = Proxy.getInvocationHandler(annotation); Annotation[] annotatedScopes = (Annotation[]) methodHandler.invoke(annotation, scopesClass .getMethod(ANNOTATIONS_SCOPES, null), null); - Scope scope; + ApiScope scope; String permissions[]; StringBuilder aggregatedPermissions; for(int i=0; ihttp://wso2.org - org.wso2.carbon.apimgt.publisher.client - org.wso2.carbon.apimgt.store.client org.wso2.carbon.apimgt.integration.client org.wso2.carbon.apimgt.webapp.publisher org.wso2.carbon.apimgt.application.extension diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index f1de4f3d62e..fb889349a7d 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -61,7 +61,7 @@ javax.security.auth.x500, javax.xml.*, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.apache.commons.codec.binary, + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.bouncycastle.asn1, org.bouncycastle.asn1.x500, org.bouncycastle.asn1.x509, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index afc03336d55..ad32fc3b988 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -29,7 +29,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; -import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; @@ -262,16 +261,6 @@ public class DeviceMgtAPIUtils { return gadgetDataService; } - public static ScopeManagementService getScopeManagementService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ScopeManagementService scopeManagementService = - (ScopeManagementService) ctx.getOSGiService(ScopeManagementService.class, null); - if (scopeManagementService == null) { - throw new IllegalStateException("Scope Management Service has not been initialized."); - } - return scopeManagementService; - } - public static int getTenantId(String tenantDomain) throws DeviceManagementException { RealmService realmService = (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(RealmService.class, null); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java index 0ffb728f0c3..c11fd758c9f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java @@ -18,7 +18,7 @@ package org.wso2.carbon.device.mgt.jaxrs.util; -import org.wso2.carbon.apimgt.api.model.Scope; +import org.wso2.carbon.device.mgt.core.config.permission.Scope; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorListItem; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 4462f703081..344b5ec25a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -50,7 +50,6 @@ javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", - org.wso2.carbon.apimgt.api.model.*;version="${carbon.api.mgt.version.range}", io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional @@ -69,10 +68,6 @@ org.wso2.orbit.com.fasterxml.jackson.core jackson-annotations - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementException.java deleted file mode 100644 index ed5082a72c6..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed 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 org.wso2.carbon.device.mgt.common.scope.mgt; - -/** - * This exception is used to throw when there is an issue in scope management service. - */ -public class ScopeManagementException extends Exception { - - private static final long serialVersionUID = -315127931137779899L; - - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public ScopeManagementException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public ScopeManagementException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public ScopeManagementException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public ScopeManagementException() { - super(); - } - - public ScopeManagementException(Throwable cause) { - super(cause); - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementService.java deleted file mode 100644 index 2d60dbd1f05..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/scope/mgt/ScopeManagementService.java +++ /dev/null @@ -1,78 +0,0 @@ -/* -* Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. 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 org.wso2.carbon.device.mgt.common.scope.mgt; - -import java.util.List; -import org.wso2.carbon.apimgt.api.model.Scope; - -/** - * This interface contains the basic operations related to scope management. - */ -public interface ScopeManagementService { - - /** - * This method is used to update the given list of scopes. - * - * @param scopes List of scopes to be updated. - * @throws ScopeManagementException - */ - void updateScopes(List scopes) throws ScopeManagementException; - - /** - * This method is used to update the given list of scopes keys with the role name. - * - * @param scopeKeys List of scopes to be updated. - * @param roleName Role name - * @throws ScopeManagementException - */ - void updateScopes(List scopeKeys, String roleName) throws ScopeManagementException; - - /** - * This method is used to retrieve all the scopes. - * - * @return List of scopes. - * @throws ScopeManagementException - */ - List getAllScopes() throws ScopeManagementException; - - /** - * This method is to retrieve the roles of the given scope - * @param scopeKey key of the scope - * @return List of roles - * @throws ScopeManagementException - */ - String getRolesOfScope(String scopeKey) throws ScopeManagementException; - - /** - * This method is to retrieve the scopes of the given role - * @param roleName key of the scope - * @return List of scopes - * @throws ScopeManagementException - */ - List getScopesOfRole(String roleName) throws ScopeManagementException; - - /** - * This method is used to remove the scopes of a given user role. - * - * @param roleName Role name - * @throws ScopeManagementException - */ - void removeScopes(String roleName) throws ScopeManagementException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 2c0ddf4f524..3f5f30c8921 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -77,7 +77,6 @@ org.wso2.carbon.identity.oauth.stub, org.wso2.carbon.identity.oauth.stub.dto, org.wso2.carbon.ndatasource.core, - org.wso2.carbon.apimgt.impl, org.wso2.carbon.ntask.core.*, org.wso2.carbon.ntask.common, org.apache.catalina, @@ -86,7 +85,8 @@ org.wso2.carbon.email.sender.*, io.swagger.annotations.*;resolution:=optional, org.wso2.carbon, - org.wso2.carbon.base + org.wso2.carbon.base, + org.scannotation.* !org.wso2.carbon.device.mgt.core.internal, @@ -94,7 +94,8 @@ javax.ws.rs-api, - scribe;scope=compile|runtime;inline=false; + scribe;scope=compile|runtime;inline=false, + javassist;inline=false * @@ -124,6 +125,10 @@ org.eclipse.osgi org.eclipse.osgi.services + + org.wso2.orbit.org.scannotation + scannotation + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common @@ -203,34 +208,6 @@ org.apache.ws.commons.axiom.wso2 axiom - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - - - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - - - org.apache.axis2.wso2 axis2 @@ -281,12 +258,6 @@ swagger-annotations provided - - - org.wso2.orbit.org.scannotation - scannotation - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations @@ -296,12 +267,14 @@ javax.ws.rs javax.ws.rs-api - javax.ws.rs jsr311-api - + + javassist + javassist + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java index 52c59d753fd..d6a6a84118e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java @@ -19,11 +19,9 @@ package org.wso2.carbon.device.mgt.core.config.permission; import io.swagger.annotations.SwaggerDefinition; -import io.swagger.models.Swagger; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.model.Scope; import org.wso2.carbon.device.mgt.common.permission.mgt.Permission; import javax.servlet.ServletContext; @@ -80,7 +78,6 @@ public class AnnotationProcessor { private Class pathClazz; private ClassLoader classLoader; private ServletContext servletContext; - private Swagger swagger; private Class apiClazz; private Class consumesClass; private Class producesClass; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/ExtendedAnnotationDB.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/ExtendedAnnotationDB.java index dbbd97e3a6d..c4ba51d1f43 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/ExtendedAnnotationDB.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/ExtendedAnnotationDB.java @@ -30,11 +30,11 @@ public class ExtendedAnnotationDB extends AnnotationDB { } public void scanArchives(URL... urls) throws IOException { - URL[] arr$ = urls; - int len$ = urls.length; + URL[] arr = urls; + int len = urls.length; - for(int i$ = 0; i$ < len$; ++i$) { - URL url = arr$[i$]; + for(int i = 0; i < len; ++i) { + URL url = arr[i]; Filter filter = new Filter() { public boolean accepts(String filename) { if(filename.endsWith(".class")) { @@ -60,16 +60,16 @@ public class ExtendedAnnotationDB extends AnnotationDB { } private boolean ignoreScan(String intf) { - String[] arr$; - int len$; - int i$; + String[] arr; + int len; + int i; String ignored; if(this.scanPackages != null) { - arr$ = this.scanPackages; - len$ = arr$.length; + arr = this.scanPackages; + len = arr.length; - for(i$ = 0; i$ < len$; ++i$) { - ignored = arr$[i$]; + for(i = 0; i < len; ++i) { + ignored = arr[i]; if(intf.startsWith(ignored + ".")) { return false; } @@ -77,11 +77,11 @@ public class ExtendedAnnotationDB extends AnnotationDB { return true; } else { - arr$ = this.ignoredPackages; - len$ = arr$.length; + arr = this.ignoredPackages; + len = arr.length; - for(i$ = 0; i$ < len$; ++i$) { - ignored = arr$[i$]; + for(i = 0; i < len; ++i) { + ignored = arr[i]; if(intf.startsWith(ignored + ".")) { return true; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/Scope.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/Scope.java new file mode 100644 index 00000000000..aab33dcccd1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/Scope.java @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* Licensed 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 org.wso2.carbon.device.mgt.core.config.permission; + +import java.io.Serializable; + +public class Scope implements Serializable { + String key; + String name; + String roles; + String description; + int id; + + public Scope() { + } + + public String getKey() { + return this.key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoles() { + return this.roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } +} + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 0ca96ec4d29..7de29280653 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.core.internal; -import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; @@ -72,8 +71,6 @@ public class DeviceManagementDataHolder { return this.map; } - private APIManagerConfiguration apiManagerConfiguration; - private DeviceManagementDataHolder() {} public static DeviceManagementDataHolder getInstance() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index adbf6cda436..8886d756bf5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; @@ -84,12 +83,6 @@ import java.util.List; * policy="dynamic" * bind="setRegistryService" * unbind="unsetRegistryService" - * @scr.reference name="api.manager.config.service" - * interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService" - * cardinality="1..1" - * policy="dynamic" - * bind="setAPIManagerConfigurationService" - * unbind="unsetAPIManagerConfigurationService" * @scr.reference name="org.wso2.carbon.ndatasource" * interface="org.wso2.carbon.ndatasource.core.DataSourceService" * cardinality="1..1" @@ -355,14 +348,6 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setRegistryService(null); } - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml index 6dc589a7ba8..5bf4d705cb1 100644 --- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml @@ -181,11 +181,6 @@ commons-logging provided - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - provided - diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 2a01d519b02..e858c780949 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -34,6 +34,10 @@ http://wso2.org + + commons-codec.wso2 + commons-codec + org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth @@ -42,10 +46,6 @@ org.wso2.carbon org.wso2.carbon.user.core - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.keymgt @@ -54,6 +54,10 @@ com.googlecode.json-simple.wso2 json-simple + + org.wso2.carbon.identity.framework + org.wso2.carbon.user.mgt + @@ -93,10 +97,6 @@ org.wso2.carbon.user.core.tenant, org.json.simple, javax.cache, - org.wso2.carbon.apimgt.api, - org.wso2.carbon.apimgt.impl, - org.wso2.carbon.apimgt.impl.dao, - org.wso2.carbon.apimgt.impl.utils, org.wso2.carbon.identity.core.util, org.wso2.carbon.identity.oauth2.dto, org.wso2.carbon.identity.oauth2.token, @@ -106,8 +106,7 @@ org.wso2.carbon.identity.oauth.config, org.wso2.carbon.identity.oauth2.dao, org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.apimgt.keymgt.handlers, - org.apache.commons.codec.binary, + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.wso2.carbon.identity.application.authentication.framework.model, org.wso2.carbon.base, org.apache.commons.collections, @@ -124,7 +123,8 @@ org.wso2.carbon.idp.mgt, org.opensaml.common.xml, org.wso2.carbon.identity.oauth.common, - org.opensaml + org.opensaml, + org.wso2.carbon.apimgt.keymgt.issuers diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java deleted file mode 100644 index c07041c678c..00000000000 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; -import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; -import org.wso2.carbon.identity.core.util.IdentityTenantUtil; -import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; -import org.wso2.carbon.user.api.TenantManager; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.core.service.RealmService; - -import javax.cache.Caching; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * This class holds util methods used by OAuth extension bundle. - */ -public class OAuthExtUtils { - - private static final Log log = LogFactory.getLog(OAuthExtUtils.class); - private static final String DEFAULT_SCOPE_NAME = "default"; - private static final String UI_EXECUTE = "ui.execute"; - private static final String REST_API_SCOPE_CACHE = "REST_API_SCOPE_CACHE"; - private static final int START_INDEX = 0; - private static final String DEFAULT_SCOPE_TAG = "device-mgt"; - - /** - * This method is used to get the tenant id when given tenant domain. - * - * @param tenantDomain Tenant domain name. - * @return Returns the tenant id. - */ - public static int getTenantId(String tenantDomain) { - int tenantId = 0; - if (tenantDomain != null) { - try { - TenantManager tenantManager = - OAuthExtensionsDataHolder.getInstance().getRealmService().getTenantManager(); - tenantId = tenantManager.getTenantId(tenantDomain); - } catch (UserStoreException e) { - String errorMsg = "Error when getting the tenant id from the tenant domain : " + - tenantDomain; - log.error(errorMsg, e); - } - } - return tenantId; - } - - /** - * This method is used to set scopes that are authorized to the OAuth token request message context. - * - * @param tokReqMsgCtx OAuth token request message context - * @return Returns true if success. - */ - public static boolean setScopes(OAuthTokenReqMessageContext tokReqMsgCtx) { - String[] requestedScopes = tokReqMsgCtx.getScope(); - String[] defaultScope = new String[]{DEFAULT_SCOPE_NAME}; - - //If no scopes were requested. - if (requestedScopes == null || requestedScopes.length == 0) { - tokReqMsgCtx.setScope(defaultScope); - return true; - } - - String consumerKey = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getClientId(); - List reqScopeList = Arrays.asList(requestedScopes); - Map restAPIScopesOfCurrentTenant; - - try { - - Map appScopes; - ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance(); - - //Get all the scopes and permissions against the scopes defined for the APIs subscribed to the application. - appScopes = apiMgtDAO.getScopeRolesOfApplication(consumerKey); - - //Add API Manager rest API scopes set. This list should be loaded at server start up and keep - //in memory and add it to each and every request coming. - String tenantDomain = tokReqMsgCtx.getAuthorizedUser().getTenantDomain(); - restAPIScopesOfCurrentTenant = (Map) Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER) - .getCache(REST_API_SCOPE_CACHE) - .get(tenantDomain); - if (restAPIScopesOfCurrentTenant != null) { - appScopes.putAll(restAPIScopesOfCurrentTenant); - } else { - restAPIScopesOfCurrentTenant = APIUtil. - getRESTAPIScopesFromConfig(APIUtil.getTenantRESTAPIScopesConfig(tenantDomain)); - - //then put cache - appScopes.putAll(restAPIScopesOfCurrentTenant); - Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER) - .getCache(REST_API_SCOPE_CACHE) - .put(tenantDomain, restAPIScopesOfCurrentTenant); - } - //If no scopes can be found in the context of the application - if (appScopes.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("No scopes defined for the Application " + - tokReqMsgCtx.getOauth2AccessTokenReqDTO().getClientId()); - } - - String[] allowedScopes = getAllowedScopes(reqScopeList); - tokReqMsgCtx.setScope(allowedScopes); - return true; - } - - // check for authorized scopes - List authorizedScopes = getAuthorizedScopes(tokReqMsgCtx, reqScopeList, appScopes); - - if (!authorizedScopes.isEmpty()) { - String[] authScopesArr = authorizedScopes.toArray(new String[authorizedScopes.size()]); - tokReqMsgCtx.setScope(authScopesArr); - } else { - tokReqMsgCtx.setScope(defaultScope); - } - } catch (APIManagementException e) { - log.error("Error while getting scopes of application " + e.getMessage()); - return false; - } - return true; - } - - /** - * Determines if the scope is specified in the white list. - * - * @param scope - The scope key to check - * @return - 'true' if the scope is white listed. 'false' if not. - */ - private static boolean isWhiteListedScope(String scope) { - // load white listed scopes - List scopeSkipList = OAuthExtensionsDataHolder.getInstance().getWhitelistedScopes(); - for (String scopeTobeSkipped : scopeSkipList) { - if (scope.matches(scopeTobeSkipped)) { - return true; - } - } - return false; - } - - /** - * Get the set of default scopes. If a requested scope is matches with the patterns specified in the white list, - * then such scopes will be issued without further validation. If the scope list is empty, - * token will be issued for default scope. - * - * @param requestedScopes - The set of requested scopes - * @return - The subset of scopes that are allowed - */ - private static String[] getAllowedScopes(List requestedScopes) { - List authorizedScopes = new ArrayList<>(); - - //Iterate the requested scopes list. - for (String scope : requestedScopes) { - if (isWhiteListedScope(scope)) { - authorizedScopes.add(scope); - } - } - if (authorizedScopes.isEmpty()) { - authorizedScopes.add(DEFAULT_SCOPE_NAME); - } - return authorizedScopes.toArray(new String[authorizedScopes.size()]); - } - - /** - * This method is used to get the authorized scopes out of requested scopes. It checks requested scopes with app - * scopes whether user has permissions to take actions for the requested scopes. - * - * @param tokReqMsgCtx OAuth token request message context. - * @param reqScopeList Requested scope list. - * @param appScopes App scopes. - * @return Returns a list of scopes. - */ - private static List getAuthorizedScopes(OAuthTokenReqMessageContext tokReqMsgCtx, List reqScopeList, - Map appScopes) { - - boolean status; - List authorizedScopes = new ArrayList<>(); - - int tenantId; - String username = tokReqMsgCtx.getAuthorizedUser().getUserName(); - String tenantDomain = tokReqMsgCtx.getAuthorizedUser().getTenantDomain(); - RealmService realmService = OAuthExtensionsDataHolder.getInstance().getRealmService(); - - try { - tenantId = realmService.getTenantManager().getTenantId(tenantDomain); - - // If tenant Id is not set in the tokenReqContext, deriving it from username. - if (tenantId == 0 || tenantId == -1) { - tenantId = IdentityTenantUtil.getTenantIdOfUser(username); - } - - UserRealm userRealm = OAuthExtensionsDataHolder.getInstance().getRealmService().getTenantUserRealm( - tenantId); - - //Iterate the requested scopes list. - for (String scope : reqScopeList) { - status = false; - - //Get the set of roles associated with the requested scope. - String appPermissions = appScopes.get(scope); - - //If the scope has been defined in the context of the App and if permissions have been defined for - // the scope - if (appPermissions != null && appPermissions.length() != 0) { - List permissions = new ArrayList<>(Arrays.asList(appPermissions.replaceAll(" ", "").split( - ","))); - - //Check if user has at least one of the permission associated with the scope - if (!permissions.isEmpty()) { - for (String permission : permissions) { - if (userRealm != null && userRealm.getAuthorizationManager() != null) { - String userStore = tokReqMsgCtx.getAuthorizedUser().getUserStoreDomain(); - - if (userStore != null) { - status = userRealm.getAuthorizationManager() - .isUserAuthorized(userStore + "/" + username, permission, UI_EXECUTE); - } else { - status = userRealm.getAuthorizationManager() - .isUserAuthorized(username, permission, UI_EXECUTE); - } - if (status) { - break; - } - } - } - if (status) { - authorizedScopes.add(scope); - } - } - } - - //The scope string starts with 'device_'. - else if (appScopes.containsKey(scope) || isWhiteListedScope(scope)) { - authorizedScopes.add(scope); - } - } - } catch (UserStoreException e) { - log.error("Error occurred while initializing user store.", e); - } - return authorizedScopes; - } - - public static String extractUserName(String username) { - if (username == null || username.isEmpty()) { - return null; - } - String trimmedName = username.trim(); - return trimmedName.substring(START_INDEX, trimmedName.lastIndexOf('@')); - } - -} diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/DeviceMgtOAuthCallbackHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/DeviceMgtOAuthCallbackHandler.java deleted file mode 100644 index e621ee4a8b4..00000000000 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/DeviceMgtOAuthCallbackHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.handlers; - -import org.wso2.carbon.identity.oauth.callback.AbstractOAuthCallbackHandler; -import org.wso2.carbon.identity.oauth.callback.OAuthCallback; -import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; - -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.UnsupportedCallbackException; -import java.io.IOException; - -/** - * This class represents a Custom OAuthCallback Handler implementation. This should be implemented - * if there's any necessity of custom logic to authorize OAuthCallbacks. - */ -public class DeviceMgtOAuthCallbackHandler extends AbstractOAuthCallbackHandler { - - @Override - public boolean canHandle(Callback[] callbacks) throws IdentityOAuth2Exception { - return true; - } - - @Override - public void handle(Callback[] callbacks) - throws IOException, UnsupportedCallbackException { - if (callbacks != null && callbacks.length > 0){ - OAuthCallback oauthCallback = (OAuthCallback) callbacks[0]; - if (OAuthCallback.OAuthCallbackType.ACCESS_DELEGATION_AUTHZ.equals( - oauthCallback.getCallbackType())){ - oauthCallback.setAuthorized(true); - } else if (OAuthCallback.OAuthCallbackType.ACCESS_DELEGATION_TOKEN.equals( - oauthCallback.getCallbackType())){ - oauthCallback.setAuthorized(true); - } else if (OAuthCallback.OAuthCallbackType.SCOPE_VALIDATION_AUTHZ.equals( - oauthCallback.getCallbackType())){ - oauthCallback.setValidScope(true); - } else if (OAuthCallback.OAuthCallbackType.SCOPE_VALIDATION_TOKEN.equals( - oauthCallback.getCallbackType())){ - String[] scopes = oauthCallback.getRequestedScope(); - oauthCallback.setApprovedScope(scopes); - oauthCallback.setValidScope(true); - //Add the necessary logic if we are doing the scope validation upon token issue - } - } - - } -} diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java deleted file mode 100644 index 8a5be8bc8da..00000000000 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedPasswordGrantHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; - -import org.wso2.carbon.device.mgt.oauth.extensions.OAuthExtUtils; -import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; - -@SuppressWarnings("unused") -public class ExtendedPasswordGrantHandler extends org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler { - - @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return OAuthExtUtils.setScopes(tokReqMsgCtx); - } - -} diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 67fbe41ba4d..0ba3d273fb3 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -38,8 +38,8 @@ import org.opensaml.xml.security.x509.X509Credential; import org.opensaml.xml.signature.SignatureValidator; import org.opensaml.xml.validation.ValidationException; import org.w3c.dom.NodeList; +import org.wso2.carbon.apimgt.keymgt.issuers.ScopesIssuingHandler; import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.device.mgt.oauth.extensions.OAuthExtUtils; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; import org.wso2.carbon.identity.application.common.model.IdentityProvider; @@ -101,7 +101,7 @@ public class ExtendedSAML2BearerGrantHandler extends AbstractAuthorizationGrantH @Override public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return OAuthExtUtils.setScopes(tokReqMsgCtx); + return ScopesIssuingHandler.getInstance().setScopes(tokReqMsgCtx); } /** diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java index dfcdc2dff27..06ee47fcf6b 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java @@ -21,16 +21,8 @@ package org.wso2.carbon.device.mgt.oauth.extensions.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.CarbonUtils; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; /** * @scr.component name="org.wso2.carbon.device.mgt.oauth.extensions" immediate="true" @@ -60,36 +52,6 @@ public class OAuthExtensionServiceComponent { if (log.isDebugEnabled()) { log.debug("Starting OAuthExtensionBundle"); } - try { - - APIManagerConfiguration configuration = new APIManagerConfiguration(); - String filePath = new StringBuilder(). - append(CarbonUtils.getCarbonHome()). - append(File.separator). - append(REPOSITORY). - append(File.separator). - append(CONFIGURATION). - append(File.separator). - append(APIM_CONF_FILE).toString(); - - configuration.load(filePath); - // loading white listed scopes - List whiteList; - - // Read scope whitelist from Configuration. - whiteList = configuration.getProperty(APIConstants.WHITELISTED_SCOPES); - - // If whitelist is null, default scopes will be put. - if (whiteList == null) { - whiteList = new ArrayList(); - whiteList.add(APIConstants.OPEN_ID_SCOPE_NAME); - whiteList.add(APIConstants.DEVICE_SCOPE_PATTERN); - } - - OAuthExtensionsDataHolder.getInstance().setWhitelistedScopes(whiteList); - } catch (APIManagementException e) { - log.error("Error occurred while loading DeviceMgtConfig configurations", e); - } } @SuppressWarnings("unused") diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index 1de87ce72c7..c9d821688d2 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -70,6 +70,10 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub + + commons-codec.wso2 + commons-codec + @@ -104,7 +108,7 @@ org.apache.axis2.transport.http, org.apache.commons.httpclient, org.apache.commons.logging, - org.apache.commons.codec.binary, + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.osgi.framework, org.osgi.service.component, org.wso2.carbon.core.security, diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index f5b348b6c97..44e936493a2 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -106,6 +106,10 @@ org.wso2.orbit.org.apache.httpcomponents httpclient + + commons-codec.wso2 + commons-codec + @@ -144,7 +148,7 @@ com.nimbusds.jwt.*;version="${nimbus.orbit.version.range}", com.nimbusds.jose.*;version="${nimbus.orbit.version.range}", javax.net.ssl, - org.apache.commons.codec.binary, + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.apache.http;version="${httpclient.version.range}", org.apache.http.client;version="${httpclient.version.range}", org.apache.http.message;version="${httpclient.version.range}", diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 342360206a6..b591d8c1099 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -73,10 +73,6 @@ org.osgi.service.component, org.osgi.framework, org.w3c.dom, - org.wso2.carbon.apimgt.api, - org.wso2.carbon.apimgt.core.authenticate, - org.wso2.carbon.apimgt.core.gateway, - org.wso2.carbon.apimgt.impl.dto, org.wso2.carbon.context, org.wso2.carbon.core.util, org.wso2.carbon.identity.base; version="${carbon.identity.imp.pkg.version}", @@ -94,14 +90,13 @@ javax.servlet.http, javax.xml, org.apache.axis2.transport.http, - org.wso2.carbon.apimgt.impl, org.wso2.carbon.certificate.mgt.core.*, org.wso2.carbon.device.mgt.core.permission.mgt, org.wso2.carbon.device.mgt.common, org.wso2.carbon.device.mgt.common.permission.mgt, org.apache.axis2, org.apache.axis2.client, - org.apache.commons.codec.binary, + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.apache.commons.httpclient, org.wso2.carbon.core.security, org.apache.axis2.context, @@ -146,14 +141,6 @@ org.wso2.tomcat tomcat-servlet-api - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.core - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - org.wso2.carbon org.wso2.carbon.logging @@ -226,6 +213,10 @@ org.wso2.orbit.org.owasp.encoder encoder + + commons-codec.wso2 + commons-codec + diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java index 8a44108ee8e..3d768ecff4b 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java @@ -23,12 +23,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.owasp.encoder.Encode; import org.w3c.dom.Document; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.core.authenticate.APITokenValidator; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.dto.APIKeyValidationInfoDTO; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.webapp.authenticator.framework.Utils.Utils; import javax.servlet.http.HttpServletResponse; import javax.xml.XMLConstants; @@ -48,33 +42,6 @@ public class AuthenticationFrameworkUtil { handleResponse(request, response, HttpServletResponse.SC_FORBIDDEN, msg); } - public static boolean doAuthenticate( - String context, String version, String accessToken, String requiredAuthenticationLevel, - String clientDomain) throws APIManagementException, AuthenticationException { - - if (APIConstants.AUTH_NO_AUTHENTICATION.equals(requiredAuthenticationLevel)) { - return true; - } - APITokenValidator tokenValidator = new APITokenValidator(); - APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken, - requiredAuthenticationLevel); - if (apiKeyValidationDTO.isAuthorized()) { - String username = apiKeyValidationDTO.getEndUserName(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); -// try { - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(Utils.getTenantIdOFUser(username)); -// } catch (IdentityException e) { -// throw new AuthenticationException("Error occurred while retrieving the tenant ID of user '" + -// username + "'", e); -// } - return true; - } else { - throw new AuthenticationException(apiKeyValidationDTO.getValidationStatus(), - "Access failure for API: " + context + ", version: " + - version + " with key: " + accessToken); - } - } - public static void handleResponse(Request request, Response response, int statusCode, String payload) { response.setStatus(statusCode); String targetResponseContentType = diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 7d22f7be659..50382ac3fb4 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -28,6 +28,7 @@ 4.0.0 org.wso2.carbon.apimgt.integration.client.feature + 2.0.8-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org @@ -35,7 +36,7 @@ - org.wso2.carbon + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.integration.client @@ -79,7 +80,7 @@ p2-feature-gen - org.wso2.carbon.apimgt.client + org.wso2.carbon.apimgt.integration.client ../../../features/etc/feature.properties @@ -88,18 +89,6 @@ - - javax.ws.rs:jsr311-api:${jsr311.version} - - - io.swagger:swagger-annotations:${swagger.annotations.version} - - - io.github.openfeign:feign-slf4j:${io.github.openfeign.version} - - - io.github.openfeign:feign-jaxrs:${io.github.openfeign.version} - io.github.openfeign:feign-jackson:${io.github.openfeign.version} @@ -110,19 +99,7 @@ io.github.openfeign:feign-gson:${io.github.openfeign.version} - org.wso2.carbon:org.wso2.carbon.apimgt.integration.client:${project.version} - - - org.wso2.carbon:org.wso2.carbon.apimgt.publisher.client:${project.version} - - - org.wso2.carbon:org.wso2.carbon.apimgt.store.client:${project.version} - - - org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:${oltu.client.version} - - - com.fasterxml.jackson.datatype:jackson-datatype-joda:${jackson.datatype.joda.version} + org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version} diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml index c809feecdde..dfabaf24f5a 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml @@ -19,10 +19,10 @@ --> - http://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.10/register + https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.11/register https://${iot.gateway.host}:${iot.gateway.https.port}/token - https://localhost:9443/api/am/publisher/v0.10 - https://localhost:9443/api/am/store/v0.10 - admin + https://${iot.apimpublisher.host}:${iot.apimpublisher.https.port}/api/am/publisher/v0.11 + https://${iot.apimstore.host}:${iot.apimstore.https.port}/api/am/store/v0.11 + admin admin \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf index 461f6ec80f7..3dca52fc595 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf @@ -1,2 +1,2 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.apim.integration_${feature.version}/conf/apim-integration.xml,target:${installFolder}/../../conf/apim-integration.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.integration.client_${feature.version}/conf/apim-integration.xml,target:${installFolder}/../../conf/apim-integration.xml,overwrite:true);\ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 3efb84cb005..7602be88f61 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -52,6 +52,10 @@ org.wso2.carbon.store org.wso2.store.sso.common + + org.wso2.orbit.org.scannotation + scannotation + @@ -81,7 +85,8 @@ javax.servlet.jsp:javax.servlet.jsp-api org.wso2.carbon.store:org.wso2.store.sso.common:${carbon.store.sso.common.version} - + org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index adbac41ef16..ef7e11bb4f6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -143,9 +143,7 @@ org.wso2.carbon.core.server:${carbon.kernel.version} - org.wso2.carbon.apimgt.core:${carbon.api.mgt.version} - - org.wso2.carbon.device.mgt.extensions:${carbon.device.mgt.version} + org.wso2.carbon.device.mgt.extensions:${carbon.device.mgt.version} org.wso2.carbon.email.sender:${carbon.device.mgt.version} diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index e98613903be..d6d51c8564a 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -53,10 +53,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.client - org.wso2.carbon.registry org.wso2.carbon.registry.indexing @@ -125,7 +121,6 @@ - org.wso2.carbon.apimgt:org.wso2.carbon.apimgt.keymgt.client:${carbon.api.mgt.version} org.wso2.carbon.registry:org.wso2.carbon.registry.indexing:${carbon.registry.version} diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index e84bbd11adf..f0662eaa630 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -40,10 +40,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.core - @@ -97,9 +93,6 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.webapp.authenticator.framework:${carbon.device.mgt.version} - - org.wso2.carbon.apimgt:org.wso2.carbon.apimgt.core:${carbon.api.mgt.version} - diff --git a/pom.xml b/pom.xml index 241eb082a0d..adeb0246756 100644 --- a/pom.xml +++ b/pom.xml @@ -120,14 +120,6 @@ org.apache.ws.commons.axiom.wso2 axiom - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - org.wso2.carbon.identity org.wso2.carbon.identity.oauth.stub @@ -208,16 +200,6 @@ org.wso2.carbon.apimgt.webapp.publisher ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.publisher.client - ${carbon.device.mgt.version} - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.store.client - ${carbon.device.mgt.version} - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.integration.client @@ -834,223 +816,11 @@ - - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - ${carbon.api.mgt.version} - - - com.googlecode.json-simple.wso2 - json-simple - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - - - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.client - ${carbon.api.mgt.version} - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.keymgt ${carbon.api.mgt.version} - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl - ${carbon.api.mgt.version} - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - - - org.wso2.carbon.mediation - org.wso2.carbon.mediation.initializer - - - org.apache.woden.wso2 - woden - - - org.wso2.carbon - org.wso2.carbon.user.core - - - org.wso2.carbon.governance - org.wso2.carbon.governance.api - - - org.wso2.carbon.registry - org.wso2.carbon.registry.ws.client - - - org.wso2.carbon.identity - org.wso2.carbon.identity.core - - - org.wso2.carbon.identity - org.wso2.carbon.identity.oauth - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.client - - - org.apache.poi - poi-ooxml - - - org.wso2.carbon.mediation - org.wso2.carbon.rest.api.stub - - - org.json.wso2 - json - - - com.h2database.wso2 - h2-database-engine - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.handlers.security.stub - - - org.wso2.carbon.commons - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.commons - org.wso2.carbon.um.ws.api - - - org.wso2.carbon.mediation - org.wso2.carbon.mediation.dependency.mgt - - - com.google.code.gson - gson - - - org.wso2.carbon.mediation - org.wso2.carbon.mediation.registry - - - org.apache.httpcomponents - httpmime - - - org.wso2.carbon.commons - org.wso2.carbon.event.core - - - org.wso2.carbon.mediation - org.wso2.carbon.sequences.stub - - - org.wso2.carbon.mediation - org.wso2.carbon.mediation.security.stub - - - org.wso2.carbon.registry - org.wso2.carbon.registry.indexing - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.stub - - - org.wso2.carbon - org.wso2.carbon.securevault - - - com.googlecode.json-simple.wso2 - json-simple - - - org.apache.bsf - bsf-all - - - org.wso2.carbon.registry - org.wso2.carbon.registry.ws.client - - - javax.servlet - servlet-api - - - xerces - xercesImpl - - - io.swagger - swagger-annotations - - - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.core - ${carbon.api.mgt.version} - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt.stub - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.stub - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.usage.publisher - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.gateway - - - org.wso2.carbon.commons - org.wso2.carbon.databridge.agent.thrift - - - org.wso2.carbon.multitenancy - org.wso2.carbon.tenant.usage.agent - - - org.wso2.carbon.apimgt - org.wso2.carbon.ganalytics.publisher - - - org.wso2.carbon.apimgt - org.wso2.carbon.throttle.core - - - @@ -1129,11 +899,6 @@ - - org.wso2.carbon.identity - org.wso2.carbon.identity.base - ${carbon.identity.framework.version} - org.wso2.carbon.identity.framework org.wso2.carbon.identity.core @@ -1445,6 +1210,11 @@ neethi ${neethi.version} + + commons-codec + commons-codec + ${commons.codec.verision} + commons-pool.wso2 @@ -1586,14 +1356,6 @@ commons-configuration ${commons-configuration.version} - - - org.wso2.carbon.identity - org.wso2.carbon.user.mgt - ${carbon.identity.framework.version} - provided - - io.swagger swagger-annotations @@ -1731,6 +1493,11 @@ jackson-datatype-joda ${jackson.datatype.joda.version} + + javassist + javassist + ${javassist.version} + @@ -2024,6 +1791,7 @@ 4.4.8 1.4.0.wso2v1 + [1.4.0,2.0.0) 2.4.0.wso2v1 2.6.0.wso2v1 [2.6.0,3.0.0) @@ -2074,7 +1842,7 @@ 1.0.3.wso2v1 - + [1.0.3, 2.0.0) 1.5.6.wso2v1 4.3.1.wso2v2 @@ -2137,6 +1905,9 @@ 1.0.1 2.1.5 + 1.9 + (1.9,2.0] + 3.12.1.GA From 7348ae2f2afcfbd0e4f6aaa20f40b7caca07a41c Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 24 Jan 2017 19:49:40 +0530 Subject: [PATCH 006/193] resolved merge issues --- .../org.wso2.carbon.apimgt.integration.client/pom.xml | 4 ++-- .../org.wso2.carbon.apimgt.integration.client.feature/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 6688f2fb112..60409715065 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -14,13 +14,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.8-SNAPSHOT + 2.0.11-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.8-SNAPSHOT + 2.0.11-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 50382ac3fb4..c3033e1aaa6 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.8-SNAPSHOT + 2.0.11-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 2.0.8-SNAPSHOT + 2.0.11-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org From 1370b8761813c00f39e4ddffeda04ccfda83d1e2 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 25 Jan 2017 09:24:23 +0530 Subject: [PATCH 007/193] fixed apim application issue --- ...ApiApplicationRegistrationServiceImpl.java | 1 - .../APIManagementProviderServiceImpl.java | 19 ++++++++++++--- .../publisher/APIPublisherServiceImpl.java | 24 ++++++++++++------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 268ec154ec5..425c9a11419 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -60,7 +60,6 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(); - username = username + "@" + APIUtil.getTenantDomainOftheUser(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index f319c296323..fdeccb2aca9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -99,14 +99,27 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } if (apiList.getList() != null && apiList.getList().size() > 0) { - for (APIInfo apiInfo :apiList.getList()) { + for (APIInfo apiInfo : apiList.getList()) { Subscription subscription = new Subscription(); subscription.setApiIdentifier(apiInfo.getId()); subscription.setApplicationId(application.getApplicationId()); subscription.tier(ApiApplicationConstants.DEFAULT_TIER); - storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE); + SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet + (apiInfo.getId(), application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); + boolean subscriptionExist = false; + if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { + for (Subscription subs : subscriptionList.getList()) { + if (subs.getApiIdentifier().equals(apiInfo.getId()) && subs.getApplicationId().equals( + application.getApplicationId())) { + subscriptionExist = true; + break; + } + } + } + if (!subscriptionExist) { + storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE); + } } - } } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index ee4801f5454..9e21d731f03 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -53,7 +53,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { API api = getAPI(apiConfig); APIList apiList = publisherClient.getApi().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null); - if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) { + if (!isExist(api, apiList)) { api = publisherClient.getApi().apisPost(api, CONTENT_TYPE); if (CREATED_STATUS.equals(api.getStatus())) { publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); @@ -61,9 +61,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { } else { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { for (APIInfo apiInfo : apiList.getList()) { - if (api.getVersion().equals(apiInfo.getVersion())) { - api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, - null); + if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) { + api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null); if (CREATED_STATUS.equals(api.getStatus())) { publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); @@ -80,6 +79,18 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } + private boolean isExist(API api, APIList apiList) { + if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) { + return false; + } + for (APIInfo existingApi : apiList.getList()) { + if (existingApi.getName().equals(api.getName()) && existingApi.getVersion().equals(api.getVersion())) { + return true; + } + } + return false; + } + private API getAPI(APIConfig config) { API api = new API(); @@ -88,11 +99,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { String context = config.getContext(); context = context.startsWith("/") ? context : ("/" + context); - String providerDomain = config.getTenantDomain(); - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(providerDomain)) { - //Create tenant aware context for API - context = "/t/" + providerDomain + context; - } api.setContext(context); api.setVersion(config.getVersion()); api.setProvider(config.getOwner()); From 1a7a21544146a9e398f9a4d3acc9fcf70b0d80cf Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 25 Jan 2017 14:00:31 +0530 Subject: [PATCH 008/193] added missing license headers --- .../client/OAuthRequestInterceptor.java | 40 +++++++++---------- .../client/publisher/api/APIDocumentApi.java | 17 ++++++++ .../client/publisher/api/APIsApi.java | 17 ++++++++ .../client/publisher/api/ApplicationsApi.java | 17 ++++++++ .../client/publisher/api/EnvironmentsApi.java | 17 ++++++++ .../publisher/api/SubscriptionsApi.java | 17 ++++++++ .../client/publisher/api/TiersApi.java | 17 ++++++++ .../client/store/api/APIindividualApi.java | 17 ++++++++ .../client/store/api/ApisAPIApi.java | 17 ++++++++ .../store/api/ApplicationCollectionApi.java | 17 ++++++++ .../store/api/ApplicationindividualApi.java | 17 ++++++++ .../store/api/SubscriptionCollectionApi.java | 17 ++++++++ .../store/api/SubscriptionindividualApi.java | 17 ++++++++ .../client/store/api/TagCollectionApi.java | 17 ++++++++ .../client/store/api/TierCollectionApi.java | 17 ++++++++ .../client/store/api/TierindividualApi.java | 17 ++++++++ .../devicemgt/app/conf/config.json | 7 ++-- .../app/modules/oauth/token-handler-utils.js | 7 ++-- 18 files changed, 283 insertions(+), 26 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java index 1c421c46f10..2f893d74cb9 100755 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java @@ -28,6 +28,7 @@ import org.wso2.carbon.apimgt.integration.client.model.ClientProfile; import org.wso2.carbon.apimgt.integration.client.model.DCRClient; import org.wso2.carbon.apimgt.integration.client.model.OAuthApplication; import org.wso2.carbon.apimgt.integration.client.util.PropertyUtils; +import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; @@ -50,7 +51,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000; private DCRClient dcrClient; private static OAuthApplication oAuthApplication; - private static Map tenantTokenMap = new HashMap<>(); + private static Map tenantUserTokenMap = new HashMap<>(); /** * Creates an interceptor that authenticates all requests. @@ -77,34 +78,33 @@ public class OAuthRequestInterceptor implements RequestInterceptor { clientProfile.setSaasApp(true); oAuthApplication = dcrClient.register(clientProfile); } - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - AccessTokenInfo tenantBasedAccessTokenInfo = tenantTokenMap.get(tenantDomain); + try { + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + username = username + "@" + tenantDomain; + } + AccessTokenInfo tenantBasedAccessTokenInfo = tenantUserTokenMap.get(username); + if ((tenantBasedAccessTokenInfo == null || + ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > + tenantBasedAccessTokenInfo.getExpiresIn()))) { - if ((tenantBasedAccessTokenInfo == null || - ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > - tenantBasedAccessTokenInfo.getExpiresIn()))) { - try { JWTClient jwtClient = APIIntegrationClientDataHolder.getInstance().getJwtClientManagerService() .getJWTClient(); - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName() + "@" + tenantDomain; - tenantBasedAccessTokenInfo = jwtClient.getAccessToken(oAuthApplication.getClientId(), oAuthApplication.getClientSecret(), username, REQUIRED_SCOPE); tenantBasedAccessTokenInfo.setExpiresIn( System.currentTimeMillis() + (tenantBasedAccessTokenInfo.getExpiresIn() * 1000)); - tenantTokenMap.put(tenantDomain, tenantBasedAccessTokenInfo); - } catch (JWTClientException e) { - throw new APIMClientOAuthException("failed to retrieve oauth token using jwt", e); - } catch (UserStoreException e) { - throw new APIMClientOAuthException("failed to retrieve tenant admin username", e); - } + tenantUserTokenMap.put(username, tenantBasedAccessTokenInfo); - } - if (tenantBasedAccessTokenInfo.getAccessToken() != null) { - String headerValue = "Bearer " + tenantBasedAccessTokenInfo.getAccessToken(); - template.header("Authorization", headerValue); + } + if (tenantBasedAccessTokenInfo.getAccessToken() != null) { + String headerValue = "Bearer " + tenantBasedAccessTokenInfo.getAccessToken(); + template.header("Authorization", headerValue); + } + } catch (JWTClientException e) { + throw new APIMClientOAuthException("failed to retrieve oauth token using jwt", e); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java index 2f7c76f9cae..86942d349f9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIDocumentApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java index 469dbcdbdb1..b1bb6fe0215 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/APIsApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java index baed5a1a78a..228755ffdf1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/ApplicationsApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java index 63dd56a1dbe..babc1b7949c 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/EnvironmentsApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java index 9a38b6a477d..b9e11e3141b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/SubscriptionsApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java index 7239c02e3bb..b25c26b948f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/api/TiersApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.publisher.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java index ff7789724a1..ebbff73ebf8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/APIindividualApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java index 5558af1ef71..35ccfdd3c01 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApisAPIApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java index 05e3fa68586..f627e4dcc37 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationCollectionApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java index b6f3b9e0b0f..7c2cabcd3f0 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/ApplicationindividualApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java index c1ca6701e8e..43075305f6d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionCollectionApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java index e5b23bab708..adf57708a40 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/SubscriptionindividualApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java index adedc6d4d1b..e57da1494ca 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TagCollectionApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java index 5e41d015091..bf8dce98a18 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierCollectionApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java index e5ae77afb76..c62d53503e1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/api/TierindividualApi.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.apimgt.integration.client.store.api; import feign.Headers; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index a43bb34bcef..a3a81e4446a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -15,13 +15,14 @@ "oauthProvider": { "appRegistration": { "appType": "webapp", - "clientName": "emm", + "clientName": "iot_ui", "owner": "admin@carbon.super", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "apiManagerClientAppRegistrationServiceURL": "https://%iot.gateway.host%:%iot.gateway.https.port%/api-application-registration/register/tenants", - "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer", + "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-carbon urn:ietf:params:oauth:grant-type:jwt-bearer", "tokenScope": "admin", - "callbackUrl": "%https.ip%/api/device-mgt/v1.0" + "callbackUrl": "%https.ip%/api/device-mgt/v1.0", + "samlGrantTypeName": "urn:ietf:carbon:signed:grant-type:saml2-bearer" }, "tokenServiceURL": "https://%iot.gateway.host%:%iot.gateway.https.port%/token" }, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js index c60cd9c80d6..b31febe79a2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js @@ -108,7 +108,8 @@ var utils = function () { var jwtToken = publicMethods.getJwtToken(adminUsername, claims); // register a tenant based client app at API Manager - var applicationName = "webapp_" + tenantDomain; + var applicationName = deviceMgtProps["oauthProvider"]["appRegistration"] + ["clientName"] + "_" + tenantDomain; var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] ["apiManagerClientAppRegistrationServiceURL"] + "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; @@ -303,8 +304,8 @@ var utils = function () { // calling oauth provider token service endpoint var requestURL = deviceMgtProps["oauthProvider"]["tokenServiceURL"]; - var requestPayload = "grant_type=urn:ietf:params:oauth:grant-type:saml2-carbon&" + - "assertion=" + encodeURIComponent(encodedAssertion) + "&scope=" + scopes; + var requestPayload = "grant_type=" + deviceMgtProps["oauthProvider"]["appRegistration"]["samlGrantTypeName"] + + "&" + "assertion=" + encodeURIComponent(encodedAssertion) + "&scope=" + scopes; var xhr = new XMLHttpRequest(); xhr.open("POST", requestURL, false); From 159e067fed548474cf4d4743a2e39f053eb74c49 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 25 Jan 2017 14:03:38 +0530 Subject: [PATCH 009/193] changed integration client version --- .../org.wso2.carbon.apimgt.integration.client/pom.xml | 4 ++-- .../org.wso2.carbon.apimgt.integration.client.feature/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 60409715065..5d73fdd0538 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -14,13 +14,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.11-SNAPSHOT + 2.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.11-SNAPSHOT + 2.0.12-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index c3033e1aaa6..b0e8bad3c29 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.11-SNAPSHOT + 2.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 2.0.11-SNAPSHOT + 2.0.12-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org From 3c45f9af116de9f3a8e7298b1201c67440a89f32 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 25 Jan 2017 22:15:03 +0530 Subject: [PATCH 010/193] fixed api Id issue for subscription --- .../extension/APIManagementProviderServiceImpl.java | 7 +++++-- .../org.wso2.carbon.apimgt.integration.client/pom.xml | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index fdeccb2aca9..6575585b76e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -101,11 +101,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (apiList.getList() != null && apiList.getList().size() > 0) { for (APIInfo apiInfo : apiList.getList()) { Subscription subscription = new Subscription(); - subscription.setApiIdentifier(apiInfo.getId()); + //fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0 + String id = apiInfo.getProvider().replace("@", "-AT-") + + "-" + apiInfo.getName()+ "-" + apiInfo.getVersion(); + subscription.setApiIdentifier(id); subscription.setApplicationId(application.getApplicationId()); subscription.tier(ApiApplicationConstants.DEFAULT_TIER); SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet - (apiInfo.getId(), application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); + (id, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); boolean subscriptionExist = false; if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { for (Subscription subs : subscriptionList.getList()) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 5d73fdd0538..392a6e364c5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -67,7 +67,9 @@ org.wso2.carbon.utils, com.fasterxml.jackson.annotation, io.swagger.annotations, - org.wso2.carbon.core.util + org.wso2.carbon.core.util, + javax.xml, + org.wso2.carbon.base jsr311-api, From 0c4a78f3e90a8105cae276b39729d8d19bc453d3 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 26 Jan 2017 00:02:17 +0530 Subject: [PATCH 011/193] fixed api Id issue for subscription --- .../application/extension/APIManagementProviderServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6575585b76e..07f8a2a8a7e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -112,7 +112,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean subscriptionExist = false; if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { for (Subscription subs : subscriptionList.getList()) { - if (subs.getApiIdentifier().equals(apiInfo.getId()) && subs.getApplicationId().equals( + if (subs.getApiIdentifier().equals(id) && subs.getApplicationId().equals( application.getApplicationId())) { subscriptionExist = true; break; From 2988357eb91199d9dc444ea098c54f3e3fe56c68 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Thu, 26 Jan 2017 12:07:29 +0530 Subject: [PATCH 012/193] Changing the task to run for all the tenants --- .../task/impl/DeviceDetailsRetrieverTask.java | 39 +++-- .../policy/mgt/core/task/MonitoringTask.java | 133 ++++++++++-------- 2 files changed, 107 insertions(+), 65 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java index 69e49b78741..f13f0134783 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java @@ -22,17 +22,21 @@ package org.wso2.carbon.device.mgt.core.task.impl; import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager; import org.wso2.carbon.ntask.core.Task; +import org.wso2.carbon.user.api.Tenant; +import org.wso2.carbon.user.api.UserStoreException; import java.util.Map; public class DeviceDetailsRetrieverTask implements Task { private static Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class); -// private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(); + // private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(); private String deviceType; private String oppConfig; private OperationMonitoringTaskConfig operationMonitoringTaskConfig; @@ -58,16 +62,31 @@ public class DeviceDetailsRetrieverTask implements Task { if (log.isDebugEnabled()) { log.debug("Device details retrieving task started to run."); } - - DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, - operationMonitoringTaskConfig); - //pass the configurations also from here, monitoring tasks try { - deviceTaskManager.addOperations(); - } catch (DeviceMgtTaskException e) { - log.error( - "Error occurred while trying to add the operations to device to retrieve device details.", - e); + Tenant tenants[] = DeviceManagementDataHolder.getInstance(). + getRealmService().getTenantManager().getAllTenants(); + + for (Tenant tenant : tenants) { + + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain()); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId()); + DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, + operationMonitoringTaskConfig); + //pass the configurations also from here, monitoring tasks + try { + deviceTaskManager.addOperations(); + } catch (DeviceMgtTaskException e) { + log.error("Error occurred while trying to add the operations to " + + "device to retrieve device details.", e); + } + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + } catch (UserStoreException e) { + log.error("Error occurred while trying to get the available tenants", e); } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java index eb28b9e7d8e..61d455dadb2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -21,16 +21,20 @@ package org.wso2.carbon.policy.mgt.core.task; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.Task; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; +import org.wso2.carbon.user.api.Tenant; +import org.wso2.carbon.user.api.UserStoreException; import java.util.ArrayList; import java.util.List; @@ -59,69 +63,88 @@ public class MonitoringTask implements Task { log.debug("Monitoring task started to run."); } - MonitoringManager monitoringManager = PolicyManagementDataHolder.getInstance().getMonitoringManager(); - List deviceTypes = new ArrayList<>(); - List configDeviceTypes = new ArrayList<>(); try { - deviceTypes = monitoringManager.getDeviceTypes(); - for (String deviceType : deviceTypes) { - if (isPlatformExist(deviceType)) { - configDeviceTypes.add(deviceType); - } - } - } catch (PolicyComplianceException e) { - log.error("Error occurred while getting the device types."); - } - if (!deviceTypes.isEmpty()) { - try { - DeviceManagementProviderService deviceManagementProviderService = - PolicyManagementDataHolder.getInstance().getDeviceManagementService(); - for (String deviceType : configDeviceTypes) { - if (log.isDebugEnabled()) { - log.debug("Running task for device type : " + deviceType); - } - PolicyMonitoringManager monitoringService = - PolicyManagementDataHolder.getInstance().getDeviceManagementService() - .getPolicyMonitoringManager(deviceType); - List devices = deviceManagementProviderService.getAllDevices(deviceType); - if (monitoringService != null && !devices.isEmpty()) { - List notifiableDevices = new ArrayList<>(); - if (log.isDebugEnabled()) { - log.debug("Removing inactive and blocked devices from the list for the device type : " + - deviceType); - } - for (Device device : devices) { - - EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus(); - if (status.equals(EnrolmentInfo.Status.BLOCKED) || - status.equals(EnrolmentInfo.Status.REMOVED) || - status.equals(EnrolmentInfo.Status.UNCLAIMED) || - status.equals(EnrolmentInfo.Status.DISENROLLMENT_REQUESTED) || - status.equals(EnrolmentInfo.Status.SUSPENDED)) { - continue; - } else { - notifiableDevices.add(device); + Tenant tenants[] = DeviceManagementDataHolder.getInstance(). + getRealmService().getTenantManager().getAllTenants(); + + for (Tenant tenant : tenants) { + + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain()); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId()); + + MonitoringManager monitoringManager = PolicyManagementDataHolder.getInstance().getMonitoringManager(); + List deviceTypes = new ArrayList<>(); + List configDeviceTypes = new ArrayList<>(); + try { + deviceTypes = monitoringManager.getDeviceTypes(); + for (String deviceType : deviceTypes) { + if (isPlatformExist(deviceType)) { + configDeviceTypes.add(deviceType); } } - if (log.isDebugEnabled()) { - log.debug("Following devices selected to send the notification for " + deviceType); - for (Device device : notifiableDevices) { - log.debug(device.getDeviceIdentifier()); + } catch (PolicyComplianceException e) { + log.error("Error occurred while getting the device types."); + } + if (!deviceTypes.isEmpty()) { + try { + DeviceManagementProviderService deviceManagementProviderService = + PolicyManagementDataHolder.getInstance().getDeviceManagementService(); + for (String deviceType : configDeviceTypes) { + if (log.isDebugEnabled()) { + log.debug("Running task for device type : " + deviceType); + } + PolicyMonitoringManager monitoringService = + PolicyManagementDataHolder.getInstance().getDeviceManagementService() + .getPolicyMonitoringManager(deviceType); + List devices = deviceManagementProviderService.getAllDevices(deviceType); + if (monitoringService != null && !devices.isEmpty()) { + List notifiableDevices = new ArrayList<>(); + if (log.isDebugEnabled()) { + log.debug("Removing inactive and blocked devices from the list for the device type : " + + deviceType); + } + for (Device device : devices) { + + EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus(); + if (status.equals(EnrolmentInfo.Status.BLOCKED) || + status.equals(EnrolmentInfo.Status.REMOVED) || + status.equals(EnrolmentInfo.Status.UNCLAIMED) || + status.equals(EnrolmentInfo.Status.DISENROLLMENT_REQUESTED) || + status.equals(EnrolmentInfo.Status.SUSPENDED)) { + continue; + } else { + notifiableDevices.add(device); + } + } + if (log.isDebugEnabled()) { + log.debug("Following devices selected to send the notification for " + deviceType); + for (Device device : notifiableDevices) { + log.debug(device.getDeviceIdentifier()); + } + } + if (!notifiableDevices.isEmpty()) { + monitoringManager.addMonitoringOperation(notifiableDevices); + } + } } + if (log.isDebugEnabled()) { + log.debug("Monitoring task running completed."); + } + } catch (Exception e) { + log.error("Error occurred while trying to run a task.", e); } - if (!notifiableDevices.isEmpty()) { - monitoringManager.addMonitoringOperation(notifiableDevices); - } + } else { + log.info("No device types registered currently. So did not run the monitoring task."); } + } finally { + PrivilegedCarbonContext.endTenantFlow(); } - if (log.isDebugEnabled()) { - log.debug("Monitoring task running completed."); - } - } catch (Exception e) { - log.error("Error occurred while trying to run a task.", e); } - } else { - log.info("No device types registered currently. So did not run the monitoring task."); + + } catch (UserStoreException e) { + log.error("Error occurred while trying to get the available tenants", e); } } From 30119ff2631c1a0d892fc9599f13f85dabf371a2 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 26 Jan 2017 12:38:26 +0530 Subject: [PATCH 013/193] fixed data holder issue --- .../org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java index 61d455dadb2..dce753ba514 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -25,9 +25,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; -import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.Task; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; @@ -64,7 +61,7 @@ public class MonitoringTask implements Task { } try { - Tenant tenants[] = DeviceManagementDataHolder.getInstance(). + Tenant tenants[] = PolicyManagementDataHolder.getInstance(). getRealmService().getTenantManager().getAllTenants(); for (Tenant tenant : tenants) { From 21d8d14b7e05744f4c916b5a7a4c5c1de8825a7b Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Thu, 26 Jan 2017 14:50:12 +0530 Subject: [PATCH 014/193] Fixed multy tenancy issues related to android device type --- .../extension/api/filter/ApiPermissionFilter.java | 4 +++- .../src/main/webapp/META-INF/permissions.xml | 4 ++-- .../core/internal/DeviceManagementServiceComponent.java | 6 +++--- .../src/main/resources/dbscripts/cdm/h2.sql | 7 +------ .../src/main/resources/dbscripts/cdm/mssql.sql | 4 +--- .../src/main/resources/dbscripts/cdm/mysql.sql | 7 +------ .../src/main/resources/dbscripts/cdm/oracle.sql | 5 +---- .../src/main/resources/dbscripts/cdm/postgresql.sql | 7 +------ 8 files changed, 13 insertions(+), 31 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java index 5f05dfb3373..1f043c7b86e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java @@ -23,6 +23,7 @@ import org.wso2.carbon.apimgt.application.extension.api.util.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; @@ -120,7 +121,8 @@ public class ApiPermissionFilter implements Filter { try { UserRealm userRealm = APIUtil.getRealmService().getTenantUserRealm(PrivilegedCarbonContext .getThreadLocalCarbonContext().getTenantId()); - return userRealm.getAuthorizationManager().isUserAuthorized(username, permission, action); + String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username); + return userRealm.getAuthorizationManager().isUserAuthorized(tenantAwareUsername, permission, action); } catch (UserStoreException e) { String errorMsg = String.format("Unable to authorize the user : %s", username); log.error(errorMsg, e); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/permissions.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/permissions.xml index 591725fa120..9c41774ce57 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/permissions.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/permissions.xml @@ -37,14 +37,14 @@ Register application - /device-mgt/api/application + /manage/api/subscribe /register POST application_user Delete application - /device-mgt/api/application + /manage/api/subscribe /unregister DELETE application_user diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index adbf6cda436..ebf1e576543 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -404,13 +404,13 @@ public class DeviceManagementServiceComponent { } - protected void setDeviceTaskManagerService(DeviceTaskManagerService emailSenderService) { + protected void setDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) { if (log.isDebugEnabled()) { } - DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(emailSenderService); + DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(deviceTaskManagerService); } - protected void unsetDeviceTaskManagerService(DeviceTaskManagerService emailSenderService) { + protected void unsetDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) { if (log.isDebugEnabled()) { } DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index eb30a07b12e..498a439c076 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -145,12 +145,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE, TENANT_ID) - REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); CREATE TABLE IF NOT EXISTS DM_POLICY ( diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index db405cdc1eb..b1a029dbbbb 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -191,9 +191,7 @@ CREATE TABLE DM_PROFILE ( DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE FOREIGN KEY (DEVICE_TYPE, TENANT_ID) REFERENCES - DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID) ON DELETE NO ACTION ON UPDATE NO ACTION + PRIMARY KEY (ID) ); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY]') AND TYPE IN (N'U')) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql index 5d8faece3f2..f327b7b5993 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -168,12 +168,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE, TENANT_ID) - REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) )ENGINE = InnoDB; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index f2e71c9c9c3..c544452f52b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -268,10 +268,7 @@ CREATE TABLE DM_PROFILE ( DEVICE_TYPE VARCHAR2(300) NOT NULL , CREATED_TIME TIMESTAMP(0) NOT NULL , UPDATED_TIME TIMESTAMP(0) NOT NULL , - CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE, TENANT_ID) - REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID) + CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) ) / -- Generate ID using sequence and trigger diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index d5c035e26b1..9c1f7490a6c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -148,12 +148,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( TENANT_ID INTEGER NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME TIMESTAMP NOT NULL , - UPDATED_TIME TIMESTAMP NOT NULL , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE, TENANT_ID) - REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + UPDATED_TIME TIMESTAMP NOT NULL ); CREATE TABLE IF NOT EXISTS DM_POLICY ( From 7ba1dc989a1b6fa052b18134247d4800a8ae1d23 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Thu, 26 Jan 2017 14:51:30 +0530 Subject: [PATCH 015/193] Implemented a scope delegation validator --- .../handlers/ScopeValidationHandler.java | 131 +++++++++++++++ .../OAuthExtensionServiceComponent.java | 34 ++++ .../internal/OAuthExtensionsDataHolder.java | 24 ++- .../ExtendedJDBCScopeValidator.java | 2 +- .../PermissionBasedScopeValidator.java | 159 ++++++++++++++++++ .../validators/RoleBasedScopeValidator.java | 158 +++++++++++++++++ 6 files changed, 506 insertions(+), 2 deletions(-) create mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java create mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java create mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java new file mode 100644 index 00000000000..0c3964e9c0f --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.handlers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; +import org.wso2.carbon.identity.oauth.cache.CacheEntry; +import org.wso2.carbon.identity.oauth.cache.OAuthCache; +import org.wso2.carbon.identity.oauth.cache.OAuthCacheKey; +import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; +import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; +import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; +import org.wso2.carbon.identity.oauth2.model.ResourceScopeCacheEntry; +import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; + +import java.util.Map; + +public class ScopeValidationHandler extends OAuth2ScopeValidator { + + private final static Log log = LogFactory.getLog(ScopeValidationHandler.class); + private Map scopeValidators; + + private final String DEFAULT_PREFIX = "default"; + + public ScopeValidationHandler() { + scopeValidators = OAuthExtensionsDataHolder.getInstance().getScopeValidators(); + } + + public boolean validateScope(AccessTokenDO accessTokenDO, String resource) throws IdentityOAuth2Exception { + + //returns true if scope validators are not defined + if (scopeValidators == null || scopeValidators.isEmpty()) { + if(log.isDebugEnabled()){ + log.debug("OAuth2 scope validators are not loaded"); + } + return true; + } + + String resourceScope = getResourceScope(resource); + + //returns true if scope does not exist for the resource + if (resourceScope == null) { + if(log.isDebugEnabled()){ + log.debug("Resource '" + resource + "' is not protected with a scope"); + } + return true; + } + + String scope[] = resourceScope.split(":"); + String scopePrefix = scope[0]; + + OAuth2ScopeValidator scopeValidator = scopeValidators.get(scopePrefix); + + if (scopeValidator == null) { + if(log.isDebugEnabled()){ + log.debug("OAuth2 scope validator cannot be identified for '" + scopePrefix + "' scope prefix"); + } + + // loading default scope validator if matching validator is not found + scopeValidator = scopeValidators.get(DEFAULT_PREFIX); + if(log.isDebugEnabled()){ + log.debug("Loading default scope validator"); + } + + if (scopeValidator == null) { + if(log.isDebugEnabled()){ + log.debug("Default scope validator is not available"); + } + return true; + } + } + + // validate scope via relevant scope validator that matches with the prefix + return scopeValidator.validateScope(accessTokenDO, resourceScope); + } + + private String getResourceScope(String resource) { + + String resourceScope = null; + boolean cacheHit = false; + // Check the cache, if caching is enabled. + if (OAuthServerConfiguration.getInstance().isCacheEnabled()) { + OAuthCache oauthCache = OAuthCache.getInstance(); + OAuthCacheKey cacheKey = new OAuthCacheKey(resource); + CacheEntry result = oauthCache.getValueFromCache(cacheKey); + + //Cache hit + if (result instanceof ResourceScopeCacheEntry) { + resourceScope = ((ResourceScopeCacheEntry) result).getScope(); + cacheHit = true; + } + } + + TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + if (!cacheHit) { + try { + resourceScope = tokenMgtDAO.findScopeOfResource(resource); + } catch (IdentityOAuth2Exception e) { + log.error("Error occurred while retrieving scope for resource '" + resource + "'"); + } + + if (OAuthServerConfiguration.getInstance().isCacheEnabled()) { + OAuthCache oauthCache = OAuthCache.getInstance(); + OAuthCacheKey cacheKey = new OAuthCacheKey(resource); + ResourceScopeCacheEntry cacheEntry = new ResourceScopeCacheEntry(resourceScope); + //Store resourceScope in cache even if it is null (to avoid database calls when accessing resources for + //which scopes haven't been defined). + oauthCache.addToCache(cacheKey, cacheEntry); + } + } + return resourceScope; + } + +} diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java index dfcdc2dff27..63b4d051da6 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java @@ -24,7 +24,10 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; +import org.wso2.carbon.device.mgt.oauth.extensions.validators.ExtendedJDBCScopeValidator; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; +import org.wso2.carbon.identity.oauth2.validators.JDBCScopeValidator; +import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.CarbonUtils; @@ -46,6 +49,12 @@ import java.util.List; * policy="dynamic" * bind="setOAuth2ValidationService" * unbind="unsetOAuth2ValidationService" + * * @scr.reference name="scope.validator.service" + * interface="org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator" + * cardinality="0..n" + * policy="dynamic" + * bind="addScopeValidator" + * unbind="removeScopeValidator" */ public class OAuthExtensionServiceComponent { @@ -53,6 +62,8 @@ public class OAuthExtensionServiceComponent { private static final String REPOSITORY = "repository"; private static final String CONFIGURATION = "conf"; private static final String APIM_CONF_FILE = "api-manager.xml"; + private static final String PERMISSION_SCOPE_PREFIX = "perm"; + private static final String DEFAULT_PREFIX = "default"; @SuppressWarnings("unused") @@ -87,6 +98,13 @@ public class OAuthExtensionServiceComponent { } OAuthExtensionsDataHolder.getInstance().setWhitelistedScopes(whiteList); + + ExtendedJDBCScopeValidator permissionBasedScopeValidator = new ExtendedJDBCScopeValidator(); + JDBCScopeValidator roleBasedScopeValidator = new JDBCScopeValidator(); + OAuthExtensionsDataHolder.getInstance().addScopeValidator(permissionBasedScopeValidator, + PERMISSION_SCOPE_PREFIX); + OAuthExtensionsDataHolder.getInstance().addScopeValidator(roleBasedScopeValidator, + DEFAULT_PREFIX); } catch (APIManagementException e) { log.error("Error occurred while loading DeviceMgtConfig configurations", e); } @@ -147,5 +165,21 @@ public class OAuthExtensionServiceComponent { OAuthExtensionsDataHolder.getInstance().setoAuth2TokenValidationService(null); } + /** + * Add scope validator to the map. + * @param scopesValidator + */ + protected void addScopeValidator(OAuth2ScopeValidator scopesValidator) { + OAuthExtensionsDataHolder.getInstance().addScopeValidator(scopesValidator, DEFAULT_PREFIX); + } + + /** + * unset scope validator. + * @param scopesValidator + */ + protected void removeScopeValidator(OAuth2ScopeValidator scopesValidator) { + OAuthExtensionsDataHolder.getInstance().removeScopeValidator(); + } + } diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionsDataHolder.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionsDataHolder.java index 4f401b3db56..2c4f25705d5 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionsDataHolder.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/internal/OAuthExtensionsDataHolder.java @@ -19,9 +19,12 @@ package org.wso2.carbon.device.mgt.oauth.extensions.internal; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; +import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; import org.wso2.carbon.user.core.service.RealmService; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * This holds the OSGi service references required for oauth extensions bundle. @@ -31,10 +34,13 @@ public class OAuthExtensionsDataHolder { private RealmService realmService; private OAuth2TokenValidationService oAuth2TokenValidationService; private List whitelistedScopes; + private Map scopeValidators; private static OAuthExtensionsDataHolder thisInstance = new OAuthExtensionsDataHolder(); - private OAuthExtensionsDataHolder() {} + private OAuthExtensionsDataHolder() { + scopeValidators = new HashMap<>(); + } public static OAuthExtensionsDataHolder getInstance() { return thisInstance; @@ -71,4 +77,20 @@ public class OAuthExtensionsDataHolder { this.whitelistedScopes = whitelistedScopes; } + public Map getScopeValidators() { + return scopeValidators; + } + + public void setScopeValidators(Map scopeValidators) { + this.scopeValidators = scopeValidators; + } + + public void addScopeValidator(OAuth2ScopeValidator oAuth2ScopeValidator, String prefix) { + scopeValidators.put(prefix, oAuth2ScopeValidator); + } + + public void removeScopeValidator() { + scopeValidators = null; + } + } diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java index 8f5ffa25141..58c975bbec9 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java @@ -45,7 +45,7 @@ import java.util.List; import java.util.Set; @SuppressWarnings("unused") -public class ExtendedJDBCScopeValidator extends OAuth2ScopeValidator{ +public class ExtendedJDBCScopeValidator extends OAuth2ScopeValidator { private static final Log log = LogFactory.getLog(ExtendedJDBCScopeValidator.class); private static final String UI_EXECUTE = "ui.execute"; diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java new file mode 100644 index 00000000000..5be19a5a0c8 --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.validators; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; +import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; +import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; +import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; +import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +@SuppressWarnings("unused") +public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { + + private static final Log log = LogFactory.getLog(PermissionBasedScopeValidator.class); + private static final String UI_EXECUTE = "ui.execute"; + + + @Override + public boolean validateScope(AccessTokenDO accessTokenDO, String resourceScope) throws IdentityOAuth2Exception { + //Get the list of scopes associated with the access token + String[] scopes = accessTokenDO.getScope(); + + //If no scopes are associated with the token + if (scopes == null || scopes.length == 0) { + return true; + } + + TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + + List scopeList = new ArrayList<>(Arrays.asList(scopes)); + + //If the access token does not bear the scope required for accessing the Resource. + if(!scopeList.contains(resourceScope)){ + if(log.isDebugEnabled()){ + log.debug("Access token '" + accessTokenDO.getAccessToken() + "' does not bear the scope '" + + resourceScope + "'"); + } + return false; + } + + try { + //Get the permissions associated with the scope, if any + Set permissionsOfScope = tokenMgtDAO.getRolesOfScopeByScopeKey(resourceScope); + + //If the scope doesn't have any permissions associated with it. + if(permissionsOfScope == null || permissionsOfScope.isEmpty()){ + if(log.isDebugEnabled()){ + log.debug("Did not find any roles associated to the scope " + resourceScope); + } + return true; + } + + if(log.isDebugEnabled()){ + StringBuilder logMessage = new StringBuilder("Found permissions of scope '" + resourceScope + "' "); + for(String permission : permissionsOfScope){ + logMessage.append(permission); + logMessage.append(", "); + } + log.debug(logMessage.toString()); + } + + User authorizedUser = accessTokenDO.getAuthzUser(); + RealmService realmService = OAuthExtensionsDataHolder.getInstance().getRealmService(); + + int tenantId = realmService.getTenantManager().getTenantId(authorizedUser.getTenantDomain()); + + if (tenantId == 0 || tenantId == -1) { + tenantId = IdentityTenantUtil.getTenantIdOfUser(authorizedUser.getUserName()); + } + + AuthorizationManager authorizationManager; + String[] userRoles; + boolean tenantFlowStarted = false; + + try{ + //If this is a tenant user + if(tenantId != MultitenantConstants.SUPER_TENANT_ID){ + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + realmService.getTenantManager().getDomain(tenantId),true); + tenantFlowStarted = true; + } + + authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); + + } finally { + if (tenantFlowStarted) { + PrivilegedCarbonContext.endTenantFlow(); + } + } + boolean status = false; + String username = MultitenantUtils.getTenantAwareUsername(authorizedUser.getUserName()); + for (String permission : permissionsOfScope) { + if (authorizationManager != null) { + String userStore = authorizedUser.getUserStoreDomain(); + + if (userStore != null) { + status = authorizationManager + .isUserAuthorized(userStore + "/" + username, permission, UI_EXECUTE); + } else { + status = authorizationManager.isUserAuthorized(username , permission, UI_EXECUTE); + } + if (status) { + break; + } + } + } + + if (status) { + if(log.isDebugEnabled()){ + log.debug("User '" + authorizedUser.getUserName() + "' is authorized"); + } + return true; + } + + if(log.isDebugEnabled()){ + log.debug("No permissions associated for the user " + authorizedUser.getUserName()); + } + return false; + + } catch (UserStoreException e) { + //Log and return since we do not want to stop issuing the token in case of scope validation failures. + log.error("Error when getting the tenant's UserStoreManager or when getting roles of user ", e); + return false; + } + } + +} diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java new file mode 100644 index 00000000000..593d9d0c89d --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.validators; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; +import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; +import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; +import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + + +/** + * The JDBC Scope Validation implementation. This validates the Resource's scope (stored in IDN_OAUTH2_RESOURCE_SCOPE) + * against the Access Token's scopes. + */ +public class RoleBasedScopeValidator extends OAuth2ScopeValidator { + + Log log = LogFactory.getLog(RoleBasedScopeValidator.class); + + @Override + public boolean validateScope(AccessTokenDO accessTokenDO, String resourceScope) throws IdentityOAuth2Exception { + + //Get the list of scopes associated with the access token + String[] scopes = accessTokenDO.getScope(); + + //If no scopes are associated with the token + if (scopes == null || scopes.length == 0) { + return true; + } + + TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + + List scopeList = new ArrayList<>(Arrays.asList(scopes)); + + //If the access token does not bear the scope required for accessing the Resource. + if(!scopeList.contains(resourceScope)){ + if(log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.ACCESS_TOKEN)){ + log.debug("Access token '" + accessTokenDO.getAccessToken() + "' does not bear the scope '" + + resourceScope + "'"); + } + return false; + } + + try { + //Get the roles associated with the scope, if any + Set rolesOfScope = tokenMgtDAO.getRolesOfScopeByScopeKey(resourceScope); + + //If the scope doesn't have any roles associated with it. + if(rolesOfScope == null || rolesOfScope.isEmpty()){ + if(log.isDebugEnabled()){ + log.debug("Did not find any roles associated to the scope " + resourceScope); + } + return true; + } + + if(log.isDebugEnabled()){ + StringBuilder logMessage = new StringBuilder("Found roles of scope '" + resourceScope + "' "); + for(String role : rolesOfScope){ + logMessage.append(role); + logMessage.append(", "); + } + log.debug(logMessage.toString()); + } + + User authzUser = accessTokenDO.getAuthzUser(); + RealmService realmService = OAuthExtensionsDataHolder.getInstance().getRealmService(); + + int tenantId = realmService.getTenantManager(). + getTenantId(authzUser.getTenantDomain()); + + if (tenantId == 0 || tenantId == -1) { + tenantId = IdentityTenantUtil.getTenantIdOfUser(authzUser.getUserName()); + } + + UserStoreManager userStoreManager; + String[] userRoles; + boolean tenantFlowStarted = false; + + try{ + //If this is a tenant user + if(tenantId != MultitenantConstants.SUPER_TENANT_ID){ + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + realmService.getTenantManager().getDomain(tenantId),true); + tenantFlowStarted = true; + } + + userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); + userRoles = userStoreManager.getRoleListOfUser( + MultitenantUtils.getTenantAwareUsername(authzUser.getUserName())); + } finally { + if (tenantFlowStarted) { + PrivilegedCarbonContext.endTenantFlow(); + } + } + + if(userRoles != null && userRoles.length > 0){ + if(log.isDebugEnabled()){ + StringBuilder logMessage = new StringBuilder("Found roles of user "); + logMessage.append(authzUser.getUserName()); + logMessage.append(" "); + for(String role : userRoles){ + logMessage.append(role); + logMessage.append(", "); + } + log.debug(logMessage.toString()); + } + //Check if the user still has a valid role for this scope. + rolesOfScope.retainAll(Arrays.asList(userRoles)); + return !rolesOfScope.isEmpty(); + } + else{ + if(log.isDebugEnabled()){ + log.debug("No roles associated for the user " + authzUser.getUserName()); + } + return false; + } + + } catch (UserStoreException e) { + //Log and return since we do not want to stop issuing the token in case of scope validation failures. + log.error("Error when getting the tenant's UserStoreManager or when getting roles of user ", e); + return false; + } + } +} From 38f61adf9457322b7782c95ab3f02b3a7d77f5b6 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Mon, 30 Jan 2017 22:14:26 +0530 Subject: [PATCH 016/193] few changes after testing multi tenancy --- ...ationManagerExtensionServiceComponent.java | 1 + .../pom.xml | 1 - .../pom.xml | 38 +++++++++---------- .../ExtendedSAML2BearerGrantHandler.java | 4 +- .../authenticator/BasicAuthAuthenticator.java | 2 +- .../pom.xml | 4 -- .../pom.xml | 4 -- .../conf/webapp-authenticator-config.xml | 1 + pom.xml | 3 +- 9 files changed, 26 insertions(+), 32 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index c79f80d3b2b..18bdec251af 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -49,6 +49,7 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" + * @scr.reference name="integration.client.service" * interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService" * cardinality="1..1" * policy="dynamic" diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 392a6e364c5..0bac2f2121d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -55,7 +55,6 @@ feign.codec, feign.auth, feign.gson, - javax.ws.rs, javax.xml.bind, javax.xml.bind.annotation, javax.xml.parsers;resolution:=optional, diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 49ebf9d72ef..1cd4137b4c1 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -87,27 +87,27 @@ org.apache.commons.logging, org.osgi.service.component, org.wso2.carbon.device.mgt.oauth.extensions.*, - org.wso2.carbon.identity.application.common.model, - org.wso2.carbon.identity.oauth.callback, - org.wso2.carbon.identity.oauth2, - org.wso2.carbon.identity.oauth2.model, - org.wso2.carbon.identity.oauth2.validators, + org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth.callback;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.model;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.validators;version="${carbon.identity.framework.version.range}", org.wso2.carbon.user.api, org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, org.json.simple, javax.cache, - org.wso2.carbon.identity.core.util, - org.wso2.carbon.identity.oauth2.dto, - org.wso2.carbon.identity.oauth2.token, + org.wso2.carbon.identity.core.util;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.dto;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.token;version="${carbon.identity.framework.version.range}", org.wso2.carbon.utils, org.wso2.carbon.context, - org.wso2.carbon.identity.oauth.cache, - org.wso2.carbon.identity.oauth.config, - org.wso2.carbon.identity.oauth2.dao, + org.wso2.carbon.identity.oauth.cache;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth.config;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.dao;version="${carbon.identity.framework.version.range}", org.wso2.carbon.utils.multitenancy, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.identity.application.authentication.framework.model, + org.wso2.carbon.identity.application.authentication.framework.model;version="${carbon.identity.framework.version.range}", org.wso2.carbon.base, org.apache.commons.collections, org.apache.commons.lang, @@ -116,15 +116,15 @@ org.opensaml.security, org.opensaml.xml.*, org.w3c.dom, - org.wso2.carbon.identity.application.common.util, - org.wso2.carbon.identity.base, - org.wso2.carbon.identity.oauth2.token.handlers.grant.*, - org.wso2.carbon.identity.oauth2.util, - org.wso2.carbon.idp.mgt, + org.wso2.carbon.identity.application.common.util;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.base;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.token.handlers.grant.*;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth2.util;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.idp.mgt;version="${carbon.identity.framework.version.range}", org.opensaml.common.xml, - org.wso2.carbon.identity.oauth.common, + org.wso2.carbon.identity.oauth.common;version="${carbon.identity.framework.version.range}", org.opensaml, - org.wso2.carbon.apimgt.keymgt.issuers + org.wso2.carbon.apimgt.keymgt.*;version="${carbon.api.mgt.version.range}" diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 0ba3d273fb3..94af1a46614 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -38,7 +38,7 @@ import org.opensaml.xml.security.x509.X509Credential; import org.opensaml.xml.signature.SignatureValidator; import org.opensaml.xml.validation.ValidationException; import org.w3c.dom.NodeList; -import org.wso2.carbon.apimgt.keymgt.issuers.ScopesIssuingHandler; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; @@ -101,7 +101,7 @@ public class ExtendedSAML2BearerGrantHandler extends AbstractAuthorizationGrantH @Override public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return ScopesIssuingHandler.getInstance().setScopes(tokReqMsgCtx); + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } /** diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 3b06468fe92..c4d2da95b6d 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -73,7 +73,7 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { boolean authenticated = userStore.authenticate(username, credentials.getPassword()); if (authenticated) { authenticationInfo.setStatus(Status.CONTINUE); - authenticationInfo.setUsername(credentials.getUsername()); + authenticationInfo.setUsername(username); authenticationInfo.setTenantDomain(Utils.getTenantDomain(tenantId)); authenticationInfo.setTenantId(tenantId); } else { diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index b0e8bad3c29..212ed5ae90c 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -102,10 +102,6 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version} - - org.wso2.carbon.core.server:${carbon.kernel.version} - - diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index ec39b16e2b5..4afc10925fa 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -106,10 +106,6 @@ net.minidev:json-smart:${json.smart.version} - - org.wso2.carbon.core.server:${carbon.kernel.449.version} - - diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml index b3a4f47c175..4b727a28c23 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml @@ -21,6 +21,7 @@ org.wso2.carbon.webapp.authenticator.framework.authenticator.JWTAuthenticator + wso2carbon wso2carbon wso2carbon wso2carbon diff --git a/pom.xml b/pom.xml index 6abdc060971..8e99d808f7a 100644 --- a/pom.xml +++ b/pom.xml @@ -1766,6 +1766,7 @@ 5.7.0 + [5.0.0, 6.0.0) 5.3.1 5.3.0 @@ -1797,7 +1798,7 @@ [2.6.0,3.0.0) - 6.1.35 + 6.1.60 (6.0.0,7.0.0] From 41353f8014138a6ceb639fbb25496cd166cb8cd6 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Tue, 31 Jan 2017 16:37:33 +0530 Subject: [PATCH 017/193] Fixed issues in scope validation feature --- .../pom.xml | 22 +++---------------- .../handlers/ScopeValidationHandler.java | 2 +- .../ExtendedSAML2BearerGrantHandler.java | 4 ++-- pom.xml | 3 ++- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 49ebf9d72ef..21fc8bc1344 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -87,27 +87,16 @@ org.apache.commons.logging, org.osgi.service.component, org.wso2.carbon.device.mgt.oauth.extensions.*, - org.wso2.carbon.identity.application.common.model, - org.wso2.carbon.identity.oauth.callback, - org.wso2.carbon.identity.oauth2, - org.wso2.carbon.identity.oauth2.model, - org.wso2.carbon.identity.oauth2.validators, + org.wso2.carbon.identity.*;version="${carbon.identity.framework.version.range}", org.wso2.carbon.user.api, org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, org.json.simple, javax.cache, - org.wso2.carbon.identity.core.util, - org.wso2.carbon.identity.oauth2.dto, - org.wso2.carbon.identity.oauth2.token, org.wso2.carbon.utils, org.wso2.carbon.context, - org.wso2.carbon.identity.oauth.cache, - org.wso2.carbon.identity.oauth.config, - org.wso2.carbon.identity.oauth2.dao, org.wso2.carbon.utils.multitenancy, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.identity.application.authentication.framework.model, org.wso2.carbon.base, org.apache.commons.collections, org.apache.commons.lang, @@ -116,15 +105,10 @@ org.opensaml.security, org.opensaml.xml.*, org.w3c.dom, - org.wso2.carbon.identity.application.common.util, - org.wso2.carbon.identity.base, - org.wso2.carbon.identity.oauth2.token.handlers.grant.*, - org.wso2.carbon.identity.oauth2.util, - org.wso2.carbon.idp.mgt, + org.wso2.carbon.idp.mgt;version="${carbon.identity.framework.version.range}", org.opensaml.common.xml, - org.wso2.carbon.identity.oauth.common, org.opensaml, - org.wso2.carbon.apimgt.keymgt.issuers + org.wso2.carbon.apimgt.keymgt;version="${carbon.api.mgt.version.range}" diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java index 0c3964e9c0f..e182c0b3a03 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java @@ -88,7 +88,7 @@ public class ScopeValidationHandler extends OAuth2ScopeValidator { } // validate scope via relevant scope validator that matches with the prefix - return scopeValidator.validateScope(accessTokenDO, resourceScope); + return scopeValidator.validateScope(accessTokenDO, resource); } private String getResourceScope(String resource) { diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 0ba3d273fb3..94af1a46614 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -38,7 +38,7 @@ import org.opensaml.xml.security.x509.X509Credential; import org.opensaml.xml.signature.SignatureValidator; import org.opensaml.xml.validation.ValidationException; import org.w3c.dom.NodeList; -import org.wso2.carbon.apimgt.keymgt.issuers.ScopesIssuingHandler; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; @@ -101,7 +101,7 @@ public class ExtendedSAML2BearerGrantHandler extends AbstractAuthorizationGrantH @Override public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return ScopesIssuingHandler.getInstance().setScopes(tokReqMsgCtx); + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } /** diff --git a/pom.xml b/pom.xml index 6abdc060971..4e0e915afe6 100644 --- a/pom.xml +++ b/pom.xml @@ -1766,6 +1766,7 @@ 5.7.0 + [5.0.0, 6.0.0) 5.3.1 5.3.0 @@ -1797,7 +1798,7 @@ [2.6.0,3.0.0) - 6.1.35 + 6.1.64 (6.0.0,7.0.0] From 4ec7762a5c5609c6da82b6421757f81e96e3443d Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 31 Jan 2017 23:06:19 +0530 Subject: [PATCH 018/193] made it use the default saml grant type --- .../devicemgt/app/conf/config.json | 4 +- .../pom.xml | 36 +- .../ExtendedSAML2BearerGrantHandler.java | 528 +----------------- 3 files changed, 13 insertions(+), 555 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index a3a81e4446a..5323b5814c6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -19,10 +19,10 @@ "owner": "admin@carbon.super", "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", "apiManagerClientAppRegistrationServiceURL": "https://%iot.gateway.host%:%iot.gateway.https.port%/api-application-registration/register/tenants", - "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-carbon urn:ietf:params:oauth:grant-type:jwt-bearer", + "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer", "tokenScope": "admin", "callbackUrl": "%https.ip%/api/device-mgt/v1.0", - "samlGrantTypeName": "urn:ietf:carbon:signed:grant-type:saml2-bearer" + "samlGrantTypeName": "urn:ietf:params:oauth:grant-type:saml2-bearer" }, "tokenServiceURL": "https://%iot.gateway.host%:%iot.gateway.https.port%/token" }, diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 1cd4137b4c1..11a6afac842 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -83,48 +83,24 @@ org.wso2.carbon.device.mgt.oauth.extensions.* - javax.security.auth.*, org.apache.commons.logging, org.osgi.service.component, - org.wso2.carbon.device.mgt.oauth.extensions.*, org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth.callback;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.model;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.validators;version="${carbon.identity.framework.version.range}", org.wso2.carbon.user.api, org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, org.json.simple, javax.cache, org.wso2.carbon.identity.core.util;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.dto;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.token;version="${carbon.identity.framework.version.range}", org.wso2.carbon.utils, org.wso2.carbon.context, - org.wso2.carbon.identity.oauth.cache;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth.config;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.dao;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.utils.multitenancy, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.identity.application.authentication.framework.model;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.base, - org.apache.commons.collections, - org.apache.commons.lang, - org.joda.time, - org.opensaml.saml2.core, - org.opensaml.security, - org.opensaml.xml.*, - org.w3c.dom, - org.wso2.carbon.identity.application.common.util;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.identity.oauth.*;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.apimgt.keymgt.*;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.base, + org.wso2.carbon.identity.application.authentication.framework.model;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.base;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.token.handlers.grant.*;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.util;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.idp.mgt;version="${carbon.identity.framework.version.range}", - org.opensaml.common.xml, - org.wso2.carbon.identity.oauth.common;version="${carbon.identity.framework.version.range}", - org.opensaml, - org.wso2.carbon.apimgt.keymgt.*;version="${carbon.api.mgt.version.range}" + org.wso2.carbon.identity.oauth2.*;version="${carbon.identity.framework.version.range}", + org.wso2.carbon.utils.multitenancy diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 94af1a46614..5caededdafd 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -18,552 +18,34 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; -import org.opensaml.DefaultBootstrap; -import org.opensaml.common.xml.SAMLConstants; -import org.opensaml.saml2.core.Assertion; -import org.opensaml.saml2.core.Audience; -import org.opensaml.saml2.core.AudienceRestriction; -import org.opensaml.saml2.core.Conditions; -import org.opensaml.saml2.core.SubjectConfirmation; -import org.opensaml.security.SAMLSignatureProfileValidator; -import org.opensaml.xml.ConfigurationException; -import org.opensaml.xml.XMLObject; -import org.opensaml.xml.security.x509.X509Credential; -import org.opensaml.xml.signature.SignatureValidator; -import org.opensaml.xml.validation.ValidationException; -import org.w3c.dom.NodeList; import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; -import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; -import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; -import org.wso2.carbon.identity.application.common.model.IdentityProvider; -import org.wso2.carbon.identity.application.common.model.Property; -import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; -import org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil; -import org.wso2.carbon.identity.base.IdentityConstants; -import org.wso2.carbon.identity.base.IdentityException; -import org.wso2.carbon.identity.core.util.IdentityUtil; -import org.wso2.carbon.identity.oauth.common.OAuthConstants; -import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; -import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; -import org.wso2.carbon.identity.oauth2.token.handlers.grant.AbstractAuthorizationGrantHandler; -import org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2TokenCallbackHandler; -import org.wso2.carbon.identity.oauth2.util.X509CredentialImpl; -import org.wso2.carbon.idp.mgt.IdentityProviderManagementException; -import org.wso2.carbon.idp.mgt.IdentityProviderManager; +import org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** - * This looks up for idp in supertenant space. + * This sets up user with tenant aware username. */ @SuppressWarnings("unused") -public class ExtendedSAML2BearerGrantHandler extends AbstractAuthorizationGrantHandler { +public class ExtendedSAML2BearerGrantHandler extends SAML2BearerGrantHandler { private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class); - SAMLSignatureProfileValidator profileValidator = null; - private static final String ASSERTION_IDENTIFIER = "assertion"; - - @Override - public void init() throws IdentityOAuth2Exception { - - super.init(); - - Thread thread = Thread.currentThread(); - ClassLoader loader = thread.getContextClassLoader(); - thread.setContextClassLoader(this.getClass().getClassLoader()); - - try { - DefaultBootstrap.bootstrap(); - } catch (ConfigurationException e) { - log.error("Error in bootstrapping the OpenSAML2 library", e); - throw new IdentityOAuth2Exception("Error in bootstrapping the OpenSAML2 library"); - } finally { - thread.setContextClassLoader(loader); - } - - profileValidator = new SAMLSignatureProfileValidator(); - } @Override public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } - /** - * We're validating the SAML token that we receive from the request. Through the assertion parameter is the POST - * request. A request format that we handle here looks like, - *

- * POST /token.oauth2 HTTP/1.1 - * Host: as.example.com - * Content-Type: application/x-www-form-urlencoded - *

- * grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Asaml2-bearer& - * assertion=PHNhbWxwOl...[omitted for brevity]...ZT4 - * - * @param tokReqMsgCtx Token message request context - * @return true if validation is successful, false otherwise - * @throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - */ @Override public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { - RequestParameter[] parameters = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters(); - for (RequestParameter parameter : parameters) { - if (ASSERTION_IDENTIFIER.equals(parameter.getKey())) { - tokReqMsgCtx.getOauth2AccessTokenReqDTO().setAssertion(parameter.getValue()[0]); - } - } - if(!super.validateGrant(tokReqMsgCtx)){ return false; } - - Assertion assertion = null; - IdentityProvider identityProvider = null; - String tokenEndpointAlias = null; - String tenantDomain = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getTenantDomain(); - if (tenantDomain == null || "".equals(tenantDomain)) { - tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; - } - - // Logging the SAML token - if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.SAML_ASSERTION)) { - log.debug("Received SAML assertion : " + - new String(Base64.decodeBase64(tokReqMsgCtx.getOauth2AccessTokenReqDTO().getAssertion())) - ); - } - - try { - XMLObject samlObject = IdentityUtil.unmarshall(new String(Base64.decodeBase64( - tokReqMsgCtx.getOauth2AccessTokenReqDTO().getAssertion()))); - // Validating for multiple assertions - NodeList assertionList = samlObject.getDOM().getElementsByTagNameNS(SAMLConstants.SAML20_NS, "Assertion"); - if (assertionList.getLength() > 0) { - log.error("Invalid schema for SAML2 Assertion. Nested assertions detected."); - return false; - } - - if (samlObject instanceof Assertion) { - assertion = (Assertion) samlObject; - } else { - log.error("Only Assertion objects are validated in SAML2Bearer Grant Type"); - return false; - } - } catch (IdentityException e) { - // fault in the saml2 assertion - if(log.isDebugEnabled()){ - log.debug("Error while unmashalling the assertion", e); - } - return false; - } - - if (assertion == null) { - log.debug("Assertion is null, cannot continue"); - return false; - } - - /* - The Assertion MUST contain a element. The subject MAY identify the resource owner for whom - the access token is being requested. For client authentication, the Subject MUST be the "client_id" - of the OAuth client. When using an Assertion as an authorization grant, the Subject SHOULD identify - an authorized accessor for whom the access token is being requested (typically the resource owner, or - an authorized delegate). Additional information identifying the subject/principal of the transaction - MAY be included in an . - */ - if (assertion.getSubject() != null) { - String subjectIdentifier = assertion.getSubject().getNameID().getValue(); - if (StringUtils.isBlank(subjectIdentifier)) { - if (log.isDebugEnabled()){ - log.debug("NameID in Assertion cannot be empty"); - } - return false; - } - AuthenticatedUser user = - AuthenticatedUser.createFederateAuthenticatedUserFromSubjectIdentifier(subjectIdentifier); - user.setUserName(MultitenantUtils.getTenantAwareUsername(subjectIdentifier)); - // we take a tenant domain of the authorized user to be the tenant domain of the OAuth app - user.setTenantDomain(tenantDomain); - tokReqMsgCtx.setAuthorizedUser(user); - tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; - } else { - if (log.isDebugEnabled()) { - log.debug("Cannot find a Subject in the Assertion"); - } - return false; - } - - if (assertion.getIssuer() == null || "".equals(assertion.getIssuer().getValue())) { - if (log.isDebugEnabled()) { - log.debug("Issuer is empty in the SAML assertion"); - } - return false; - } else { - try { - identityProvider = IdentityProviderManager.getInstance(). - getIdPByAuthenticatorPropertyValue("IdPEntityId", - assertion.getIssuer().getValue(), tenantDomain, false); - // IF Federated IDP not found get the resident IDP and check, - // resident IDP entityID == issuer - if (identityProvider != null) { - if (IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME.equals( - identityProvider.getIdentityProviderName())) { - identityProvider = IdentityProviderManager.getInstance().getResidentIdP(tenantDomain); - - FederatedAuthenticatorConfig[] fedAuthnConfigs = - identityProvider.getFederatedAuthenticatorConfigs(); - String idpEntityId = null; - - // Get SAML authenticator - FederatedAuthenticatorConfig samlAuthenticatorConfig = - IdentityApplicationManagementUtil.getFederatedAuthenticator(fedAuthnConfigs, - IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); - // Get Entity ID from SAML authenticator - Property samlProperty = IdentityApplicationManagementUtil.getProperty( - samlAuthenticatorConfig.getProperties(), - IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID); - if (samlProperty != null) { - idpEntityId = samlProperty.getValue(); - } - - if (idpEntityId == null || !assertion.getIssuer().getValue().equals(idpEntityId)) { - if(log.isDebugEnabled()) { - log.debug("SAML Token Issuer verification failed against resident Identity Provider " + - "in tenant : " + tenantDomain + ". Received : " + - assertion.getIssuer().getValue() + ", Expected : " + idpEntityId); - } - return false; - } - - // Get OpenIDConnect authenticator == OAuth - // authenticator - FederatedAuthenticatorConfig oauthAuthenticatorConfig = - IdentityApplicationManagementUtil.getFederatedAuthenticator(fedAuthnConfigs, - IdentityApplicationConstants.Authenticator.OIDC.NAME); - // Get OAuth token endpoint - Property oauthProperty = IdentityApplicationManagementUtil.getProperty( - oauthAuthenticatorConfig.getProperties(), - IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_TOKEN_URL); - if (oauthProperty != null) { - tokenEndpointAlias = oauthProperty.getValue(); - } - } else { - // Get Alias from Federated IDP - tokenEndpointAlias = identityProvider.getAlias(); - } - } else { - if(log.isDebugEnabled()) { - log.debug("SAML Token Issuer : " + assertion.getIssuer().getValue() + - " not registered as a local Identity Provider in tenant : " + tenantDomain); - } - return false; - } - } catch (IdentityProviderManagementException e) { - throw new IdentityOAuth2Exception("Error while getting an Identity Provider for issuer value : " + - assertion.getIssuer().getValue(), e); - } - } - - /* - The Assertion MUST contain element with an element with an - element containing a URI reference that identifies the authorization server, or the service provider - SAML entity of its controlling domain, as an intended audience. The token endpoint URL of the - authorization server MAY be used as an acceptable value for an element. The authorization - server MUST verify that it is an intended audience for the Assertion. - */ - - if (StringUtils.isBlank(tokenEndpointAlias)) { - if (log.isDebugEnabled()){ - String errorMsg = "Token Endpoint alias has not been configured in the Identity Provider : " - + identityProvider.getIdentityProviderName() + " in tenant : " + tenantDomain; - log.debug(errorMsg); - } - return false; - } - - Conditions conditions = assertion.getConditions(); - if (conditions != null) { - //Set validity period extracted from SAML Assertion - long curTimeInMillis = Calendar.getInstance().getTimeInMillis(); - tokReqMsgCtx.setValidityPeriod(conditions.getNotOnOrAfter().getMillis() - curTimeInMillis); - List audienceRestrictions = conditions.getAudienceRestrictions(); - if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) { - boolean audienceFound = false; - for (AudienceRestriction audienceRestriction : audienceRestrictions) { - if (CollectionUtils.isNotEmpty(audienceRestriction.getAudiences())) { - for (Audience audience : audienceRestriction.getAudiences()) { - if (audience.getAudienceURI().equals(tokenEndpointAlias)) { - audienceFound = true; - break; - } - } - } - if (audienceFound) { - break; - } - } - if (!audienceFound) { - if (log.isDebugEnabled()) { - log.debug("SAML Assertion Audience Restriction validation failed against the Audience : " + - tokenEndpointAlias + " of Identity Provider : " + - identityProvider.getIdentityProviderName() + " in tenant : " + tenantDomain); - } - return false; - } - } else { - if (log.isDebugEnabled()) { - String message = "SAML Assertion doesn't contain AudienceRestrictions"; - log.debug(message); - } - return false; - } - } else { - if (log.isDebugEnabled()) { - String message = "SAML Assertion doesn't contain Conditions"; - log.debug(message); - } - return false; - } - - - /* - The Assertion MUST have an expiry that limits the time window during which it can be used. The expiry - can be expressed either as the NotOnOrAfter attribute of the element or as the NotOnOrAfter - attribute of a suitable element. - */ - - /* - The element MUST contain at least one element that allows the - authorization server to confirm it as a Bearer Assertion. Such a element MUST - have a Method attribute with a value of "urn:oasis:names:tc:SAML:2.0:cm:bearer". The - element MUST contain a element, unless the Assertion - has a suitable NotOnOrAfter attribute on the element, in which case the - element MAY be omitted. When present, the element - MUST have a Recipient attribute with a value indicating the token endpoint URL of the authorization - server (or an acceptable alias). The authorization server MUST verify that the value of the Recipient - attribute matches the token endpoint URL (or an acceptable alias) to which the Assertion was delivered. - The element MUST have a NotOnOrAfter attribute that limits the window during - which the Assertion can be confirmed. The element MAY also contain an Address - attribute limiting the client address from which the Assertion can be delivered. Verification of the - Address is at the discretion of the authorization server. - */ - - DateTime notOnOrAfterFromConditions = null; - Map notOnOrAfterFromAndNotBeforeSubjectConfirmations = new HashMap<>(); - boolean bearerFound = false; - List recipientURLS = new ArrayList<>(); - - if (assertion.getConditions() != null && assertion.getConditions().getNotOnOrAfter() != null) { - notOnOrAfterFromConditions = assertion.getConditions().getNotOnOrAfter(); - } - - DateTime notBeforeConditions = null; - if (assertion.getConditions() != null && assertion.getConditions().getNotBefore() != null) { - notBeforeConditions = assertion.getConditions().getNotBefore(); - } - - List subjectConfirmations = assertion.getSubject().getSubjectConfirmations(); - if (subjectConfirmations != null && !subjectConfirmations.isEmpty()) { - for (SubjectConfirmation s : subjectConfirmations) { - if (s.getMethod() != null) { - if (s.getMethod().equals(OAuthConstants.OAUTH_SAML2_BEARER_METHOD)) { - bearerFound = true; - } - } else { - if (log.isDebugEnabled()){ - log.debug("Cannot find Method attribute in SubjectConfirmation " + s.toString()); - } - return false; - } - - if (s.getSubjectConfirmationData() != null) { - if (s.getSubjectConfirmationData().getRecipient() != null) { - recipientURLS.add(s.getSubjectConfirmationData().getRecipient()); - } - if (s.getSubjectConfirmationData().getNotOnOrAfter() != null || s.getSubjectConfirmationData() - .getNotBefore() != null) { - notOnOrAfterFromAndNotBeforeSubjectConfirmations.put(s.getSubjectConfirmationData().getNotOnOrAfter(), - s.getSubjectConfirmationData().getNotBefore()); - } else { - if (log.isDebugEnabled()){ - log.debug("Cannot find NotOnOrAfter and NotBefore attributes in " + - "SubjectConfirmationData " + - s.getSubjectConfirmationData().toString()); - } - } - } else { - if (s.getSubjectConfirmationData() == null && notOnOrAfterFromConditions == null) { - if (log.isDebugEnabled()){ - log.debug("Neither can find NotOnOrAfter attribute in Conditions nor SubjectConfirmationData" + - "in SubjectConfirmation " + s.toString()); - } - return false; - } - - if (s.getSubjectConfirmationData() == null && notBeforeConditions == null) { - if (log.isDebugEnabled()){ - log.debug("Neither can find NotBefore attribute in Conditions nor SubjectConfirmationData" + - "in SubjectConfirmation " + s.toString()); - } - return false; - } - } - } - } else { - if (log.isDebugEnabled()){ - log.debug("No SubjectConfirmation exist in Assertion"); - } - return false; - } - - if (!bearerFound) { - if (log.isDebugEnabled()){ - log.debug("Failed to find a SubjectConfirmation with a Method attribute having : " + - OAuthConstants.OAUTH_SAML2_BEARER_METHOD); - } - return false; - } - - if (CollectionUtils.isNotEmpty(recipientURLS) && !recipientURLS.contains(tokenEndpointAlias)) { - if (log.isDebugEnabled()){ - log.debug("None of the recipient URLs match against the token endpoint alias : " + tokenEndpointAlias + - " of Identity Provider " + identityProvider.getIdentityProviderName() + " in tenant : " + - tenantDomain); - } - return false; - } - - /* - The authorization server MUST verify that the NotOnOrAfter instant has not passed, subject to allowable - clock skew between systems. An invalid NotOnOrAfter instant on the element invalidates - the entire Assertion. An invalid NotOnOrAfter instant on a element only - invalidates the individual . The authorization server MAY reject Assertions with - a NotOnOrAfter instant that is unreasonably far in the future. The authorization server MAY ensure - that Bearer Assertions are not replayed, by maintaining the set of used ID values for the length of - time for which the Assertion would be considered valid based on the applicable NotOnOrAfter instant. - */ - if (notOnOrAfterFromConditions != null && notOnOrAfterFromConditions.compareTo(new DateTime()) < 1) { - // notOnOrAfter is an expired timestamp - if (log.isDebugEnabled()){ - log.debug("NotOnOrAfter is having an expired timestamp in Conditions element"); - } - return false; - } - - if (notBeforeConditions != null && notBeforeConditions.compareTo(new DateTime()) >= 1) { - // notBefore is an early timestamp - if (log.isDebugEnabled()){ - log.debug("NotBefore is having an early timestamp in Conditions element"); - } - return false; - } - - boolean validSubjectConfirmationDataExists = false; - if (!notOnOrAfterFromAndNotBeforeSubjectConfirmations.isEmpty()) { - for (Map.Entry entry : notOnOrAfterFromAndNotBeforeSubjectConfirmations.entrySet()) { - if (entry.getKey() != null) { - if (entry.getKey().compareTo(new DateTime()) >= 1) { - validSubjectConfirmationDataExists = true; - } - } - if (entry.getValue() != null) { - if (entry.getValue().compareTo(new DateTime()) < 1) { - validSubjectConfirmationDataExists = true; - } - } - } - } - - if (notOnOrAfterFromConditions == null && !validSubjectConfirmationDataExists) { - if (log.isDebugEnabled()){ - log.debug("No valid NotOnOrAfter element found in SubjectConfirmations"); - } - return false; - } - - if (notBeforeConditions == null && !validSubjectConfirmationDataExists) { - if (log.isDebugEnabled()){ - log.debug("No valid NotBefore element found in SubjectConfirmations"); - } - return false; - } - - /* - The Assertion MUST be digitally signed by the issuer and the authorization server MUST verify the - signature. - */ - - try { - profileValidator.validate(assertion.getSignature()); - } catch (ValidationException e) { - // Indicates signature did not conform to SAML Signature profile - log.error("Signature do not confirm to SAML signature profile.", e); - - return false; - } - - X509Certificate x509Certificate = null; - try { - x509Certificate = (X509Certificate) IdentityApplicationManagementUtil - .decodeCertificate(identityProvider.getCertificate()); - } catch (CertificateException e) { - throw new IdentityOAuth2Exception("Error occurred while decoding public certificate of Identity Provider " - + identityProvider.getIdentityProviderName() + " for tenant domain " + tenantDomain, e); - } - - try { - X509Credential x509Credential = new X509CredentialImpl(x509Certificate); - SignatureValidator signatureValidator = new SignatureValidator(x509Credential); - signatureValidator.validate(assertion.getSignature()); - if (log.isDebugEnabled()){ - log.debug("Signature validation successful"); - } - } catch (ValidationException e) { - log.error("Error while validating the signature.", e); - return false; - } - - - /* - The authorization server MUST verify that the Assertion is valid in all other respects per - [OASIS.saml-core-2.0-os], such as (but not limited to) evaluating all content within the Conditions - element including the NotOnOrAfter and NotBefore attributes, rejecting unknown condition types, etc. - - [OASIS.saml-core-2.0-os] - http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf - */ - - - // TODO: Throw the SAML request through the general SAML2 validation routines - - tokReqMsgCtx.setScope(tokReqMsgCtx.getOauth2AccessTokenReqDTO().getScope()); - - // Storing the Assertion. This will be used in OpenID Connect for example - tokReqMsgCtx.addProperty(OAuthConstants.OAUTH_SAML2_ASSERTION, assertion); - - // Invoking extension - SAML2TokenCallbackHandler callback = - OAuthServerConfiguration.getInstance() - .getSAML2TokenCallbackHandler(); - if (callback != null) { - if (log.isDebugEnabled()){ - log.debug("Invoking the SAML2 Token callback handler "); - } - callback.handleSAML2Token(tokReqMsgCtx); - } - + AuthenticatedUser authenticatedUser = tokReqMsgCtx.getAuthorizedUser(); + authenticatedUser.setUserName(MultitenantUtils.getTenantAwareUsername(authenticatedUser.getUserName())); return true; } From 701d6e45227d8e96a06619d6c701264739af62e0 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Wed, 1 Feb 2017 12:55:56 +0530 Subject: [PATCH 019/193] Updated the snapshot version of intergration client --- .../org.wso2.carbon.apimgt.integration.client/pom.xml | 4 ++-- .../org.wso2.carbon.apimgt.integration.client.feature/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 0bac2f2121d..f8e67e64b9d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -14,13 +14,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 212ed5ae90c..15c8f907397 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org From 79018f9a4c84d2704c8d2ccd56967299986ec91d Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 2 Feb 2017 15:52:41 +0530 Subject: [PATCH 020/193] Fix https://wso2.org/jira/browse/IOTS-436 --- .../org.wso2.carbon.device.mgt.api/pom.xml | 6 ++++ .../mgt/jaxrs/beans/BasePaginatedResult.java | 6 ++-- .../impl/UserManagementServiceImpl.java | 26 +++++++++++++++ .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 33 +++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index b572c746c5f..b0e27a25a91 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -281,6 +281,12 @@ javax.ws.rs javax.ws.rs-api + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.user.store.count + ${carbon.identity.framework.version} + provided + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java index 8d1c82d8d75..5c2936a1a3d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java @@ -30,13 +30,13 @@ public class BasePaginatedResult { value = "Number of total resources.", example = "1") @JsonProperty("count") - private int count; + private long count; - public int getCount() { + public long getCount() { return count; } - public void setCount(int count) { + public void setCount(long count) { this.count = count; } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 2b5a2e8d455..ca1ad45d1d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -38,6 +38,8 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever; +import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.CarbonUtils; @@ -395,6 +397,30 @@ public class UserManagementServiceImpl implements UserManagementService { @Path("/count") @Override public Response getUserCount() { + try { + UserStoreCountRetriever userStoreCountRetrieverService = DeviceMgtAPIUtils.getUserStoreCountRetrieverService(); + if (userStoreCountRetrieverService != null) { + long count = userStoreCountRetrieverService.countUsers(""); + if (count != -1) { + BasicUserInfoList result = new BasicUserInfoList(); + result.setCount(count); + return Response.status(Response.Status.OK).entity(result).build(); + } + } + } catch (UserStoreCounterException e) { + String msg = + "Error occurred while retrieving the count of users that exist within the current tenant"; + log.error(msg, e); + } + return getUserCountViaUserStoreManager(); + } + + /** + * This method returns the count of users using UserStoreManager. + * + * @return user count + */ + private Response getUserCountViaUserStoreManager() { if (log.isDebugEnabled()) { log.debug("Getting the user count"); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index afc03336d55..e372cf52c46 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -37,13 +37,20 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException; +import org.wso2.carbon.identity.user.store.count.AbstractCountRetrieverFactory; +import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever; +import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException; +import org.wso2.carbon.identity.user.store.count.jdbc.JDBCCountRetrieverFactory; +import org.wso2.carbon.identity.user.store.count.jdbc.internal.InternalCountRetrieverFactory; import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService; import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.RealmConfiguration; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager; import org.wso2.carbon.user.core.service.RealmService; import javax.ws.rs.core.MediaType; @@ -105,6 +112,32 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } + public static UserStoreCountRetriever getUserStoreCountRetrieverService() + throws UserStoreCounterException { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + List countRetrieverFactories = ctx.getOSGiServices(AbstractCountRetrieverFactory.class, null); + RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); + RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration(); + String userStoreType; + //Ignoring Sonar warning as getUserStoreClass() returning string name of the class. So cannot use 'instanceof'. + if (JDBCUserStoreManager.class.getName().equals(realmConfiguration.getUserStoreClass())) { + userStoreType = JDBCCountRetrieverFactory.JDBC; + } else { + userStoreType = InternalCountRetrieverFactory.INTERNAL; + } + AbstractCountRetrieverFactory countRetrieverFactory = null; + for (Object countRetrieverFactoryObj : countRetrieverFactories) { + countRetrieverFactory = (AbstractCountRetrieverFactory) countRetrieverFactoryObj; + if (userStoreType.equals(countRetrieverFactory.getCounterType())) { + break; + } + } + if (countRetrieverFactory == null) { + return null; + } + return countRetrieverFactory.buildCountRetriever(realmConfiguration); + } + public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); DeviceAccessAuthorizationService deviceAccessAuthorizationService = From c224fe7cab68924939038d4c69b98f3e3c31181f Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 2 Feb 2017 19:28:07 +0530 Subject: [PATCH 021/193] Fix https://wso2.org/jira/browse/IOTS-436 --- .../devicemgt/app/modules/business-controllers/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index c6ed7da1bdb..31567cf4ce4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -174,7 +174,7 @@ var userModule = function () { } try { utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users?offset=0&limit=1"; + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/count"; return serviceInvokers.XMLHttp.get( url, function (responsePayload) { return parse(responsePayload["responseText"])["count"]; From 274d3e9aeb1414ba6cd4c61363c7d131e7c6c67c Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sat, 4 Feb 2017 20:51:56 +0530 Subject: [PATCH 022/193] used jwt grant type instead of saml --- .../pom.xml | 4 +- .../src/test/resources/sample.xml | 8 +- .../devicemgt/app/modules/login.js | 6 +- .../app/modules/oauth/token-handler-utils.js | 82 +++++++------------ .../app/modules/oauth/token-handlers.js | 45 ++++++++++ .../app/units/cdmf.unit.footer/footer.hbs | 4 +- .../uuf-template-app/lib/modules/auth/auth.js | 70 ++++++++++++++++ .../pom.xml | 5 ++ .../grant/ExtendedJWTGrantHandler.java | 51 ++++++++++++ .../jwt/client/extension/JWTClient.java | 30 ++++++- .../extension/constant/JWTConstants.java | 1 + .../client/extension/dto/AccessTokenInfo.java | 9 ++ .../pom.xml | 4 +- .../src/main/resources/conf/cdm-config.xml | 9 +- .../src/main/resources/jwt.properties | 2 +- pom.xml | 8 +- 16 files changed, 263 insertions(+), 75 deletions(-) create mode 100644 components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index f8e67e64b9d..5a9ada7d421 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -14,13 +14,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.14-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.14-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index aa18e5d03b7..6542d9629b2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -36,10 +36,10 @@ - + false diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index d36e7af0ab8..166859f89b4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -26,7 +26,11 @@ var onFail; var utility = require("/app/modules/utility.js").utility; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; if (context.input.samlToken) { - apiWrapperUtil.setupTokenPairBySamlGrantType(context.user.username + '@' + context.user.domain, context.input.samlToken); + //apiWrapperUtil.setupTokenPairBySamlGrantType(context.user.username + '@' + context.user.domain, context.input.samlToken); + /** + * Since the user can be verified using the sso.client.js we can use JWT grant type to issue the token for the user. + */ + apiWrapperUtil.setupTokenPairByJWTGrantType(context.user.username + '@' + context.user.domain, context.input.samlToken); } else { apiWrapperUtil.setupTokenPairByPasswordGrantType(context.input.username, context.input.password); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js index b31febe79a2..109e67f7ac7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js @@ -22,6 +22,7 @@ var utils = function () { var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var carbon = require("carbon"); + var authModule = require("/lib/modules/auth/auth.js").module; //noinspection JSUnresolvedVariable var Base64 = Packages.org.apache.commons.codec.binary.Base64; @@ -275,59 +276,34 @@ var utils = function () { } }; - publicMethods["getTokenPairAndScopesBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { - if (!assertion || !encodedClientAppCredentials || !scopes) { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by saml " + - "grant type. No assertion, encoded client app credentials or scopes are " + - "found - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); - return null; - } else { - var assertionXML = publicMethods.decode(assertion); - /* - TODO: make assertion extraction with proper parsing. - Since Jaggery XML parser seem to add formatting which causes signature verification to fail. - */ - var assertionStartMarker = " - - WSO2 CDMF v2.0.6 | © , + + WSO2 IoT Server 3.1.0 | © , Inc. All Rights Reserved.

{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index 93cffdbf862..fad0b27b99e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -565,6 +565,76 @@ var module = {}; } }; + + /** + * saml token validation Service. + * @param request {Object} HTTP request + * @param response {Object} HTTP response + */ + module.ssoLogin = function (samlToken) { + var samlResponse = samlToken; + var ssoClient = require("sso").client; + var samlResponseObj; + + if (samlResponse) { + try { + samlResponseObj = ssoClient.getSamlObject(samlResponse); + } catch (e) { + log.error(e.message, e); + return; + } + + // This is a login response. + var ssoConfigs = getSsoConfigurations(); + var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils; + var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password"); + var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location"); + var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS]; + var keyStoreParams = { + KEY_STORE_NAME: keyStoreName, + KEY_STORE_PASSWORD: keyStorePassword, + IDP_ALIAS: identityAlias + }; + var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED]; + if (utils.parseBoolean(rsEnabled)) { + if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) { + var msg = "Invalid signature found in the SAML response."; + log.error(msg); + return; + } + } + + if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) { + var msg = "Invalid SAML response found."; + log.error(msg); + return; + } + + /** + * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: + * string}} + */ + var ssoSession = ssoClient.decodeSAMLLoginResponse(samlResponseObj, samlResponse, + session.getId()); + if (ssoSession.sessionId) { + var ssoSessions = getSsoSessions(); + ssoSessions[ssoSession.sessionId] = ssoSession; + if (ssoSession.sessionIndex) { + var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); + utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); + module.loadTenant(ssoSession.loggedInUser); + var user = {user: module.getCurrentUser()}; + return user; + } + } else { + var msg = "Cannot decode SAML login response."; + log.error(msg); + return; + } + + } + }; + /** * Load current user tenant * @param username logged user name diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 75239f0fb2a..7406555132b 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -58,6 +58,10 @@ org.wso2.carbon.identity.framework org.wso2.carbon.user.mgt + + org.wso2.carbon.identity + org.wso2.carbon.identity.oauth2.grant.jwt + @@ -83,6 +87,7 @@ org.wso2.carbon.device.mgt.oauth.extensions.* + org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", org.apache.commons.logging, org.osgi.service.component, org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java new file mode 100644 index 00000000000..90bba018517 --- /dev/null +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; +import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler; +import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +/** + * This sets up user with tenant aware username. + */ +@SuppressWarnings("unused") +public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler { + private static Log log = LogFactory.getLog(ExtendedJWTGrantHandler.class); + + @Override + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); + } + + @Override + public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { + /** + * This is added to skip per tenant IDP creation. + */ + tokReqMsgCtx.getOauth2AccessTokenReqDTO().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + return super.validateGrant(tokReqMsgCtx); + } +} diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java index ad7d5470901..dc51a2c9df6 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/JWTClient.java @@ -80,6 +80,25 @@ public class JWTClient { return getTokenInfo(params, consumerKey, consumerSecret); } + public AccessTokenInfo getAccessToken(String encodedAppcredential, String username, String scopes) + throws JWTClientException { + List params = new ArrayList<>(); + params.add(new BasicNameValuePair(JWTConstants.GRANT_TYPE_PARAM_NAME, jwtConfig.getJwtGrantType())); + String assertion = JWTClientUtil.generateSignedJWTAssertion(username, jwtConfig, isDefaultJWTClient); + if (assertion == null) { + throw new JWTClientException("JWT is not configured properly for user : " + username); + } + params.add(new BasicNameValuePair(JWTConstants.JWT_PARAM_NAME, assertion)); + if (scopes != null && !scopes.isEmpty()) { + params.add(new BasicNameValuePair(JWTConstants.SCOPE_PARAM_NAME, scopes)); + } + String decodedKey[] = getDecodedKey(encodedAppcredential); + if (decodedKey.length != 2) { + throw new JWTClientException("Invalid app credential"); + } + return getTokenInfo(params, decodedKey[0], decodedKey[1]); + } + public AccessTokenInfo getAccessToken(String consumerKey, String consumerSecret, String username, String scopes, Map paramsMap) throws JWTClientException { @@ -137,9 +156,12 @@ public class JWTClient { String accessToken = (String) jsonObject.get(JWTConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); if (accessToken != null && !accessToken.isEmpty()) { accessTokenInfo.setAccessToken(accessToken); - accessTokenInfo.setRefreshToken((String) jsonObject.get(JWTConstants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); + accessTokenInfo.setRefreshToken((String) jsonObject.get( + JWTConstants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); accessTokenInfo.setExpiresIn((Long) jsonObject.get(JWTConstants.OAUTH_EXPIRES_IN)); accessTokenInfo.setTokenType((String) jsonObject.get(JWTConstants.OAUTH_TOKEN_TYPE)); + accessTokenInfo.setScopes((String) jsonObject.get(JWTConstants.OAUTH_TOKEN_SCOPE)); + } return accessTokenInfo; } catch (MalformedURLException e) { @@ -161,7 +183,11 @@ public class JWTClient { return new String(Base64.encodeBase64((consumerKey + ":" + consumerSecret).getBytes())); } - public String getJwtToken(String username) throws JWTClientException { + private String[] getDecodedKey(String encodedKey) { + return (new String(Base64.decodeBase64((encodedKey).getBytes()))).split(":"); + } + + public String getJwtToken(String username) throws JWTClientException { return JWTClientUtil.generateSignedJWTAssertion(username, jwtConfig, isDefaultJWTClient); } diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/constant/JWTConstants.java b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/constant/JWTConstants.java index ab6a4b142d1..998813054a3 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/constant/JWTConstants.java +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/constant/JWTConstants.java @@ -23,6 +23,7 @@ package org.wso2.carbon.identity.jwt.client.extension.constant; public class JWTConstants { public static final String OAUTH_EXPIRES_IN = "expires_in"; public static final String OAUTH_TOKEN_TYPE = "token_type"; + public static final String OAUTH_TOKEN_SCOPE = "scope"; public static final String JWT_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/dto/AccessTokenInfo.java b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/dto/AccessTokenInfo.java index c1adb813fd4..a0240dc8189 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/dto/AccessTokenInfo.java +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/dto/AccessTokenInfo.java @@ -27,6 +27,7 @@ public class AccessTokenInfo { private long expiresIn; private String refreshToken; private String accessToken; + private String scopes; public String getTokenType() { return tokenType; @@ -59,4 +60,12 @@ public class AccessTokenInfo { public void setAccessToken(String accessToken) { this.accessToken = accessToken; } + + public String getScopes() { + return scopes; + } + + public void setScopes(String scopes) { + this.scopes = scopes; + } } diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 15c8f907397..e6c65be7614 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.14-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 2.0.14-SNAPSHOT + 2.0.16-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index e48531dd83a..c747b4354c6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -28,8 +28,8 @@ org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.GCMBasedPushNotificationProvider - - + org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider https://localhost:9443 @@ -47,11 +47,6 @@ Simple - - android - ios - windows - diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties index 3c384655811..b0d9a4c18d7 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties @@ -19,7 +19,7 @@ #issuer of the JWT iss=wso2.org/products/iot -TokenEndpoint=https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token +TokenEndpoint=https://${iot.gateway.host}:${iot.gateway.https.port}/token #audience of JWT claim #comma seperated values diff --git a/pom.xml b/pom.xml index 1c40349604c..9bbaf653fa0 100644 --- a/pom.xml +++ b/pom.xml @@ -909,6 +909,11 @@ org.wso2.carbon.identity.oauth.stub ${identity.inbound.auth.oauth.version} + + org.wso2.carbon.identity + org.wso2.carbon.identity.oauth2.grant.jwt + ${carbon.identity.jwt.grant.version} + org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.authentication.framework @@ -1769,7 +1774,8 @@ [5.0.0, 6.0.0) 5.3.1 5.3.0 - + 1.0.2 + [1.0.2, 2.0.0) [5.7.0, 6.0.0) [5.2.0, 6.0.0) From 0999bb70a0c6258af0461caff5e1d1f6776a71f8 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 5 Feb 2017 17:51:15 +0530 Subject: [PATCH 023/193] exposed artefact deployment through api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merged Jasintha’s code --- .../DeviceTypePublisherAdminService.java | 148 ++++++++ .../DeviceTypePublisherAdminServiceImpl.java | 315 ++++++++++++++++++ 2 files changed, 463 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java new file mode 100644 index 00000000000..7914f9d071c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.jaxrs.service.api.admin; + + +import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; +import org.wso2.carbon.device.mgt.jaxrs.util.Constants; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "DeviceTypePublisherAdminService"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/devicetype"), + }) + } + ), + tags = { + @Tag(name = "device_management", description = "") + } +) +@Path("/admin/devicetype") +@Api(value = "Devicetype deployment Administrative Service", description = "This an API intended to be used to " + + "deploy device type components" + + "Further, this is strictly restricted to admin users only ") +@Scopes( + scopes = { + @Scope( + name = "Devicetype deployment", + description = "Deploy devicetype", + key = "perm:devicetype:deployment", + permissions = {"/device-mgt/devicetype/deploy"} + ) + } +) + +public interface DeviceTypePublisherAdminService { + + @POST + @Path("/deploy/{type}") + @ApiOperation( + httpMethod = "POST", + value = "Deploy device type\n", + notes = "This is an API that can be used to deploy existing device type artifact for tenant", + response = Response.class, + tags = "Devicetype Deployment Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:devicetype:deployment") + }) + }) + + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "OK. \n Successfully deployed the artifacts.", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified resource does not exist."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The entity of the request was in a not supported format."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while checking the authorization" + + " for a specified set of devices.", + response = ErrorResponse.class) + }) + + Response doPublish( + @ApiParam(name = "type", + value = "The type of deployment." + + "INFO: Deploy artifact with given type.", + required = true) + @PathParam("type") String type); + + @GET + @Path("/deploy/{type}/status") + @ApiOperation( + httpMethod = "GET", + value = "Check the status of device type artifact\n", + notes = "This is an API that can be used to check the status of the artifact", + response = Response.class, + tags = "Devicetype Status Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:devicetype:deployment") + }) + }) + + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "OK. \n Successfully deployed the artifacts.", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified resource does not exist."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The entity of the request was in a not supported format."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while checking the authorization" + + " for a specified set of devices.", + response = ErrorResponse.class) + }) + + Response getStatus(@PathParam("type") String deviceType); + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java new file mode 100644 index 00000000000..66548fee52d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java @@ -0,0 +1,315 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.carbon.device.mgt.jaxrs.service.impl.admin; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axis2.client.Options; +import org.apache.axis2.java.security.SSLProtocolSocketFactory; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.protocol.Protocol; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.application.mgt.stub.upload.CarbonAppUploaderStub; +import org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem; +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.util.Utils; +import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypePublisherAdminService; +import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.registry.core.Registry; +import org.wso2.carbon.registry.core.Resource; +import org.wso2.carbon.registry.core.ResourceImpl; +import org.wso2.carbon.registry.core.exceptions.RegistryException; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.activation.DataHandler; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; +import java.io.*; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; + +@Path("/admin/devicetype") +public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherAdminService { + + /** + * required soap header for mutualSSL + */ + private static final String USER_NAME_HEADER = "UserName"; + + private static final String KEY_STORE_TYPE = "JKS"; + /** + * Default truststore type of the client + */ + private static final String TRUST_STORE_TYPE = "JKS"; + /** + * Default keymanager type of the client + */ + private static final String KEY_MANAGER_TYPE = "SunX509"; //Default Key Manager Type + /** + * Default trustmanager type of the client + */ + private static final String TRUST_MANAGER_TYPE = "SunX509"; //Default Trust Manager Type + + private static final String SSLV3 = "SSLv3"; + + private KeyStore keyStore; + private KeyStore trustStore; + private char[] keyStorePassword; + private SSLContext sslContext; + + private static final Log log = LogFactory.getLog(DeviceTypePublisherAdminServiceImpl.class); + private static final String DEFAULT_RESOURCE_LOCATION = "/resources/devicetypes"; + private static final String CAR_FILE_LOCATION = CarbonUtils.getCarbonHome() + File.separator + "repository" + + File.separator + "resources" + File.separator + "devicetypes"; + private static final String DAS_PORT = "${iot.analytics.https.port}"; + private static final String DAS_HOST_NAME = "${iot.analytics.host}"; + private static final String DEFAULT_HTTP_PROTOCOL = "https"; + private static final String IOT_MGT_PORT = "${iot.manager.https.port}"; + private static final String IOT_MGT_HOST_NAME = "${iot.manager.host}"; + private static final String DAS_URL = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME + + ":" + DAS_PORT + "/services/CarbonAppUploader" + "/"; + private static final String IOT_MGT_URL = DEFAULT_HTTP_PROTOCOL + "://" + IOT_MGT_HOST_NAME + + ":" + IOT_MGT_PORT + "/services/CarbonAppUploader" + "/"; + private static final String MEDIA_TYPE_XML = "application/xml"; + private static final String DEVICE_MANAGEMENT_TYPE = "device_management"; + + @Override + @POST + @Path("/deploy/{type}") + public Response doPublish(@PathParam("type") String type) { + + try { + //Getting the tenant Domain + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantAdminUser = username + "@" + tenantDomain; + + String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); + String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( + "Security.TrustStore.Password"); + String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location"); + String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty( + "Security.TrustStore.Location"); + + //Call to load the keystore. + loadKeyStore(keyStoreLocation, keyStorePassword); + //Call to load the TrustStore. + loadTrustStore(trustStoreLocation, trustStorePassword); + //Create the SSL context with the loaded TrustStore/keystore. + initMutualSSLConnection(); + + //Constructing the soap header that required for mutual SSL + String strHeader = + "'" + tenantAdminUser + + "'"; + + InputStream is = new ByteArrayInputStream(strHeader.getBytes()); + OMElement header = OMXMLBuilderFactory.createOMBuilder(is).getDocumentElement(); + + List
list = new ArrayList
(); + Header httpHeader = new Header(); + httpHeader.setName(USER_NAME_HEADER); + byte[] encodedBytes = Base64.encodeBase64(tenantAdminUser.getBytes()); + httpHeader.setValue(new String(encodedBytes)); + list.add(httpHeader);//"https" + + File directory = new File(CAR_FILE_LOCATION + File.separator + type); + if (directory.isDirectory() && directory.exists()) { + UploadedFileItem[] uploadedFileItems = loadCappFromFileSystem(type); + if (uploadedFileItems.length > 0) { + CarbonAppUploaderStub carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty( + IOT_MGT_URL)); + carbonAppUploaderStub._getServiceClient().addHeader(header); + Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); + if (appUploaderOptions == null) { + appUploaderOptions = new Options(); + } + appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); + appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER + , new Protocol(DEFAULT_HTTP_PROTOCOL, (ProtocolSocketFactory) new SSLProtocolSocketFactory + (sslContext), Integer.parseInt(Utils.replaceSystemProperty(IOT_MGT_PORT)))); + + carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); + carbonAppUploaderStub.uploadApp(uploadedFileItems); + + if (!DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) { + carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL)); + carbonAppUploaderStub._getServiceClient().addHeader(header); + appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); + if (appUploaderOptions == null) { + appUploaderOptions = new Options(); + } + appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); + appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER + , new Protocol(DEFAULT_HTTP_PROTOCOL + , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) + , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); + + carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); + carbonAppUploaderStub.uploadApp(uploadedFileItems); + } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + Registry registry = DeviceMgtAPIUtils.getRegistryService().getConfigSystemRegistry(tenantId); + if (!registry.resourceExists(DEFAULT_RESOURCE_LOCATION + type + ".exist")) { + Resource resource = new ResourceImpl(); + resource.setContent(""); + resource.setMediaType(MEDIA_TYPE_XML); + registry.put(DEFAULT_RESOURCE_LOCATION + type + ".exist", resource); + } + } + } else { + return Response.status(Response.Status.BAD_REQUEST) + .entity("\"Error, Artifact does not exist.\"").build(); + } + + } catch (Exception e) { + log.error("Capp deployment failed due to " + e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + "\"Error, Artifact deployment has failed\"").build(); + } + + return Response.status(Response.Status.CREATED).entity("\"OK. \\n Successfully uploaded the artifacts.\"") + .build(); + } + + @GET + @Path("/deploy/{type}/status") + @Override + public Response getStatus(@PathParam("type") String deviceType) { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + Registry registry = null; + try { + registry = DeviceMgtAPIUtils.getRegistryService().getConfigSystemRegistry(tenantId); + if (registry.resourceExists(DEFAULT_RESOURCE_LOCATION + deviceType + ".exist")) { + return Response.status(Response.Status.OK).entity("Exist").build(); + } else { + return Response.status(Response.Status.NO_CONTENT).entity("Does not Exist").build(); + } + } catch (RegistryException e) { + log.error("Registry failed to load." + e.getMessage(), e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + "\"Error, Artifact status check has failed\"").build(); + } + } + + private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException { + + File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType); + File[] carFiles = directory.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.toLowerCase().endsWith(".car"); + } + }); + List uploadedFileItemLis = new ArrayList<>(); + if (carFiles != null) { + + for (File carFile : carFiles) { + UploadedFileItem uploadedFileItem = new UploadedFileItem(); + DataHandler param = new DataHandler(carFile.toURI().toURL()); + uploadedFileItem.setDataHandler(param); + uploadedFileItem.setFileName(carFile.getName()); + uploadedFileItem.setFileType("jar"); + uploadedFileItemLis.add(uploadedFileItem); + } + } + UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()]; + fileItems = uploadedFileItemLis.toArray(fileItems); + return fileItems; + } + + /** + * Loads the keystore. + * + * @param keyStorePath - the path of the keystore + * @param ksPassword - the keystore password + */ + private void loadKeyStore(String keyStorePath, String ksPassword) + throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { + InputStream fis = null; + try { + keyStorePassword = ksPassword.toCharArray(); + keyStore = KeyStore.getInstance(KEY_STORE_TYPE); + fis = new FileInputStream(keyStorePath); + keyStore.load(fis, keyStorePassword); + } finally { + if (fis != null) { + fis.close(); + } + } + } + + /** + * Loads the trustore + * + * @param trustStorePath - the trustore path in the filesystem. + * @param tsPassword - the truststore password + */ + private void loadTrustStore(String trustStorePath, String tsPassword) + throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { + + InputStream fis = null; + try { + trustStore = KeyStore.getInstance(TRUST_STORE_TYPE); + fis = new FileInputStream(trustStorePath); + trustStore.load(fis, tsPassword.toCharArray()); + } finally { + if (fis != null) { + fis.close(); + } + } + } + + /** + * Initializes the SSL Context + */ + private void initMutualSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException, + KeyStoreException, KeyManagementException { + KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE); + keyManagerFactory.init(keyStore, keyStorePassword); + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE); + trustManagerFactory.init(trustStore); + + // Create and initialize SSLContext for HTTPS communication + sslContext = SSLContext.getInstance(SSLV3); + sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); + SSLContext.setDefault(sslContext); + } + + +} + From b7566f4e4ae5a8b3764e45aea59656f63d83fc08 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 5 Feb 2017 17:51:48 +0530 Subject: [PATCH 024/193] added artifact deployment support through UI --- .../APIManagementProviderServiceImpl.java | 2 +- .../APIPublisherLifecycleListener.java | 9 ++-- .../org.wso2.carbon.device.mgt.api/pom.xml | 5 ++ .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 13 +++++ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 6 ++- .../devicemgt/app/conf/app-conf.json | 2 +- .../devicemgt/app/conf/config.json | 3 +- .../cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs | 22 ++++++++- .../public/js/nav-menu.js | 47 +++++++++++++++++-- pom.xml | 5 ++ 10 files changed, 100 insertions(+), 14 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 07f8a2a8a7e..af471ebd6ef 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -93,7 +93,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag , CONTENT_TYPE, null); - if (apiList.getList() != null && apiList.getList().size() == 0) { + if (apiList.getList() == null || apiList.getList().size() == 0) { apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0 , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index 24c73c739df..3f0730b36ac 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -109,14 +109,11 @@ public class APIPublisherLifecycleListener implements LifecycleListener { } catch (UserStoreException e) { log.error("Error while retrieving tenant admin user for the tenant domain" + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(), e); + } catch (Throwable e) { + // This is done to stop tomcat failure if a webapp failed to publish apis. + log.error("Failed to Publish api from " + servletContext.getContextPath(), e); } } } } - - //TODO : Need to implemented, to merge API Definitions in cases where implementation of an API Lies in two classes - private List mergeAPIDefinitions(List inputList) { - return null; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 5ad39c39aaa..11b998998d2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -281,6 +281,11 @@ javax.ws.rs javax.ws.rs-api + + org.wso2.carbon.commons + org.wso2.carbon.application.mgt.stub + provided + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index ad32fc3b988..2e562b03b3c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -39,6 +39,7 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationExcepti import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService; +import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; @@ -155,6 +156,18 @@ public class DeviceMgtAPIUtils { return realmService; } + public static RegistryService getRegistryService() { + RegistryService registryService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + registryService = (RegistryService) ctx.getOSGiService(RegistryService.class, null); + if (registryService == null) { + String msg = "registry service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return registryService; + } + /** * Getting the current tenant's user realm */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 79481868933..fd6c5e0309b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -39,6 +39,8 @@ + + @@ -80,7 +82,9 @@ - + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json index 7087cdb9769..bfe2bd2a0fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json @@ -31,7 +31,7 @@ "issuer" : "devicemgt", "appName" : "devicemgt", "identityProviderUrl" : "https://%iot.keymanager.host%:%iot.keymanager.https.port%/samlsso", - "acs": "https://%iot.keymanager.host%:%iot.keymanager.https.port%/devicemgt/uuf/sso/acs", + "acs": "https://%iot.manager.host%:%iot.manager.https.port%/devicemgt/uuf/sso/acs", "identityAlias": "wso2carbon", "responseSigningEnabled" : true, "validateAssertionValidityPeriod": true, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 340aac83e8f..fdd95504397 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -175,7 +175,8 @@ "perm:ios:remove-profile", "perm:ios:get-restrictions", "perm:ios:wipe-data", - "perm:admin" + "perm:admin", + "perm:devicetype:deployment" ], "isOAuthEnabled" : true, "backendRestEndpoints" : { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs index 61655a5f44d..c3a76babc94 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs @@ -32,9 +32,29 @@ {{/if}} {{#if permissions.VIEW_DASHBOARD}}
  • - + Device Statistics +
  • {{/if}} {{#if permissions.LIST_GROUPS}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js index 2b7d3cf2d46..07ddd59f2ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js @@ -20,7 +20,7 @@ var modalPopup = ".modal"; var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; -var emmAdminBasePath = "/api/device-mgt/v1.0"; +var backendEndBasePath = "/api/device-mgt/v1.0"; /* * set popup maximum height function. @@ -66,7 +66,7 @@ var updateNotificationCount = function (data, textStatus, jqXHR) { function loadNotificationsPanel() { if ("true" == $("#right-sidebar").attr("is-authorized")) { - var serviceURL = emmAdminBasePath + "/notifications?status=NEW"; + var serviceURL = backendEndBasePath + "/notifications?status=NEW"; invokerUtil.get(serviceURL, updateNotificationCount, hideNotificationCount); loadNewNotifications(); } else { @@ -90,7 +90,7 @@ function loadNewNotifications() { var currentUser = notifications.data("currentUser"); $.template("notification-listing", notifications.attr("src"), function (template) { - var serviceURL = emmAdminBasePath + "/notifications?status=NEW"; + var serviceURL = backendEndBasePath + "/notifications?status=NEW"; var successCallback = function (data, textStatus, jqXHR) { if (jqXHR.status == 200 && data) { @@ -453,3 +453,44 @@ $(document).ready(function () { }); } }); + +function statisticLoad(redirectUrl) { + var contentType = "application/json"; + + var uri = backendEndBasePath + "/admin/devicetype/deploy/device_management/status"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + + invokerUtil.get(uri, function (data, textStatus, jqXHR) { + if (jqXHR.status == 204) { + var urix = backendEndBasePath + "/admin/devicetype/deploy/device_management"; + var device = {}; + invokerUtil.post(urix, device, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + // location.reload(true); + location.href = redirectUrl; + }, 20000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); + } else { + location.href = redirectUrl; + } + }, function (jqXHR) { + title.html("Failed to connect with server, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); +} diff --git a/pom.xml b/pom.xml index 9bbaf653fa0..3e745d19bdc 100644 --- a/pom.xml +++ b/pom.xml @@ -1161,6 +1161,11 @@ + + org.wso2.carbon.commons + org.wso2.carbon.application.mgt.stub + ${carbon.commons.version} + org.wso2.orbit.org.bouncycastle From ed7b67dd24310773e650835a30459765d801aaf7 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Mon, 6 Feb 2017 03:47:27 +0530 Subject: [PATCH 025/193] made it accept tenant domain as parameter --- .../grant/ExtendedJWTGrantHandler.java | 18 ++++++++++++++---- .../src/main/resources/jwt.properties | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java index 90bba018517..006317f1794 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java @@ -25,6 +25,7 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler; +import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -34,6 +35,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @SuppressWarnings("unused") public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler { private static Log log = LogFactory.getLog(ExtendedJWTGrantHandler.class); + private static final String TENANT_DOMAIN_KEY = "tenantDomain"; @Override public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { @@ -42,10 +44,18 @@ public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler { @Override public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { - /** - * This is added to skip per tenant IDP creation. - */ - tokReqMsgCtx.getOauth2AccessTokenReqDTO().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + + RequestParameter[] requestParameters = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters(); + for (RequestParameter requestParameter : requestParameters) { + if (TENANT_DOMAIN_KEY.equals(requestParameter.getKey())) { + String[] values = requestParameter.getValue(); + if (values != null && values.length > 0) { + tokReqMsgCtx.getOauth2AccessTokenReqDTO() + .setTenantDomain(values[0]); + } + } + } + return super.validateGrant(tokReqMsgCtx); } } diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties index b0d9a4c18d7..0c9641fa2da 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/src/main/resources/jwt.properties @@ -19,7 +19,7 @@ #issuer of the JWT iss=wso2.org/products/iot -TokenEndpoint=https://${iot.gateway.host}:${iot.gateway.https.port}/token +TokenEndpoint=https://${iot.gateway.host}:${iot.gateway.https.port}/token?tenantDomain=carbon.super #audience of JWT claim #comma seperated values From 00b1f982c6ca36ffffbc05653ce9920ad4dba619 Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Punchihewa Date: Mon, 6 Feb 2017 12:01:27 +0530 Subject: [PATCH 026/193] Update user-menu.hbs --- .../units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs index 8bc7d0b35b8..386f4b6b5ec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs @@ -21,7 +21,7 @@