diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java index 1816df83d8..d420bbc622 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api; import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; @@ -9,6 +27,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; + AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 50c6c7d4d4..d1613f3d74 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api; import com.google.gson.Gson; @@ -81,7 +99,6 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject params = new JSONObject(); params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE); - //ToDo: Remove hardcoded value params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken); params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); return getToken(params, consumerKey, consumerSecret); diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java index c2c0202c8a..7148286aa3 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api; import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java index c454444598..97033b6d5c 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.bean; /** @@ -6,63 +24,63 @@ package io.entgra.devicemgt.apimgt.extension.rest.api.bean; */ public class RegistrationProfile { - private String callbackUrl; - private String clientName; - private String tokenScope; - private String owner; - private String grantType; - private String applicationType; + 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(); + private static final String TAG = RegistrationProfile.class.getSimpleName(); - public String getCallbackUrl() { - return callbackUrl; - } + public String getCallbackUrl() { + return callbackUrl; + } - public void setCallbackUrl(String callBackUrl) { - this.callbackUrl = callBackUrl; - } + public void setCallbackUrl(String callBackUrl) { + this.callbackUrl = callBackUrl; + } - public String getClientName() { - return clientName; - } + public String getClientName() { + return clientName; + } - public void setClientName(String clientName) { - this.clientName = clientName; - } + public void setClientName(String clientName) { + this.clientName = clientName; + } - public String getTokenScope() { - return tokenScope; - } + public String getTokenScope() { + return tokenScope; + } - public void setTokenScope(String tokenScope) { - this.tokenScope = tokenScope; - } + public void setTokenScope(String tokenScope) { + this.tokenScope = tokenScope; + } - public String getOwner() { - return owner; - } + public String getOwner() { + return owner; + } - public void setOwner(String owner) { - this.owner = owner; - } + public void setOwner(String owner) { + this.owner = owner; + } - public String getGrantType() { - return grantType; - } + public String getGrantType() { + return grantType; + } - public void setGrantType(String grantType) { - this.grantType = grantType; - } + public void setGrantType(String grantType) { + this.grantType = grantType; + } - public String getApplicationType() { - return applicationType; - } + public String getApplicationType() { + return applicationType; + } - public void setApplicationType(String applicationType) { - this.applicationType = applicationType; - } + public void setApplicationType(String applicationType) { + this.applicationType = applicationType; + } public boolean isSaasApp() { return isSaasApp; @@ -73,10 +91,10 @@ public class RegistrationProfile { } public String toJSON() { - String jsonString = - "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + - "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + - "\", \"saasApp\" : " + isSaasApp + " }\n"; - return jsonString; - } + String jsonString = + "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + + "\", \"saasApp\" : " + isSaasApp + " }\n"; + return jsonString; + } } \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java index 4e92ad6d93..73b4a3a842 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java @@ -20,15 +20,6 @@ public final class Constants { public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; - public static final int DEFAULT_MIN_THREAD_POOL_SIZE = 8; - public static final int DEFAULT_MAX_THREAD_POOL_SIZE = 100; - public static final int DEFAULT_EXECUTOR_JOB_QUEUE_SIZE = 2000; - public static final long DEFAULT_KEEP_ALIVE_TIME_IN_MILLIS = 20000; - public static final String ADAPTER_MIN_THREAD_POOL_SIZE_NAME = "minThread"; - public static final String ADAPTER_MAX_THREAD_POOL_SIZE_NAME = "maxThread"; - public static final String ADAPTER_KEEP_ALIVE_TIME_NAME = "keepAliveTimeInMillis"; - public static final String ADAPTER_EXECUTOR_JOB_QUEUE_SIZE_NAME = "jobQueueSize"; - public static final String DEFAULT_CALLBACK = ""; public static final String DEFAULT_PASSWORD = ""; public static final String TOKEN_SCOPE = "production"; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java index e18c4b3d90..cbadf626b2 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java @@ -1,7 +1,25 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.dto; /** - * This holds api application consumer id and secret. + * This holds the consumer application information that return from the register application endpoint */ public class APIApplicationKey { private String clientName; @@ -14,7 +32,7 @@ public class APIApplicationKey { private String jsonAppAttribute; private String tokenType; - public APIApplicationKey(String clientId, String clientSecret){ + public APIApplicationKey(String clientId, String clientSecret) { this.clientId = clientId; this.clientSecret = clientSecret; } @@ -34,6 +52,7 @@ public class APIApplicationKey { public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } + public String getClientName() { return clientName; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java index f9c9a4db67..061e7e898d 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.dto; /** diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java index 897146bbcd..35a247a190 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java @@ -1,12 +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.devicemgt.apimgt.extension.rest.api.exceptions; -public class APIApplicationServicesException extends Exception{ +public class APIApplicationServicesException extends Exception { - public APIApplicationServicesException() {super();} + public APIApplicationServicesException() { + super(); + } - public APIApplicationServicesException(String message) {super();} + public APIApplicationServicesException(String message) { + super(); + } - public APIApplicationServicesException(String message, Throwable cause){super();} + public APIApplicationServicesException(String message, Throwable cause) { + super(); + } - public APIApplicationServicesException(Throwable cause){super();} + public APIApplicationServicesException(Throwable cause) { + super(); + } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java index 00d4b423fa..25cebe82fc 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java @@ -1,22 +1,19 @@ /* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * * Copyright (c) 2022, 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. + * 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. */ /** diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java index ce651eeb36..9545a94fb4 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.internal; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; @@ -8,12 +26,14 @@ public class PublisherRESTAPIDataHolder { private APIApplicationServices apiApplicationServices; - public static PublisherRESTAPIDataHolder getInstance(){ + public static PublisherRESTAPIDataHolder getInstance() { return thisInstance; } + public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; } + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { this.apiApplicationServices = apiApplicationServices; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index 3817e365a4..fdf74638c6 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -1,3 +1,21 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.internal; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java index 8a7e6d2fbb..5716ebfcb1 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java @@ -1,8 +1,25 @@ +/* + * 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.devicemgt.apimgt.extension.rest.api.util; /** - * This class represents the data that are required to register - * the oauth application. + * This class represents the scope data. */ public class ScopeUtils { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 0aebefbaa4..5452a4f8bd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -432,15 +432,15 @@ public class APIPublisherServiceImpl implements APIPublisherService { //Set scope id which related to the scope key JSONArray scopeList = (JSONArray) scopeObject.get("list"); - JSONObject object = null; + JSONObject jsonObject = null; for (int i = 0; i < scopeList.length(); i++) { - JSONObject obj = null; - obj = scopeList.getJSONObject(i); - if (obj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { - object = obj; + JSONObject scopeObj = null; + scopeObj = scopeList.getJSONObject(i); + if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { + jsonObject = scopeObj; } } - scope.setId(object.getString("id")); + scope.setId(jsonObject.getString("id")); if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 01b1cd810c..949f16c3e9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.core.ServerStartupObserver; + import java.util.Stack; public class APIPublisherStartupHandler implements ServerStartupObserver { @@ -34,10 +35,12 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static final int MAX_RETRY_COUNT = 5; private static Stack failedAPIsStack = new Stack<>(); private static Stack currentAPIsStack; + private APIPublisherService publisher; @Override public void completingServerStartup() { + } @Override @@ -52,7 +55,6 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.debug("Total number of unpublished APIs: " + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); } - publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); int retryCount = 0; while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index 7cdede5bcb..f41c07967a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -299,7 +299,7 @@ public class AnnotationProcessor { // if (scope != null) { // resource.setScope(scope); // } else { -// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); // scope = new ApiScope(); // scope.setName(DEFAULT_SCOPE_NAME); @@ -537,7 +537,7 @@ public class AnnotationProcessor { if (scope != null) { apiResource.setScope(scope); } else { -// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); scope = new ApiScope(); scope.setName(DEFAULT_SCOPE_NAME); diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2c175c1ea1..c4bfc0d36d 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -25,32 +25,6 @@ 5.0.26-SNAPSHOT ../../pom.xml - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - com.squareup.okhttp3 - okhttp - - - org.json.wso2 - json - - - com.google.code.gson - gson - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - 4.0.0 apimgt-extensions