Skip to content

Commit

Permalink
feat: create apis to verify and save license api-keys in Admin UI #1196
Browse files Browse the repository at this point in the history
… (#1203)

* feat: create apis to verify and save license api-keys in Admin UI #1196

* feat: create apis to verify and save license api-keys in Admin UI #1196

* feat: create apis to verify and save license api-keys in Admin UI #1196
  • Loading branch information
duttarnab authored Apr 18, 2022
1 parent 90f77c3 commit 315faec
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class DynamicConfig {
private List<AdminRole> roles;
private List<AdminPermission> permissions;
private List<RolePermissionMapping> rolePermissionMapping;
private LicenseSpringCredentials licenseSpringCredentials;

public List<AdminRole> getRoles() {
return roles;
Expand All @@ -31,4 +32,12 @@ public List<RolePermissionMapping> getRolePermissionMapping() {
public void setRolePermissionMapping(List<RolePermissionMapping> rolePermissionMapping) {
this.rolePermissionMapping = rolePermissionMapping;
}

public LicenseSpringCredentials getLicenseSpringCredentials() {
return licenseSpringCredentials;
}

public void setLicenseSpringCredentials(LicenseSpringCredentials licenseSpringCredentials) {
this.licenseSpringCredentials = licenseSpringCredentials;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.jans.as.model.config.adminui;

public class LicenseSpringCredentials {
private String apiKey;
private String productCode;
private String sharedKey;
private String managementKey;

public String getApiKey() {
return apiKey;
}

public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}

public String getProductCode() {
return productCode;
}

public void setProductCode(String productCode) {
this.productCode = productCode;
}

public String getSharedKey() {
return sharedKey;
}

public void setSharedKey(String sharedKey) {
this.sharedKey = sharedKey;
}

public String getManagementKey() {
return managementKey;
}

public void setManagementKey(String managementKey) {
this.managementKey = managementKey;
}

@Override
public String toString() {
return "LicenseSpringCredentials{" +
"apiKey='" + apiKey + '\'' +
", productCode='" + productCode + '\'' +
", sharedKey='" + sharedKey + '\'' +
", managementKey='" + managementKey + '\'' +
'}';
}
}
144 changes: 137 additions & 7 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,95 @@ paths:
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/jans-config-api/admin-ui/license/isActive:
get:
tags:
- Admin UI - License
x-cli-plugin: admin-ui
summary: Check if admin-ui license is active.
description: Check if admin-ui license is active.
operationId: is-license-active
security:
- oauth2: [https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly]
responses:
'200':
description: OK
content:
application/json:
schema:
title: Check if admin-ui license is active.
description: Check if admin-ui license is active.
$ref: '#/components/schemas/LicenseApiResponse'
'400':
$ref: '#/components/schemas/LicenseApiResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/schemas/LicenseApiResponse'
/jans-config-api/admin-ui/license/activateLicense:
post:
tags:
- Admin UI - License
x-cli-plugin: admin-ui
summary: Activate license using license-key.
description: Activate license using license-key.
operationId: activate-adminui-license
security:
- oauth2: [https://jans.io/oauth/jans-auth-server/config/adminui/license.write]
requestBody:
content:
application/json:
schema:
required:
- licenseKey
$ref: '#/components/schemas/LicenseApiRequest'
responses:
'200':
description: OK
content:
application/json:
schema:
title: Activate license using license-key.
description: Activate license using license-key.
$ref: '#/components/schemas/LicenseApiResponse'
'400':
$ref: '#/components/schemas/LicenseApiResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/schemas/LicenseApiResponse'
/jans-config-api/admin-ui/license/saveApiCredentials:
post:
tags:
- Admin UI - License
x-cli-plugin: admin-ui
summary: Save license api credentials.
description: Save license api credentials.
operationId: save-license-api-credentials
security:
- oauth2: [https://jans.io/oauth/jans-auth-server/config/adminui/license.write]
requestBody:
content:
application/json:
schema:
required:
- licenseKey
$ref: '#/components/schemas/LicenseSpringCredentials'
responses:
'200':
description: OK
content:
application/json:
schema:
title: Save license api credentials.
description: Save license api credentials.
$ref: '#/components/schemas/LicenseApiResponse'
'400':
$ref: '#/components/schemas/LicenseApiResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/schemas/LicenseApiResponse'
/jans-config-api/admin-ui/license/licenseDetails:
get:
tags:
Expand All @@ -3527,7 +3616,7 @@ paths:
schema:
title: Get admin ui license details.
description: Get admin ui license details.
$ref: '#/components/schemas/LicenseResponse'
$ref: '#/components/schemas/LicenseDetailsResponse'
'400':
$ref: '#/components/responses/NotAcceptable'
'401':
Expand All @@ -3549,7 +3638,7 @@ paths:
schema:
required:
- role
$ref: '#/components/schemas/LicenseRequest'
$ref: '#/components/schemas/LicenseDetailsRequest'
responses:
'200':
description: OK
Expand All @@ -3558,7 +3647,7 @@ paths:
schema:
title: Edit admin ui license details.
description: Edit admin ui license details.
$ref: '#/components/schemas/LicenseResponse'
$ref: '#/components/schemas/LicenseDetailsResponse'
'400':
$ref: '#/components/responses/NotAcceptable'
'401':
Expand Down Expand Up @@ -6759,9 +6848,9 @@ components:
items:
type: string
description: permissions
LicenseRequest:
LicenseDetailsRequest:
type: object
description: Admin license request
description: Admin license details request
required:
- validityPeriod
properties:
Expand All @@ -6774,9 +6863,38 @@ components:
licenseActive:
type: string
description: Is license active?
LicenseResponse:
LicenseApiRequest:
type: object
description: Admin license response
description: Admin license api request
required:
- licenseKey
properties:
licenseKey:
type: string
description: The license-key.
LicenseSpringCredentials:
type: object
required:
- apiKey
- productCode
- sharedKey
- managementKey
properties:
apiKey:
type: string
description: The api-key.
productCode:
type: string
description: The product-code.
sharedKey:
type: string
description: The shared-key.
managementKey:
type: string
description: The management-key.
LicenseDetailsResponse:
type: object
description: Admin license details response
properties:
licenseEnabled:
type: boolean
Expand Down Expand Up @@ -6816,6 +6934,18 @@ components:
customerLastName:
type: string
description: The customer last name.
LicenseApiResponse:
type: object
properties:
apiResult:
type: boolean
description: liceseSpring api request success status
responseMessage:
type: string
description: Response Message
responseCode:
type: integer
description: Response code
ScimAppConfiguration:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.jans.ca.plugin.adminui.model.auth;

public class LicenseApiResponse {
private boolean apiResult;
private String responseMessage;
private int responseCode;

public String getResponseMessage() {
return responseMessage;
}

public void setResponseMessage(String responseMessage) {
this.responseMessage = responseMessage;
}

public int getResponseCode() {
return responseCode;
}

public void setResponseCode(int responseCode) {
this.responseCode = responseCode;
}

public boolean isApiResult() {
return apiResult;
}

public void setApiResult(boolean apiResult) {
this.apiResult = apiResult;
}

@Override
public String toString() {
return "LicenseApiResponse{" +
"apiResult=" + apiResult +
", responseMessage='" + responseMessage + '\'' +
", responseCode=" + responseCode +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ public class LicenseConfiguration {
private String productCode;
private String sharedKey;
private String managementKey;
private Boolean enabled = Boolean.FALSE;
private Boolean enabled = Boolean.TRUE;
LicenseSpringConfiguration licenseSpringConfiguration;
LicenseManager licenseManager;

public LicenseConfiguration() {
}

public LicenseConfiguration(String apiKey, String productCode, String sharedKey, String managementKey, Boolean enabled) {
this.apiKey = apiKey;
this.productCode = productCode;
this.sharedKey = sharedKey;
this.enabled = enabled;
this.managementKey = managementKey;

if(Boolean.TRUE.equals(this.enabled)) {
if (Boolean.TRUE.equals(this.enabled)) {
initializeLicenseManager();
}
}
Expand All @@ -43,6 +44,7 @@ public void initializeLicenseManager() {
.build();

this.licenseManager = LicenseManager.getInstance();

if (!licenseManager.isInitialized()) {
licenseManager.initialize(licenseSpringConfiguration);
}
Expand Down
Loading

0 comments on commit 315faec

Please sign in to comment.