diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java
index 471136864a2..8b48346e6e6 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java
@@ -87,12 +87,11 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
@POST
public Response register(RegistrationProfile registrationProfile) {
try {
- if (registrationProfile.getTags() == null || registrationProfile.getTags().length == 0) {
- return Response.status(Response.Status.NOT_ACCEPTABLE).entity("Tags should not be empty").build();
- }
- if (!APIUtil.getAllowedApisTags().containsAll(Arrays.asList(registrationProfile.getTags()))) {
- return Response.status(Response.Status.NOT_ACCEPTABLE).entity("APIs(Tags) are not allowed to this user."
- ).build();
+ if ((registrationProfile.getTags() != null && registrationProfile.getTags().length != 0)) {
+ if (!APIUtil.getAllowedApisTags().containsAll(Arrays.asList(registrationProfile.getTags()))) {
+ return Response.status(Response.Status.NOT_ACCEPTABLE).entity("APIs(Tags) are not allowed to this user."
+ ).build();
+ }
}
String username = APIUtil.getAuthenticatedUser();
@@ -142,4 +141,4 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
}
}
-}
\ No newline at end of file
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml
new file mode 100644
index 00000000000..dc93695b1dc
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml
@@ -0,0 +1,60 @@
+
+
+
+ apimgt-extensions
+ org.wso2.carbon.devicemgt
+ 5.0.11-SNAPSHOT
+
+
+ 4.0.0
+ org.wso2.carbon.apimgt.keymgt.extension.api
+ war
+ WSO2 Carbon - API Key Management API
+ This module extends the API manager's key management apis.
+ http://wso2.org
+
+
+
+
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
+ maven-war-plugin
+
+ WEB-INF/lib/*cxf*.jar
+ ${project.artifactId}
+
+
+
+
+
+
+
+ org.springframework
+ spring-web
+ provided
+
+
+ org.apache.cxf
+ cxf-bundle-jaxrs
+ provided
+
+
+ org.codehaus.jackson
+ jackson-jaxrs
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.apimgt.keymgt.extension
+ ${carbon.device.mgt.version}
+ provided
+
+
+
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java
new file mode 100644
index 00000000000..36f6c4d9f73
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension.api;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DCRRequest {
+ @XmlElement(required = true)
+ private String clientName;
+ @XmlElement(required = true)
+ private String owner;
+ @XmlElement(required = true)
+ private String grantTypes;
+ @XmlElement
+ private String callBackUrl;
+ @XmlElement(required = true)
+ private String[] tags;
+ @XmlElement
+ private boolean isSaasApp;
+
+ public String getClientName() {
+ return clientName;
+ }
+
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getGrantTypes() {
+ return grantTypes;
+ }
+
+ public void setGrantTypes(String grantTypes) {
+ this.grantTypes = grantTypes;
+ }
+
+ public String getCallBackUrl() {
+ return callBackUrl;
+ }
+
+ public void setCallBackUrl(String callBackUrl) {
+ this.callBackUrl = callBackUrl;
+ }
+
+ public String[] getTags() {
+ return tags;
+ }
+
+ public void setTags(String[] tags) {
+ this.tags = tags;
+ }
+
+ public boolean getIsSaasApp() {
+ return isSaasApp;
+ }
+
+ public void setIsSaasApp(boolean saasApp) {
+ isSaasApp = saasApp;
+ }
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java
new file mode 100644
index 00000000000..14ca64a2e60
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension.api;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+public interface KeyManagerService {
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/dynamic-client-registration")
+ Response dynamicClientRegistration(DCRRequest request);
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Path("/token")
+ Response generateAccessToken(@FormParam("client_id") String clientId,
+ @FormParam("client_secret") String clientSecret,
+ @FormParam("refresh_token") String refreshToken,
+ @FormParam("scope") String scope,
+ @FormParam("grant_type") String grantType);
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java
new file mode 100644
index 00000000000..53b2c4ffca5
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension.api;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.apimgt.keymgt.extension.DCRResponse;
+import org.wso2.carbon.apimgt.keymgt.extension.TokenRequest;
+import org.wso2.carbon.apimgt.keymgt.extension.TokenResponse;
+import org.wso2.carbon.apimgt.keymgt.extension.exception.BadRequestException;
+import org.wso2.carbon.apimgt.keymgt.extension.exception.KeyMgtException;
+import org.wso2.carbon.apimgt.keymgt.extension.service.KeyMgtService;
+import org.wso2.carbon.apimgt.keymgt.extension.service.KeyMgtServiceImpl;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+public class KeyManagerServiceImpl implements KeyManagerService {
+
+ @Override
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/dynamic-client-registration")
+ public Response dynamicClientRegistration(DCRRequest dcrRequest) {
+ try {
+ KeyMgtService keyMgtService = new KeyMgtServiceImpl();
+ DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getClientName(), dcrRequest.getOwner(),
+ dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp());
+ return Response.status(Response.Status.CREATED).entity(resp).build();
+ } catch (KeyMgtException e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
+ }
+ }
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Path("/token")
+ public Response generateAccessToken(@FormParam("client_id") String clientId,
+ @FormParam("client_secret") String clientSecret,
+ @FormParam("refresh_token") String refreshToken,
+ @FormParam("scope") String scope,
+ @FormParam("grant_type") String grantType) {
+ try {
+ KeyMgtService keyMgtService = new KeyMgtServiceImpl();
+ TokenResponse resp = keyMgtService.generateAccessToken(
+ new TokenRequest(clientId, clientSecret, refreshToken, scope, grantType));
+ return Response.status(Response.Status.CREATED).entity(resp).build();
+ } catch (KeyMgtException e) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
+ } catch (BadRequestException e) {
+ return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
+ }
+ }
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/permissions.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/permissions.xml
new file mode 100644
index 00000000000..190a634a123
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/permissions.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/webapp-classloading.xml
new file mode 100644
index 00000000000..9f50930c4f7
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/META-INF/webapp-classloading.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+ false
+
+
+ CXF3,Carbon
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml
new file mode 100644
index 00000000000..6d5685c5f50
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/web.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..fe5ca1742ee
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,109 @@
+
+
+
+ Grafana-API-Proxy-Webapp
+
+ JAX-WS/JAX-RS Grafana API Management Endpoint
+ JAX-WS/JAX-RS Servlet
+ CXFServlet
+
+ org.apache.cxf.transport.servlet.CXFServlet
+
+
+
+ swagger.security.filter
+ ApiAuthorizationFilterImpl
+
+ 1
+
+
+ CXFServlet
+ /*
+
+
+ 60
+
+
+
+ doAuthentication
+ false
+
+
+ basicAuth
+ false
+
+
+
+ nonSecuredEndPoints
+
+ /keymgt-test-api/.*,
+
+
+
+
+
+ managed-api-enabled
+ true
+
+
+ managed-api-owner
+ admin
+
+
+ isSharedWithAllTenants
+ true
+
+
+
+ HttpHeaderSecurityFilter
+ org.apache.catalina.filters.HttpHeaderSecurityFilter
+
+ hstsEnabled
+ false
+
+
+
+
+ ContentTypeBasedCachePreventionFilter
+ org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter
+
+ patterns
+ text/html" ,application/json" ,text/plain
+
+
+ filterAction
+ enforce
+
+
+ httpHeaders
+ Cache-Control: no-store, no-cache, must-revalidate, private
+
+
+
+
+ HttpHeaderSecurityFilter
+ /*
+
+
+
+ ContentTypeBasedCachePreventionFilter
+ /*
+
+
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml
index e90923172bc..f53e5d05e08 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml
@@ -43,7 +43,7 @@
org.apache.felix
maven-bundle-plugin
- 1.4.0
+ 5.1.7
true
@@ -51,10 +51,16 @@
${project.artifactId}
${carbon.device.mgt.version}
API Management Application Bundle
+ org.wso2.carbon.apimgt.keymgt.extension.internal
+ org.wso2.carbon.apimgt.application.extension,
+ org.wso2.carbon.apimgt.application.extension.*,
+ org.wso2.carbon.device.mgt.common.*,
+ org.wso2.carbon.device.mgt.core.*
- org.wso2.carbon.apimgt.keymgt.extension
+ !org.wso2.carbon.apimgt.keymgt.extension.internal,
+ org.wso2.carbon.apimgt.keymgt.extension.*
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/CustomKeyManager.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/CustomKeyManager.java
new file mode 100644
index 00000000000..eca37026d99
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/CustomKeyManager.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.apimgt.api.APIManagementException;
+import org.wso2.carbon.apimgt.api.model.AccessTokenInfo;
+import org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl;
+
+public class CustomKeyManager extends AMDefaultKeyManagerImpl {
+ private static final Log log = LogFactory.getLog(CustomKeyManager.class);
+
+ /**
+ * This is used to get the metadata of the access token.
+ *
+ * @param accessToken AccessToken.
+ * @return The meta data details of access token.
+ * @throws APIManagementException This is the custom exception class for API management.
+ */
+ @Override
+ public AccessTokenInfo getTokenMetaData(String accessToken) throws APIManagementException {
+ log.debug("Access Token With Prefix : "+accessToken);
+ String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_")+1);
+ log.debug("Access Token WithOut Prefix : "+accessTokenWithoutPrefix);
+ return super.getTokenMetaData(accessTokenWithoutPrefix);
+ }
+
+ @Override
+ public String getType() {
+ return KeyMgtConstants.CUSTOM_TYPE;
+ }
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/DCRResponse.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/DCRResponse.java
new file mode 100644
index 00000000000..22dc2336a6a
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/DCRResponse.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension;
+
+public class DCRResponse {
+ String clientId;
+ String clientSecret;
+
+ public DCRResponse(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;
+ }
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java
new file mode 100644
index 00000000000..e68d69bfb09
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension;
+
+import org.wso2.carbon.apimgt.api.model.ConfigurationDto;
+import org.wso2.carbon.apimgt.impl.APIConstants;
+import org.wso2.carbon.apimgt.impl.DefaultKeyManagerConnectorConfiguration;
+import org.wso2.carbon.apimgt.impl.jwt.JWTValidatorImpl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @scr.component name="org.wso2.carbon.apimgt.keymgt.extension.customKeyManagerConfigComponent" immediate="true"
+ */
+public class KeyManagerConnectorConfiguration extends DefaultKeyManagerConnectorConfiguration {
+
+ @Override
+ public String getImplementation() {
+ return CustomKeyManager.class.getName();
+ }
+
+ @Override
+ public String getJWTValidator() {
+ return JWTValidatorImpl.class.getName();
+ }
+
+ @Override
+ public List getApplicationConfigurations() {
+ return super.getApplicationConfigurations();
+ }
+
+ @Override
+ public String getType() {
+ return KeyMgtConstants.CUSTOM_TYPE;
+ }
+
+ @Override
+ public String getDefaultScopesClaim() {
+ return APIConstants.JwtTokenConstants.SCOPE;
+ }
+
+ @Override
+ public String getDefaultConsumerKeyClaim() {
+ return APIConstants.JwtTokenConstants.AUTHORIZED_PARTY;
+ }
+
+ @Override
+ public List getConnectionConfigurations() {
+ List configurationDtoList = new ArrayList<>();
+ configurationDtoList.add(new ConfigurationDto("Username", "Username", "input", "Username of admin user", "", true, false, Collections.emptyList(), false));
+ configurationDtoList.add(new ConfigurationDto("Password", "Password", "input", "Password of Admin user", "", true, true, Collections.emptyList(), false));
+ configurationDtoList.addAll(super.getConnectionConfigurations());
+ return configurationDtoList;
+ }
+}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerPayload.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerPayload.java
new file mode 100644
index 00000000000..47d254ad6c3
--- /dev/null
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/KeyManagerPayload.java
@@ -0,0 +1,333 @@
+/*
+ * 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.
+ */
+
+package org.wso2.carbon.apimgt.keymgt.extension;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class KeyManagerPayload {
+ private String name;
+ private String displayName;
+ private String type;
+ private String description;
+ private String wellKnownEndpoint;
+ private String introspectionEndpoint;
+ private String clientRegistrationEndpoint;
+ private String tokenEndpoint;
+ private String displayTokenEndpoint;
+ private String revokeEndpoint;
+ private String displayRevokeEndpoint;
+ private String userInfoEndpoint;
+ private String authorizeEndpoint;
+ private Map certificates;
+ private String issuer;
+ private String scopeManagementEndpoint;
+ private List availableGrantTypes;
+ private boolean enableTokenGeneration;
+ private boolean enableTokenEncryption;
+ private boolean enableTokenHashing;
+ private boolean enableMapOAuthConsumerApps;
+ private boolean enableOAuthAppCreation;
+ private boolean enableSelfValidationJWT;
+ private List claimMapping;
+ private String consumerKeyClaim;
+ private String scopesClaim;
+ private List
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-jaxrs-war
+ package
+
+ copy
+
+
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.apimgt.keymgt.extension.api
+ war
+ true
+ ${project.build.directory}/maven-shared-archive-resources/webapps/
+ api-key-management.war
+
+
+
+
+
+
org.wso2.maven
carbon-p2-plugin
diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/src/main/resources/p2.inf
index a828a69832a..03e2e6eb95b 100644
--- a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/src/main/resources/p2.inf
+++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/src/main/resources/p2.inf
@@ -1 +1,3 @@
instructions.configure = \
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.keymgt.extension_${feature.version}/webapps/api-key-management.war,target:${installFolder}/../../deployment/server/webapps/api-key-management.war,overwrite:true);\
diff --git a/pom.xml b/pom.xml
index 4318441f2cc..8df731c2fbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -343,6 +343,11 @@
io.entgra.analytics.mgt.grafana.proxy.common
${carbon.device.mgt.version}
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.apimgt.keymgt.extension.api
+ ${carbon.device.mgt.version}
+