mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of ssh://repository.entgra.net:222/community/device-mgt-core
This commit is contained in:
commit
c3abf3d6b7
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>grafana-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>analytics-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
~
|
||||
~ Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.extension.rest.api</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>Entgra - Device Management Extension for APIM REST API</name>
|
||||
<description>Entgra - Device Management Extension for APIM REST API</description>
|
||||
<url>https://entgra.io</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json.wso2</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.apimgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>5.1.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Publisher API Management Bundle</Bundle-Description>
|
||||
<Private-Package>
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.internal
|
||||
</Private-Package>
|
||||
<Export-Package>
|
||||
!io.entgra.device.mgt.core.apimgt.extension.rest.api.internal,
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.wso2.carbon.core;version="4.6",
|
||||
org.wso2.carbon.core.util;version="4.6",
|
||||
org.apache.commons.ssl,
|
||||
org.wso2.carbon.apimgt.api.model,
|
||||
okhttp3.*,
|
||||
org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.impl.internal;version="${carbon.api.mgt.version.range}",
|
||||
org.json
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-site</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
|
||||
public interface APIApplicationServices {
|
||||
|
||||
APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException;
|
||||
|
||||
AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException;
|
||||
|
||||
AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIServicesException;
|
||||
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.json.JSONObject;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Credentials;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;
|
||||
import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;
|
||||
import java.io.IOException;
|
||||
|
||||
public class APIApplicationServicesImpl implements APIApplicationServices {
|
||||
|
||||
private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class);
|
||||
private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder());
|
||||
private static final Gson gson = new Gson();
|
||||
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
String msg = null;
|
||||
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().
|
||||
getAPIManagerConfigurationService().getAPIManagerConfiguration();
|
||||
|
||||
@Override
|
||||
public APIApplicationKey createAndRetrieveApplicationCredentials()
|
||||
throws APIServicesException {
|
||||
|
||||
String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT);
|
||||
String serverUser = config.getFirstProperty(Constants.SERVER_USER);
|
||||
String serverPassword = config.getFirstProperty(Constants.SERVER_PASSWORD);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("callbackUrl", Constants.EMPTY_STRING);
|
||||
jsonObject.put("clientName", Constants.CLIENT_NAME);
|
||||
jsonObject.put("grantType", Constants.GRANT_TYPE);
|
||||
jsonObject.put("owner", serverUser);
|
||||
jsonObject.put("saasApp", true);
|
||||
|
||||
RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON);
|
||||
Request request = new Request.Builder()
|
||||
.url(applicationEndpoint)
|
||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(serverUser, serverPassword))
|
||||
.post(requestBody)
|
||||
.build();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
return gson.fromJson(response.body().string(), APIApplicationKey.class);
|
||||
} catch (IOException e) {
|
||||
msg = "Error occurred while processing the response";
|
||||
log.error(msg, e);
|
||||
throw new APIServicesException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret)
|
||||
throws APIServicesException {
|
||||
|
||||
String userName = config.getFirstProperty(Constants.SERVER_USER);
|
||||
String userPassword = config.getFirstProperty(Constants.SERVER_PASSWORD);
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE);
|
||||
params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME, userName);
|
||||
params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD, userPassword);
|
||||
params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES);
|
||||
return getToken(params, consumerKey, consumerSecret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret)
|
||||
throws APIServicesException {
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE);
|
||||
params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken);
|
||||
params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES);
|
||||
return getToken(params, consumerKey, consumerSecret);
|
||||
}
|
||||
|
||||
public AccessTokenInfo getToken(JSONObject nameValuePairs, String clientId, String clientSecret)
|
||||
throws APIServicesException {
|
||||
|
||||
String tokenEndPoint = config.getFirstProperty(Constants.TOKE_END_POINT);
|
||||
|
||||
RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON);
|
||||
Request request = new Request.Builder()
|
||||
.url(tokenEndPoint)
|
||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(clientId, clientSecret))
|
||||
.post(requestBody)
|
||||
.build();
|
||||
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
return gson.fromJson(response.body().string(), AccessTokenInfo.class);
|
||||
} catch (IOException e) {
|
||||
msg = "Error occurred while processing the response";
|
||||
log.error(msg, e);
|
||||
throw new APIServicesException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException;
|
||||
import org.json.JSONObject;
|
||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
||||
|
||||
public interface PublisherRESTAPIServices {
|
||||
|
||||
JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||
|
||||
boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||
|
||||
boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||
}
|
||||
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.RequestBody;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.ssl.Base64;
|
||||
import org.json.JSONObject;
|
||||
import org.wso2.carbon.apimgt.api.model.Scope;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
||||
private static final Log log = LogFactory.getLog(PublisherRESTAPIServicesImpl.class);
|
||||
private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder());
|
||||
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
private static final String host = System.getProperty(Constants.IOT_CORE_HOST);
|
||||
private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT);
|
||||
|
||||
@Override
|
||||
public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||
|
||||
String getAllScopesUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON
|
||||
+ port + Constants.GET_ALL_SCOPES;
|
||||
Request request = new Request.Builder()
|
||||
.url(getAllScopesUrl)
|
||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
||||
+ accessTokenInfo.getAccess_token())
|
||||
.get()
|
||||
.build();
|
||||
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
if (HttpStatus.SC_OK == response.code()) {
|
||||
JSONObject jsonObject = new JSONObject(response.body().string());
|
||||
return jsonObject;
|
||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||
generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(),
|
||||
apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret());
|
||||
//TODO: max attempt count
|
||||
return getScopes(apiApplicationKey, refreshedAccessToken);
|
||||
} else if (HttpStatus.SC_BAD_REQUEST == response.code()) {
|
||||
String msg = "Bad Request, Invalid request";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
} else {
|
||||
String msg = "Response : " + response.code() + response.body();
|
||||
throw new UnexpectedResponseException(msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String msg = "Error occurred while processing the response";
|
||||
log.error(msg, e);
|
||||
throw new APIServicesException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||
|
||||
String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace(Constants.QUERY_KEY_VALUE_SEPARATOR,
|
||||
Constants.EMPTY_STRING);
|
||||
String getScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON
|
||||
+ port + Constants.GET_SCOPE + keyValue;
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(getScopeUrl)
|
||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
||||
+ accessTokenInfo.getAccess_token())
|
||||
.head()
|
||||
.build();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
if (HttpStatus.SC_OK == response.code()) {
|
||||
return true;
|
||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||
generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(),
|
||||
apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret());
|
||||
//TODO: max attempt count
|
||||
return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key);
|
||||
} else if (HttpStatus.SC_BAD_REQUEST == response.code()) {
|
||||
String msg = "Bad Request, Invalid request";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
} else {
|
||||
String msg = "Response : " + response.code() + response.body();
|
||||
throw new UnexpectedResponseException(msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String msg = "Error occurred while processing the response";
|
||||
log.error(msg, e);
|
||||
throw new APIServicesException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope)
|
||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||
|
||||
String updateScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host
|
||||
+ Constants.COLON + port + Constants.GET_SCOPE + scope.getId();
|
||||
|
||||
ScopeUtils scopeUtil = new ScopeUtils();
|
||||
scopeUtil.setKey(scope.getKey());
|
||||
scopeUtil.setName(scope.getName());
|
||||
scopeUtil.setDescription(scope.getDescription());
|
||||
scopeUtil.setRoles(scope.getRoles());
|
||||
String scopeString = scopeUtil.toJSON();
|
||||
|
||||
RequestBody requestBody = RequestBody.create(JSON, scopeString);
|
||||
Request request = new Request.Builder()
|
||||
.url(updateScopeUrl)
|
||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
||||
+ accessTokenInfo.getAccess_token())
|
||||
.put(requestBody)
|
||||
.build();
|
||||
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
if (HttpStatus.SC_OK == response.code()) {
|
||||
return true;
|
||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||
generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(),
|
||||
apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret());
|
||||
//TODO: max attempt count
|
||||
return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope);
|
||||
} else if (HttpStatus.SC_BAD_REQUEST == response.code()) {
|
||||
String msg = "Bad Request, Invalid scope object";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
} else {
|
||||
String msg = "Response : " + response.code() + response.body();
|
||||
throw new UnexpectedResponseException(msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String msg = "Error occurred while processing the response";
|
||||
log.error(msg, e);
|
||||
throw new APIServicesException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean;
|
||||
|
||||
/**
|
||||
* This class represents the data that are required to register
|
||||
* the oauth application.
|
||||
*/
|
||||
public class RegistrationProfile {
|
||||
|
||||
private String callbackUrl;
|
||||
private String clientName;
|
||||
private String tokenScope;
|
||||
private String owner;
|
||||
private String grantType;
|
||||
private String applicationType;
|
||||
private boolean isSaasApp;
|
||||
|
||||
private static final String TAG = RegistrationProfile.class.getSimpleName();
|
||||
|
||||
public String getCallbackUrl() {
|
||||
return callbackUrl;
|
||||
}
|
||||
|
||||
public void setCallbackUrl(String callBackUrl) {
|
||||
this.callbackUrl = callBackUrl;
|
||||
}
|
||||
|
||||
public String getClientName() {
|
||||
return clientName;
|
||||
}
|
||||
|
||||
public void setClientName(String clientName) {
|
||||
this.clientName = clientName;
|
||||
}
|
||||
|
||||
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 grantType) {
|
||||
this.grantType = grantType;
|
||||
}
|
||||
|
||||
public String getApplicationType() {
|
||||
return applicationType;
|
||||
}
|
||||
|
||||
public void setApplicationType(String applicationType) {
|
||||
this.applicationType = applicationType;
|
||||
}
|
||||
|
||||
public boolean isSaasApp() {
|
||||
return isSaasApp;
|
||||
}
|
||||
|
||||
public void setIsSaasApp(boolean isSaasApp) {
|
||||
this.isSaasApp = isSaasApp;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
String jsonString =
|
||||
"{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName +
|
||||
"\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType +
|
||||
"\", \"saasApp\" : " + isSaasApp + " }\n";
|
||||
return jsonString;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.constants;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
private Constants() {
|
||||
}
|
||||
|
||||
public static final String EMPTY_STRING = "";
|
||||
public static final String CLIENT_NAME = "rest_api_publisher_code";
|
||||
public static final String SERVER_USER = "WorkflowConfigurations.ServerUser";
|
||||
public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword";
|
||||
public static final String GRANT_TYPE = "client_credentials password refresh_token";
|
||||
public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token";
|
||||
public static final String OAUTH_EXPIRES_IN = "expires_in";
|
||||
public static final String OAUTH_TOKEN_SCOPE = "scope";
|
||||
public static final String OAUTH_TOKEN_TYPE = "token_type";
|
||||
public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token";
|
||||
public static final String SCOPE_PARAM_NAME = "scope";
|
||||
public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage";
|
||||
public static final String DCR_END_POINT = "WorkflowConfigurations.DCREndPoint";
|
||||
public static final String TOKE_END_POINT = "WorkflowConfigurations.TokenEndPoint";
|
||||
public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive";
|
||||
public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000;
|
||||
public static final String CLIENT_ID = "clientId";
|
||||
public static final String CLIENT_SECRET = "clientSecret";
|
||||
|
||||
public static final String AUTHORIZATION_HEADER_NAME = "Authorization";
|
||||
public static final String AUTHORIZATION_HEADER_VALUE_PREFIX = "Basic ";
|
||||
public static final String AUTHORIZATION_HEADER_PREFIX_BEARER = "Bearer ";
|
||||
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
public static final String APPLICATION_JSON = "application/json";
|
||||
public static final String PASSWORD_GRANT_TYPE = "password";
|
||||
public static final String PASSWORD_GRANT_TYPE_USERNAME = "username";
|
||||
public static final String PASSWORD_GRANT_TYPE_PASSWORD = "password";
|
||||
public static final String PASSWORD_GRANT_TYPE_SCOPES = "scopes";
|
||||
public static final String ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME = "access_token";
|
||||
public static final String GRANT_TYPE_PARAM_NAME = "grant_type";
|
||||
public static final String HTTPS_PROTOCOL = "https";
|
||||
public static final String HTTP_PROTOCOL = "http";
|
||||
public static final String SCHEME_SEPARATOR = "://";
|
||||
public static final String COLON = ":";
|
||||
public static final String QUERY_KEY_VALUE_SEPARATOR = "=";
|
||||
public static final String IOT_CORE_HOST = "iot.core.host";
|
||||
public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port";
|
||||
public static final String GET_ALL_SCOPES = "/api/am/publisher/v2/scopes?limit=1000";
|
||||
public static final String GET_SCOPE = "/api/am/publisher/v2/scopes/";
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;
|
||||
|
||||
/**
|
||||
* This holds the consumer application information that return from the register application endpoint
|
||||
*/
|
||||
public class APIApplicationKey {
|
||||
private String clientName;
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String callBackURL;
|
||||
private String isSaasApplication;
|
||||
private String appOwner;
|
||||
private String jsonString;
|
||||
private String jsonAppAttribute;
|
||||
private String tokenType;
|
||||
|
||||
public APIApplicationKey(String clientId, String clientSecret) {
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 getAppOwner() {
|
||||
return appOwner;
|
||||
}
|
||||
|
||||
public void setAppOwner(String appOwner) {
|
||||
this.appOwner = appOwner;
|
||||
}
|
||||
|
||||
public String getJsonString() {
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
public void setJsonString(String jsonString) {
|
||||
this.jsonString = jsonString;
|
||||
}
|
||||
|
||||
public String getJsonAppAttribute() {
|
||||
return jsonAppAttribute;
|
||||
}
|
||||
|
||||
public void setJsonAppAttribute(String jsonAppAttribute) {
|
||||
this.jsonAppAttribute = jsonAppAttribute;
|
||||
}
|
||||
|
||||
public String getTokenType() {
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
public void setTokenType(String tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;
|
||||
|
||||
/**
|
||||
* This holds the token information that return from the token endpoint.
|
||||
*/
|
||||
public class AccessTokenInfo {
|
||||
|
||||
private String token_type;
|
||||
private long expires_in;
|
||||
private String refresh_token;
|
||||
private String access_token;
|
||||
private String scope;
|
||||
|
||||
public String getToken_type() {
|
||||
return token_type;
|
||||
}
|
||||
|
||||
public void setToken_type(String token_type) {
|
||||
this.token_type = token_type;
|
||||
}
|
||||
|
||||
public long getExpires_in() {
|
||||
return expires_in;
|
||||
}
|
||||
|
||||
public void setExpires_in(long expires_in) {
|
||||
this.expires_in = expires_in;
|
||||
}
|
||||
|
||||
public String getRefresh_token() {
|
||||
return refresh_token;
|
||||
}
|
||||
|
||||
public void setRefresh_token(String refresh_token) {
|
||||
this.refresh_token = refresh_token;
|
||||
}
|
||||
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;
|
||||
|
||||
public class APIServicesException extends Exception {
|
||||
|
||||
public APIServicesException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public APIServicesException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public APIServicesException(String message, Throwable cause) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public APIServicesException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom exception class for handling bad request exceptions.
|
||||
*/
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;
|
||||
|
||||
public class BadRequestException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -2387103750774855056L;
|
||||
|
||||
public BadRequestException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom exception class for handling unexpected server response exceptions.
|
||||
*/
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;
|
||||
|
||||
public class UnexpectedResponseException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -2387103750774855056L;
|
||||
|
||||
public UnexpectedResponseException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
||||
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
|
||||
|
||||
public class PublisherRESTAPIDataHolder {
|
||||
|
||||
private APIApplicationServices apiApplicationServices;
|
||||
private APIManagerConfigurationService apiManagerConfigurationService;
|
||||
|
||||
private static PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder();
|
||||
|
||||
private PublisherRESTAPIDataHolder() {
|
||||
}
|
||||
|
||||
static PublisherRESTAPIDataHolder getInstance() {
|
||||
return thisInstance;
|
||||
}
|
||||
|
||||
public APIApplicationServices getApiApplicationServices() {
|
||||
return apiApplicationServices;
|
||||
}
|
||||
|
||||
public void setApiApplicationServices(APIApplicationServices apiApplicationServices) {
|
||||
this.apiApplicationServices = apiApplicationServices;
|
||||
}
|
||||
|
||||
public void setAPIManagerConfiguration(APIManagerConfigurationService apiManagerConfigurationService) {
|
||||
this.apiManagerConfigurationService = apiManagerConfigurationService;
|
||||
}
|
||||
|
||||
public APIManagerConfigurationService getAPIManagerConfigurationService() {
|
||||
if (apiManagerConfigurationService == null) {
|
||||
throw new IllegalStateException("API Manager Configuration service is not initialized properly");
|
||||
}
|
||||
return apiManagerConfigurationService;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @scr.component name="internal.io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServiceComponent"
|
||||
* immediate="true"
|
||||
* @scr.reference name="user.apimanagerconfigurationservice.default"
|
||||
* interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setAPIManagerConfigurationService"
|
||||
* unbind="unsetAPIManagerConfigurationService"
|
||||
*/
|
||||
public class PublisherRESTAPIServiceComponent {
|
||||
|
||||
private static Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing publisher API extension bundle");
|
||||
}
|
||||
try {
|
||||
BundleContext bundleContext = componentContext.getBundleContext();
|
||||
|
||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||
bundleContext.registerService(APIApplicationServices.class.getName(), apiApplicationServices, null);
|
||||
PublisherRESTAPIDataHolder.getInstance().setApiApplicationServices(apiApplicationServices);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("API Application bundle has been successfully initialized");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while initializing API Application bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext componentContext) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
protected void setAPIManagerConfigurationService(APIManagerConfigurationService apiManagerConfigurationService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Setting API Manager Configuration Service");
|
||||
}
|
||||
PublisherRESTAPIDataHolder.getInstance().setAPIManagerConfiguration(apiManagerConfigurationService);
|
||||
}
|
||||
|
||||
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService apiManagerConfigurationService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting API Manager Configuration Service");
|
||||
}
|
||||
PublisherRESTAPIDataHolder.getInstance().setAPIManagerConfiguration(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.util;
|
||||
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.base.ServerConfiguration;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class HttpsTrustManagerUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(HttpsTrustManagerUtils.class);
|
||||
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 static final String DEFAULT_HOST = "localhost";
|
||||
private static final String DEFAULT_HOST_IP = "127.0.0.1";
|
||||
private static final int TIMEOUT = 100;
|
||||
|
||||
public static OkHttpClient getSSLClient() {
|
||||
|
||||
boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System.getProperty("org.wso2"
|
||||
+ ".ignoreHostnameVerification"));
|
||||
OkHttpClient okHttpClient;
|
||||
final String proxyHost = System.getProperty("http.proxyHost");
|
||||
final String proxyPort = System.getProperty("http.proxyPort");
|
||||
final String nonProxyHostsValue = System.getProperty("http.nonProxyHosts");
|
||||
|
||||
final ProxySelector proxySelector = new ProxySelector() {
|
||||
@Override
|
||||
public List<Proxy> select(URI uri) {
|
||||
List<Proxy> proxyList = new ArrayList<>();
|
||||
String host = uri.getHost();
|
||||
|
||||
if (!StringUtils.isEmpty(host)) {
|
||||
if (host.startsWith(DEFAULT_HOST_IP) || host.startsWith(DEFAULT_HOST) || StringUtils
|
||||
.isEmpty(nonProxyHostsValue) || StringUtils.contains(nonProxyHostsValue, host) ||
|
||||
StringUtils.isEmpty(proxyHost) || StringUtils.isEmpty(proxyPort)) {
|
||||
proxyList.add(Proxy.NO_PROXY);
|
||||
} else {
|
||||
proxyList.add(new Proxy(Proxy.Type.HTTP,
|
||||
new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort))));
|
||||
}
|
||||
} else {
|
||||
log.error("Host is null. Host could not be empty or null");
|
||||
}
|
||||
return proxyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
};
|
||||
|
||||
X509TrustManager trustAllCerts = new X509TrustManager() {
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return new java.security.cert.X509Certificate[0];
|
||||
}
|
||||
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
};
|
||||
|
||||
if (isIgnoreHostnameVerification) {
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.writeTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.readTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.connectionPool(new ConnectionPool(TIMEOUT, TIMEOUT, TimeUnit.SECONDS))
|
||||
.sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts)
|
||||
.hostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String s, SSLSession sslSession) {
|
||||
return true;
|
||||
}
|
||||
}).proxySelector(proxySelector).build();
|
||||
return okHttpClient;
|
||||
} else {
|
||||
SSLSocketFactory trustedSSLSocketFactory = getTrustedSSLSocketFactory();
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.writeTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.readTimeout(TIMEOUT, TimeUnit.SECONDS)
|
||||
.connectionPool(new ConnectionPool(TIMEOUT, TIMEOUT, TimeUnit.SECONDS))
|
||||
.sslSocketFactory(trustedSSLSocketFactory)
|
||||
.proxySelector(proxySelector).build();
|
||||
return okHttpClient;
|
||||
}
|
||||
}
|
||||
|
||||
private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() {
|
||||
try {
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(
|
||||
java.security.cert.X509Certificate[] certs, String authType) {
|
||||
}
|
||||
}
|
||||
};
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new SecureRandom());
|
||||
return sc.getSocketFactory();
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException e) {
|
||||
log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static SSLSocketFactory getTrustedSSLSocketFactory() {
|
||||
try {
|
||||
String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password");
|
||||
String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location");
|
||||
String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty(
|
||||
"Security.TrustStore.Password");
|
||||
String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty(
|
||||
"Security.TrustStore.Location");
|
||||
KeyStore keyStore = loadKeyStore(keyStoreLocation, keyStorePassword, KEY_STORE_TYPE);
|
||||
KeyStore trustStore = loadTrustStore(trustStoreLocation, trustStorePassword);
|
||||
|
||||
return initSSLConnection(keyStore, keyStorePassword, trustStore);
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException
|
||||
| CertificateException | IOException | UnrecoverableKeyException e) {
|
||||
log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static SSLSocketFactory initSSLConnection(KeyStore keyStore, String keyStorePassword, KeyStore trustStore)
|
||||
throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException {
|
||||
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE);
|
||||
keyManagerFactory.init(keyStore, keyStorePassword.toCharArray());
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE);
|
||||
trustManagerFactory.init(trustStore);
|
||||
|
||||
// Create and initialize SSLContext for HTTPS communication
|
||||
SSLContext sslContext = SSLContext.getInstance(SSLV3);
|
||||
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
|
||||
SSLContext.setDefault(sslContext);
|
||||
return sslContext.getSocketFactory();
|
||||
}
|
||||
|
||||
private static KeyStore loadKeyStore(String keyStorePath, String ksPassword, String type)
|
||||
throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
char[] keypassChar = ksPassword.toCharArray();
|
||||
KeyStore keyStore = KeyStore.getInstance(type);
|
||||
fileInputStream = new FileInputStream(keyStorePath);
|
||||
keyStore.load(fileInputStream, keypassChar);
|
||||
return keyStore;
|
||||
} finally {
|
||||
if (fileInputStream != null) {
|
||||
fileInputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KeyStore loadTrustStore(String trustStorePath, String tsPassword)
|
||||
throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
|
||||
return loadKeyStore(trustStorePath, tsPassword, TRUST_STORE_TYPE);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.util;
|
||||
|
||||
/**
|
||||
* This class represents the scope data.
|
||||
*/
|
||||
public class ScopeUtils {
|
||||
|
||||
private String key;
|
||||
private String name;
|
||||
private String roles;
|
||||
private String description;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(String roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
String jsonString = "{\n" +
|
||||
" \"name\":\" " + key + "\",\n" +
|
||||
" \"displayName\":\" " + name + "\",\n" +
|
||||
" \"description\":\" " + description + " \",\n" +
|
||||
" \"bindings\":[\n" +
|
||||
" \" " + roles + " \"\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
return jsonString;
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -122,6 +122,15 @@
|
||||
<artifactId>h2-database-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.extension.rest.api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json.wso2</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -165,6 +174,9 @@
|
||||
org.scannotation;version="1.0",
|
||||
org.scannotation.archiveiterator;version="1.0",
|
||||
org.w3c.dom,
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api,
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto,
|
||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions,
|
||||
org.wso2.carbon.apimgt.annotations.api,
|
||||
org.wso2.carbon.apimgt.api,
|
||||
org.wso2.carbon.apimgt.api.model,
|
||||
@ -187,7 +199,8 @@
|
||||
org.wso2.carbon.utils;version="4.6",
|
||||
org.wso2.carbon.utils.multitenancy;version="4.6",
|
||||
org.wso2.carbon.apimgt.impl.definitions,
|
||||
org.apache.commons.lang
|
||||
org.apache.commons.lang,
|
||||
org.json
|
||||
</Import-Package>
|
||||
<Embed-Dependency>
|
||||
jsr311-api;scope=compile|runtime;inline=false
|
||||
|
||||
@ -28,17 +28,16 @@ import java.util.Set;
|
||||
/**
|
||||
* This bean class carries the properties used by some API that needs to be published within the underlying
|
||||
* API-Management infrastructure.
|
||||
*
|
||||
* A sample API configuration accepted by this particular bean class would look like what's shown below.
|
||||
* e.g.
|
||||
*
|
||||
* <API>
|
||||
* <Name>enrollment</Name>
|
||||
* <Owner>admin</Owner>
|
||||
* <Context>/enrol</Context>
|
||||
* <Version>1.0.0</Version>
|
||||
* <Endpoint>http://localhost:9763/</Endpoint>
|
||||
* <Transports>http,https</Transports>
|
||||
* <Name>enrollment</Name>
|
||||
* <Owner>admin</Owner>
|
||||
* <Context>/enrol</Context>
|
||||
* <Version>1.0.0</Version>
|
||||
* <Endpoint>http://localhost:9763/</Endpoint>
|
||||
* <Transports>http,https</Transports>
|
||||
* </API>
|
||||
*/
|
||||
@XmlRootElement(name = "API")
|
||||
@ -47,6 +46,9 @@ public class APIConfig {
|
||||
private String name;
|
||||
private String owner;
|
||||
private String context;
|
||||
private String apiDocumentationName;
|
||||
private String apiDocumentationSummary;
|
||||
private String apiDocumentationSourceFile;
|
||||
private String endpoint;
|
||||
private String version;
|
||||
private String policy;
|
||||
@ -82,6 +84,33 @@ public class APIConfig {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ApiDocumentationName", required = false)
|
||||
public String getApiDocumentationName() {
|
||||
return apiDocumentationName;
|
||||
}
|
||||
|
||||
public void setApiDocumentationName(String apiDocumentationName) {
|
||||
this.apiDocumentationName = apiDocumentationName;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ApiDocumentationSummary", required = false)
|
||||
public String getApiDocumentationSummary() {
|
||||
return apiDocumentationSummary;
|
||||
}
|
||||
|
||||
public void setApiDocumentationSummary(String apiDocumentationSummary) {
|
||||
this.apiDocumentationSummary = apiDocumentationSummary;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ApiDocumentationSourceFile", required = false)
|
||||
public String getApiDocumentationSourceFile() {
|
||||
return apiDocumentationSourceFile;
|
||||
}
|
||||
|
||||
public void setApiDocumentationSourceFile(String apiDocumentationSourceFile) {
|
||||
this.apiDocumentationSourceFile = apiDocumentationSourceFile;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Owner", required = true)
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
|
||||
@ -18,9 +18,22 @@
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServicesImpl;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.apimgt.api.model.Documentation;
|
||||
import org.wso2.carbon.apimgt.api.model.DocumentationType;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.wso2.carbon.apimgt.api.APIManagementException;
|
||||
import org.wso2.carbon.apimgt.api.APIProvider;
|
||||
import org.wso2.carbon.apimgt.api.FaultGatewaysException;
|
||||
@ -48,7 +61,6 @@ import org.wso2.carbon.user.core.tenant.Tenant;
|
||||
import org.wso2.carbon.user.core.tenant.TenantSearchResult;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -66,18 +78,19 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* This class represents the concrete implementation of the APIPublisherService that corresponds to providing all
|
||||
* API publishing related operations.
|
||||
*/
|
||||
public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
||||
private static final String UNLIMITED_TIER = "Unlimited";
|
||||
private static final String WS_UNLIMITED_TIER = "AsyncUnlimited";
|
||||
private static final String API_PUBLISH_ENVIRONMENT = "Default";
|
||||
private static final String CREATED_STATUS = "CREATED";
|
||||
private static final String PUBLISH_ACTION = "Publish";
|
||||
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
||||
private static final Log log = LogFactory.getLog(APIPublisherServiceImpl.class);
|
||||
|
||||
@Override
|
||||
@ -293,7 +306,45 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FaultGatewaysException | APIManagementException e) {
|
||||
if (apiConfig.getApiDocumentationSourceFile() != null) {
|
||||
API api = getAPI(apiConfig, true);
|
||||
|
||||
String fileName =
|
||||
CarbonUtils.getCarbonHome() + File.separator + "repository" +
|
||||
File.separator + "resources" + File.separator + "api-docs" + File.separator +
|
||||
apiConfig.getApiDocumentationSourceFile();
|
||||
|
||||
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String line = null;
|
||||
String ls = System.lineSeparator();
|
||||
while ((line = br.readLine()) != null) {
|
||||
stringBuilder.append(line);
|
||||
stringBuilder.append(ls);
|
||||
}
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||
br.close();
|
||||
String docContent = stringBuilder.toString();
|
||||
|
||||
Documentation apiDocumentation = new Documentation(DocumentationType.HOWTO, apiConfig.getApiDocumentationName());
|
||||
apiDocumentation.setVisibility(Documentation.DocumentVisibility.API_LEVEL);
|
||||
apiDocumentation.setSourceType(Documentation.DocumentSourceType.MARKDOWN);
|
||||
apiDocumentation.setCreatedDate(new Date());
|
||||
apiDocumentation.setLastUpdated(new Date());
|
||||
apiDocumentation.setSummary(apiConfig.getApiDocumentationSummary());
|
||||
apiDocumentation.setOtherTypeName(null);
|
||||
|
||||
try {
|
||||
//Including below code lines inside the try block because 'getDocumentation' method returns an APIManagementException exception when it doesn't have any existing doc
|
||||
Documentation existingDoc = apiProvider.getDocumentation(api.getId(), DocumentationType.HOWTO, apiConfig.getApiDocumentationName());
|
||||
apiProvider.removeDocumentation(api.getId(), existingDoc.getId(), null);
|
||||
} catch (APIManagementException e) {
|
||||
log.info("There is no any existing api documentation.");
|
||||
}
|
||||
apiProvider.addDocumentation(api.getId(), apiDocumentation);
|
||||
apiProvider.addDocumentationContent(api, apiConfig.getApiDocumentationName(), docContent);
|
||||
}
|
||||
} catch (FaultGatewaysException | APIManagementException | IOException e) {
|
||||
String msg = "Error occurred while publishing api";
|
||||
log.error(msg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
@ -316,18 +367,31 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
WebappPublisherConfig config = WebappPublisherConfig.getInstance();
|
||||
List<String> tenants = new ArrayList<>(Collections.singletonList(APIConstants.SUPER_TENANT_DOMAIN));
|
||||
tenants.addAll(config.getTenants().getTenant());
|
||||
|
||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||
APIApplicationKey apiApplicationKey;
|
||||
AccessTokenInfo accessTokenInfo;
|
||||
try {
|
||||
apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials();
|
||||
accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication(
|
||||
apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret());
|
||||
} catch (APIServicesException e) {
|
||||
String errorMsg = "Error while generating application";
|
||||
log.error(errorMsg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
for (String tenantDomain : tenants) {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
|
||||
APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(MultitenantUtils.getTenantAwareUsername(
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
|
||||
.getAdminUserName()));
|
||||
PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServicesImpl();
|
||||
JSONObject scopeObject = publisherRESTAPIServices.getScopes(apiApplicationKey, accessTokenInfo);
|
||||
|
||||
try {
|
||||
String fileName =
|
||||
CarbonUtils.getCarbonConfigDirPath() + File.separator + "etc"
|
||||
+ File.separator + tenantDomain + ".csv";
|
||||
+ File.separator + tenantDomain + ".csv";
|
||||
if (Files.exists(Paths.get(fileName))) {
|
||||
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
||||
int lineNumber = 0;
|
||||
@ -368,8 +432,18 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
}
|
||||
scope.setRoles(roleString);
|
||||
|
||||
if (apiProvider.isSharedScopeNameExists(scope.getKey(), tenantDomain)) {
|
||||
apiProvider.updateSharedScope(scope, tenantDomain);
|
||||
//Set scope id which related to the scope key
|
||||
JSONArray scopeList = (JSONArray) scopeObject.get("list");
|
||||
for (int i = 0; i < scopeList.length(); i++) {
|
||||
JSONObject scopeObj = scopeList.getJSONObject(i);
|
||||
if (scopeObj.getString("name").equals(scopeMapping[2] != null ?
|
||||
StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) {
|
||||
scope.setId(scopeObj.getString("id"));
|
||||
}
|
||||
}
|
||||
|
||||
if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) {
|
||||
publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope);
|
||||
} else {
|
||||
// todo: come to this level means, that scope is removed from API, but haven't removed from the scope-role-permission-mappings list
|
||||
if (log.isDebugEnabled()) {
|
||||
@ -380,18 +454,27 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
}
|
||||
} catch (IOException | DirectoryIteratorException ex) {
|
||||
log.error("failed to read scopes from file.", ex);
|
||||
} catch (APIServicesException | BadRequestException e) {
|
||||
String errorMsg = "Error while calling APIs";
|
||||
log.error(errorMsg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while reading tenant admin username";
|
||||
log.error(msg, e);
|
||||
}
|
||||
catch (APIServicesException e) {
|
||||
String errorMsg = "Error while processing Publisher REST API response";
|
||||
log.error(errorMsg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
} catch (APIManagementException e) {
|
||||
String msg = "Error occurred while loading api provider";
|
||||
log.error(msg, e);
|
||||
} catch (BadRequestException e) {
|
||||
String errorMsg = "Error while calling Publisher REST APIs";
|
||||
log.error(errorMsg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
} finally {
|
||||
} catch (UnexpectedResponseException e) {
|
||||
String errorMsg = "Unexpected response from the server";
|
||||
log.error(errorMsg, e);
|
||||
throw new APIManagerPublisherException(e);
|
||||
}finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class APIPublisherUtil {
|
||||
}
|
||||
|
||||
public static String getWsServerBaseUrl() {
|
||||
return getServerBaseUrl().replace("https","wss");
|
||||
return getServerBaseUrl().replace("https", "wss");
|
||||
}
|
||||
|
||||
public static String getApiEndpointUrl(String context) {
|
||||
@ -104,7 +104,32 @@ public class APIPublisherUtil {
|
||||
}
|
||||
apiConfig.setVersion(version);
|
||||
|
||||
String apiDocumentationName = apiDef.getApiDocumentationName();
|
||||
if (apiDocumentationName == null || apiDocumentationName.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("'API Documentation not set in @SwaggerDefinition Annotation'");
|
||||
}
|
||||
} else {
|
||||
apiConfig.setApiDocumentationName(apiDef.getApiDocumentationName());
|
||||
}
|
||||
|
||||
String apiDocumentationSummary = apiDef.getApiDocumentationSummary();
|
||||
if (apiDocumentationSummary == null || apiDocumentationSummary.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("'API Documentation summary not set in @SwaggerDefinition Annotation'");
|
||||
}
|
||||
} else {
|
||||
apiConfig.setApiDocumentationSummary(apiDef.getApiDocumentationSummary());
|
||||
}
|
||||
|
||||
String apiDocumentationSourceFile = apiDef.getApiDocumentationSourceFile();
|
||||
if (apiDocumentationSourceFile == null || apiDocumentationSourceFile.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("'API Documentation source file not set in @SwaggerDefinition Annotation'");
|
||||
}
|
||||
} else {
|
||||
apiConfig.setApiDocumentationSourceFile(apiDef.getApiDocumentationSourceFile());
|
||||
}
|
||||
String context = apiDef.getContext();
|
||||
if (context == null || context.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
@ -302,20 +327,20 @@ public class APIPublisherUtil {
|
||||
public static void setResourceAuthTypes(ServletContext servletContext, APIConfig apiConfig) {
|
||||
List<String> resourcesList = null;
|
||||
String nonSecuredResources = servletContext.getInitParameter(NON_SECURED_RESOURCES);
|
||||
if(null != nonSecuredResources){
|
||||
if (null != nonSecuredResources) {
|
||||
resourcesList = Arrays.asList(nonSecuredResources.split(","));
|
||||
}
|
||||
Set<ApiUriTemplate> templates = apiConfig.getUriTemplates();
|
||||
if(null != resourcesList) {
|
||||
if (null != resourcesList) {
|
||||
for (ApiUriTemplate template : templates) {
|
||||
String fullPaath = "";
|
||||
if (!template.getUriTemplate().equals(AnnotationProcessor.WILD_CARD)) {
|
||||
fullPaath = apiConfig.getContext() + template.getUriTemplate();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
fullPaath = apiConfig.getContext();
|
||||
}
|
||||
for(String context : resourcesList) {
|
||||
for (String context : resourcesList) {
|
||||
if (context.trim().equals(fullPaath)) {
|
||||
template.setAuthType(AUTH_TYPE_NON_SECURED);
|
||||
}
|
||||
|
||||
@ -25,60 +25,92 @@ import java.util.List;
|
||||
@XmlRootElement(name = "ResourceConfiguration")
|
||||
public class APIResourceConfiguration {
|
||||
|
||||
private String name;
|
||||
private String context;
|
||||
private String version;
|
||||
private List<APIResource> resources;
|
||||
private String[] tags;
|
||||
private String name;
|
||||
private String context;
|
||||
private String apiDocumentationName;
|
||||
private String apiDocumentationSummary;
|
||||
private String apiDocumentationSourceFile;
|
||||
private String version;
|
||||
private List<APIResource> resources;
|
||||
private String[] tags;
|
||||
private String endpointType;
|
||||
private String inSequenceName;
|
||||
private String inSequenceConfig;
|
||||
private String asyncApiDefinition;
|
||||
|
||||
public List<APIResource> getResources() {
|
||||
return resources;
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Resources", required = true)
|
||||
public void setResources(List<APIResource> resources) {
|
||||
this.resources = resources;
|
||||
}
|
||||
@XmlElement(name = "Resources", required = true)
|
||||
public void setResources(List<APIResource> resources) {
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Context", required = true)
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
@XmlElement(name = "Context", required = true)
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Name")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@XmlElement(name = "Name")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
public String getApiDocumentationName() {
|
||||
return apiDocumentationName;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Version")
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
@XmlElement(name = "ApiDocumentation")
|
||||
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Tags")
|
||||
public void setTags(String[] tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
public void setApiDocumentationName(String apiDocumentationName) {
|
||||
this.apiDocumentationName = apiDocumentationName;
|
||||
}
|
||||
|
||||
public String getApiDocumentationSummary() {
|
||||
return apiDocumentationSummary;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ApiDocumentationSummary")
|
||||
public void setApiDocumentationSummary(String apiDocumentationSummary) {
|
||||
this.apiDocumentationSummary = apiDocumentationSummary;
|
||||
}
|
||||
|
||||
public String getApiDocumentationSourceFile() {
|
||||
return apiDocumentationSourceFile;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ApiDocumentationSourceFile")
|
||||
public void setApiDocumentationSourceFile(String apiDocumentationSourceFile) {
|
||||
this.apiDocumentationSourceFile = apiDocumentationSourceFile;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Version")
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Tags")
|
||||
public void setTags(String[] tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getEndpointType() {
|
||||
return endpointType;
|
||||
@ -110,6 +142,7 @@ public class APIResourceConfiguration {
|
||||
public String getAsyncApiDefinition() {
|
||||
return asyncApiDefinition;
|
||||
}
|
||||
|
||||
@XmlElement(name = "asyncApiDefinition")
|
||||
public void setAsyncApiDefinition(String asyncApiDefinition) {
|
||||
this.asyncApiDefinition = asyncApiDefinition;
|
||||
|
||||
@ -53,7 +53,6 @@ import java.util.*;
|
||||
public class AnnotationProcessor {
|
||||
|
||||
private static final Log log = LogFactory.getLog(AnnotationProcessor.class);
|
||||
|
||||
private static final String AUTH_TYPE = "Application & Application User";
|
||||
private static final String STRING_ARR = "string_arr";
|
||||
private static final String STRING = "string";
|
||||
@ -61,7 +60,6 @@ public class AnnotationProcessor {
|
||||
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus";
|
||||
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework";
|
||||
public static final String WILD_CARD = "/*";
|
||||
|
||||
private static final String SWAGGER_ANNOTATIONS_INFO = "info";
|
||||
private static final String SWAGGER_ANNOTATIONS_TAGS = "tags";
|
||||
private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions";
|
||||
@ -73,6 +71,9 @@ public class AnnotationProcessor {
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ROLES = "roles";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_NAME = "apiDocumentationName";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SUMMARY = "apiDocumentationSummary";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SOURCE_FILE = "apiDocumentationSourceFile";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE = "endpointType";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_NAME = "inSequenceName";
|
||||
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_CONFIG = "inSequenceConfig";
|
||||
@ -112,26 +113,25 @@ public class AnnotationProcessor {
|
||||
pathClazz = (Class<Path>) classLoader.loadClass(Path.class.getName());
|
||||
consumesClass = (Class<Consumes>) classLoader.loadClass(Consumes.class.getName());
|
||||
producesClass = (Class<Produces>) classLoader.loadClass(Produces.class.getName());
|
||||
apiClazz= (Class<SwaggerDefinition>)classLoader.loadClass((SwaggerDefinition.class.getName()));
|
||||
infoClass = (Class<io.swagger.annotations.Info>)classLoader
|
||||
apiClazz = (Class<SwaggerDefinition>) classLoader.loadClass((SwaggerDefinition.class.getName()));
|
||||
infoClass = (Class<io.swagger.annotations.Info>) classLoader
|
||||
.loadClass((io.swagger.annotations.Info.class.getName()));
|
||||
tagClass = (Class<io.swagger.annotations.Tag>)classLoader
|
||||
tagClass = (Class<io.swagger.annotations.Tag>) classLoader
|
||||
.loadClass((io.swagger.annotations.Tag.class.getName()));
|
||||
extensionClass = (Class<io.swagger.annotations.Extension>)classLoader
|
||||
extensionClass = (Class<io.swagger.annotations.Extension>) classLoader
|
||||
.loadClass((io.swagger.annotations.Extension.class.getName()));
|
||||
extensionPropertyClass = (Class<io.swagger.annotations.ExtensionProperty>)classLoader
|
||||
extensionPropertyClass = (Class<io.swagger.annotations.ExtensionProperty>) classLoader
|
||||
.loadClass(io.swagger.annotations.ExtensionProperty.class.getName());
|
||||
scopeClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scope>) classLoader
|
||||
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scope.class.getName());
|
||||
scopesClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scopes>) classLoader
|
||||
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scopes.class.getName());
|
||||
apiOperation = (Class<ApiOperation>)classLoader
|
||||
apiOperation = (Class<ApiOperation>) classLoader
|
||||
.loadClass((ApiOperation.class.getName()));
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error("An error has occurred while loading classes ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> scanStandardContext(String className) throws IOException {
|
||||
ExtendedAnnotationDB db = new ExtendedAnnotationDB();
|
||||
db.addIgnoredPackages(PACKAGE_ORG_APACHE);
|
||||
@ -166,7 +166,7 @@ public class AnnotationProcessor {
|
||||
if (Scopes != null) {
|
||||
apiScopes = processAPIScopes(Scopes);
|
||||
}
|
||||
if(apiResourceConfig != null){
|
||||
if (apiResourceConfig != null) {
|
||||
String rootContext = servletContext.getContextPath();
|
||||
pathClazzMethods = pathClazz.getMethods();
|
||||
Annotation rootContectAnno = clazz.getAnnotation(pathClazz);
|
||||
@ -199,21 +199,21 @@ public class AnnotationProcessor {
|
||||
" This API will not be published.";
|
||||
log.error(msg, e1);
|
||||
} catch (RuntimeException e) {
|
||||
log.error("Unexpected error has been occurred while publishing "+ className
|
||||
+"hence, this API will not be published.");
|
||||
log.error("Unexpected error has been occurred while publishing " + className
|
||||
+ "hence, this API will not be published.");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return apiResourceConfig;
|
||||
}
|
||||
});
|
||||
if(apiResourceConfiguration !=null)
|
||||
if (apiResourceConfiguration != null)
|
||||
apiResourceConfigs.add(apiResourceConfiguration);
|
||||
}
|
||||
}
|
||||
return apiResourceConfigs;
|
||||
}
|
||||
|
||||
private Map<String,ApiScope> processAPIScopes(Annotation annotation) throws Throwable {
|
||||
private Map<String, ApiScope> processAPIScopes(Annotation annotation) throws Throwable {
|
||||
Map<String, ApiScope> scopes = new HashMap<>();
|
||||
|
||||
InvocationHandler methodHandler = Proxy.getInvocationHandler(annotation);
|
||||
@ -225,7 +225,7 @@ public class AnnotationProcessor {
|
||||
StringBuilder aggregatedPermissions;
|
||||
String roles[];
|
||||
StringBuilder aggregatedRoles;
|
||||
for(int i=0; i<annotatedScopes.length; i++){
|
||||
for (int i = 0; i < annotatedScopes.length; i++) {
|
||||
aggregatedPermissions = new StringBuilder();
|
||||
aggregatedRoles = new StringBuilder();
|
||||
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
|
||||
@ -236,16 +236,16 @@ public class AnnotationProcessor {
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION), annotatedScopes[i], STRING));
|
||||
scope.setKey(invokeMethod(scopeClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_KEY), annotatedScopes[i], STRING));
|
||||
permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null);
|
||||
permissions = (String[]) methodHandler.invoke(annotatedScopes[i], scopeClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null), null);
|
||||
for (String permission : permissions) {
|
||||
aggregatedPermissions.append(PERMISSION_PREFIX);
|
||||
aggregatedPermissions.append(permission);
|
||||
aggregatedPermissions.append(" ");
|
||||
}
|
||||
scope.setPermissions(aggregatedPermissions.toString().trim());
|
||||
roles = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_ROLES, null),null);
|
||||
roles = (String[]) methodHandler.invoke(annotatedScopes[i], scopeClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_ROLES, null), null);
|
||||
for (String role : roles) {
|
||||
aggregatedRoles.append(role);
|
||||
aggregatedRoles.append(",");
|
||||
@ -369,30 +369,30 @@ public class AnnotationProcessor {
|
||||
* Iterate API annotation and build API Configuration
|
||||
*
|
||||
* @param annotation reading @SwaggerDefinition annotation
|
||||
* @return APIResourceConfiguration which compose with an API information which has its name, context,version,and tags
|
||||
* @return APIResourceConfiguration which compose with an API information which has its name, context, version, api-documentation, and tags
|
||||
* @throws Throwable
|
||||
*/
|
||||
private APIResourceConfiguration processAPIAnnotation(Annotation annotation) throws Throwable {
|
||||
InvocationHandler methodHandler = Proxy.getInvocationHandler(annotation);
|
||||
Annotation info = (Annotation) methodHandler.invoke(annotation, apiClazz
|
||||
.getMethod(SWAGGER_ANNOTATIONS_INFO,null),null);
|
||||
.getMethod(SWAGGER_ANNOTATIONS_INFO, null), null);
|
||||
Annotation[] tags = (Annotation[]) methodHandler.invoke(annotation, apiClazz
|
||||
.getMethod(SWAGGER_ANNOTATIONS_TAGS,null),null);
|
||||
.getMethod(SWAGGER_ANNOTATIONS_TAGS, null), null);
|
||||
String[] tagNames = new String[tags.length];
|
||||
for(int i=0; i<tags.length; i++){
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
methodHandler = Proxy.getInvocationHandler(tags[i]);
|
||||
tagNames[i]=(String)methodHandler.invoke(tags[i], tagClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_NAME, null),null);
|
||||
tagNames[i] = (String) methodHandler.invoke(tags[i], tagClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_NAME, null), null);
|
||||
}
|
||||
methodHandler = Proxy.getInvocationHandler(info);
|
||||
String version = (String)methodHandler.invoke(info, infoClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VERSION,null),null);
|
||||
if("".equals(version))return null;
|
||||
Annotation[] apiInfo = (Annotation[])methodHandler.invoke(info, infoClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_EXTENSIONS,null),null);
|
||||
String version = (String) methodHandler.invoke(info, infoClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VERSION, null), null);
|
||||
if ("".equals(version)) return null;
|
||||
Annotation[] apiInfo = (Annotation[]) methodHandler.invoke(info, infoClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_EXTENSIONS, null), null);
|
||||
methodHandler = Proxy.getInvocationHandler(apiInfo[0]);
|
||||
Annotation[] properties = (Annotation[])methodHandler.invoke(apiInfo[0], extensionClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES,null), null);
|
||||
Annotation[] properties = (Annotation[]) methodHandler.invoke(apiInfo[0], extensionClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES, null), null);
|
||||
APIResourceConfiguration apiResourceConfig = new APIResourceConfiguration();
|
||||
for (Annotation property : properties) {
|
||||
methodHandler = Proxy.getInvocationHandler(property);
|
||||
@ -400,7 +400,7 @@ public class AnnotationProcessor {
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_NAME, null),
|
||||
null);
|
||||
String value = (String) methodHandler.invoke(property, extensionPropertyClass
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null),null);
|
||||
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null), null);
|
||||
if ("".equals(key)) return null;
|
||||
switch (key) {
|
||||
case SWAGGER_ANNOTATIONS_PROPERTIES_NAME:
|
||||
@ -411,6 +411,18 @@ public class AnnotationProcessor {
|
||||
if ("".equals(value)) return null;
|
||||
apiResourceConfig.setContext(value);
|
||||
break;
|
||||
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_NAME:
|
||||
if ("".equals(value)) return null;
|
||||
apiResourceConfig.setApiDocumentationName(value);
|
||||
break;
|
||||
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SUMMARY:
|
||||
if ("".equals(value)) return null;
|
||||
apiResourceConfig.setApiDocumentationSummary(value);
|
||||
break;
|
||||
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SOURCE_FILE:
|
||||
if ("".equals(value)) return null;
|
||||
apiResourceConfig.setApiDocumentationSourceFile(value);
|
||||
break;
|
||||
case SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE:
|
||||
if ("".equals(value))
|
||||
return null;
|
||||
@ -485,19 +497,15 @@ public class AnnotationProcessor {
|
||||
* @param servletContext
|
||||
* @return null if cannot determin /WEB-INF/classes
|
||||
*/
|
||||
private static URL findWebInfClassesPath(ServletContext servletContext)
|
||||
{
|
||||
private static URL findWebInfClassesPath(ServletContext servletContext) {
|
||||
String path = servletContext.getRealPath("/WEB-INF/classes");
|
||||
if (path == null) return null;
|
||||
File fp = new File(path);
|
||||
if (fp.exists() == false) return null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
URI uri = fp.toURI();
|
||||
return uri.toURL();
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
<module>org.wso2.carbon.apimgt.keymgt.extension</module>
|
||||
<module>org.wso2.carbon.apimgt.keymgt.extension.api</module>
|
||||
<module>io.entgra.device.mgt.core.apimgt.analytics.extension</module>
|
||||
<module>io.entgra.device.mgt.core.apimgt.extension.rest.api</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3244,7 +3244,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
||||
applicationDTO.getApplicationReleaseDTOs().get(0));
|
||||
validateAppReleaseUpdating(customAppReleaseWrapper, applicationDTO, applicationArtifact,
|
||||
ApplicationType.ENTERPRISE.toString());
|
||||
ApplicationType.CUSTOM.toString());
|
||||
applicationReleaseDTO.get().setPrice(customAppReleaseWrapper.getPrice());
|
||||
applicationReleaseDTO.get()
|
||||
.setIsSharedWithAllTenants(applicationReleaseDTO.get().getIsSharedWithAllTenants());
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>heartbeat-management</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>identity-extensions</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>identity-extensions</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>logger</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>io.entgra.notification.logger</artifactId>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>policy-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>policy-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>policy-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>policy-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -16,12 +16,11 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>subtype-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -16,12 +16,11 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<parent>
|
||||
<artifactId>task-manager</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>task-manager</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>task-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>task-watcher</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>task-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -16,13 +16,11 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>tenant-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -16,13 +16,11 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>tenant-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -16,13 +16,11 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>email-sender</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>transport-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>sms-handler</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>sms-handler</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>sms-handler</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>transport-mgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>ui-request-interceptor</artifactId>
|
||||
<groupId>io.entgra.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>webapp-authenticator-framework</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>grafana-mgt-feature</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>grafana-mgt-feature</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>analytics-mgt-feature</artifactId>
|
||||
<version>5.0.25-SNAPSHOT</version>
|
||||
<version>5.0.26-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user