Skip to content

Commit

Permalink
Merge branch 'master' into global_master
Browse files Browse the repository at this point in the history
  • Loading branch information
prasa7 authored Feb 12, 2024
2 parents f3cd16e + 13b6312 commit f3b122e
Show file tree
Hide file tree
Showing 72 changed files with 148 additions and 119 deletions.
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.eventing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>apimgt</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
public class KeyMgtNotificationSender {

public void notify(KeyManagerConfigurationDTO keyManagerConfigurationDTO,String action) {
String encodedString = "";
if (keyManagerConfigurationDTO.getAdditionalProperties() != null){
String additionalProperties = new Gson().toJson(keyManagerConfigurationDTO.getAdditionalProperties());
encodedString = new String(Base64.encodeBase64(additionalProperties.getBytes()));
}

String keyManagerConfiguration = new Gson().toJson(keyManagerConfigurationDTO);
String encodedString = new String(Base64.encodeBase64(keyManagerConfiguration.getBytes()));
Object[] objects = new Object[]{APIConstants.KeyManager.KeyManagerEvent.KEY_MANAGER_CONFIGURATION, action,
keyManagerConfigurationDTO.getName(), keyManagerConfigurationDTO.getType(),
keyManagerConfigurationDTO.isEnabled(), encodedString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO;
import org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;
Expand Down Expand Up @@ -63,21 +64,22 @@ public void run() {
httpResponse = httpClient.execute(method);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String responseString = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
KeyManagerConfiguration[] keyManagerConfigurations =
new Gson().fromJson(responseString, KeyManagerConfiguration[].class);
for (KeyManagerConfiguration keyManagerConfiguration : keyManagerConfigurations) {
KeyManagerConfigurationDTO[] keyManagerConfigurationDTOS =
new Gson().fromJson(responseString, KeyManagerConfigurationDTO[].class);
for (KeyManagerConfigurationDTO keyManagerConfiguration : keyManagerConfigurationDTOS) {
if (keyManagerConfiguration.isEnabled()) {
KeyManagerConfiguration resolvedKeyManagerConfiguration = APIUtil.toKeyManagerConfiguration(keyManagerConfiguration);
try {
ServiceReferenceHolder.getInstance().getKeyManagerConfigurationService()
.addKeyManagerConfiguration(
keyManagerConfiguration.getTenantDomain(),
keyManagerConfiguration.getName(),
keyManagerConfiguration.getType(),
keyManagerConfiguration);
resolvedKeyManagerConfiguration.getTenantDomain(),
resolvedKeyManagerConfiguration.getName(),
resolvedKeyManagerConfiguration.getType(),
resolvedKeyManagerConfiguration);
} catch (APIManagementException e) {
log.error("Error while configuring Key Manager " +
keyManagerConfiguration.getName() +
" in tenant " + keyManagerConfiguration.getTenantDomain(), e);
" in tenant " + resolvedKeyManagerConfiguration.getTenantDomain(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7428,11 +7428,23 @@ public int compare(ConditionDto o1, ConditionDto o2) {
public static KeyManagerConfiguration toKeyManagerConfiguration(String base64EncodedString)
throws APIManagementException {

KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
String decodedString = new String(Base64.decodeBase64(base64EncodedString));
new Gson().fromJson(decodedString, Map.class);
Map configuration = new Gson().fromJson(decodedString, Map.class);
keyManagerConfiguration.setConfiguration(configuration);
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new Gson().fromJson(decodedString,
KeyManagerConfigurationDTO.class);
return toKeyManagerConfiguration(keyManagerConfigurationDTO);
}

public static KeyManagerConfiguration toKeyManagerConfiguration(KeyManagerConfigurationDTO keyManagerConfigurationDTO)
{

KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
keyManagerConfiguration.setName(keyManagerConfigurationDTO.getName());
keyManagerConfiguration.setConfiguration(keyManagerConfigurationDTO.getAdditionalProperties());
keyManagerConfiguration.setTenantDomain(keyManagerConfigurationDTO.getOrganization());
keyManagerConfiguration.setTokenType(KeyManagerConfiguration.TokenType.valueOf(keyManagerConfigurationDTO
.getTokenType().toUpperCase()));
keyManagerConfiguration.setEnabled(keyManagerConfigurationDTO.isEnabled());
keyManagerConfiguration.setType(keyManagerConfigurationDTO.getType());
return keyManagerConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.26-SNAPSHOT</version>
<version>9.29.27-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

public class KeyManagerDTO {

private String uuid = null;
private String name = null;
private String type = null;
private Boolean enabled = null;
private String tenantDomain = null;
private Object _configuration = null;
private String organization = null;
private Object additionalProperties = null;

@XmlType(name="TokenTypeEnum")
@XmlEnum(String.class)
Expand Down Expand Up @@ -55,6 +56,23 @@ public static TokenTypeEnum fromValue(String v) {
}
private TokenTypeEnum tokenType = TokenTypeEnum.DIRECT;

/**
**/
public KeyManagerDTO uuid(String uuid) {
this.uuid = uuid;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("uuid")
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}

/**
**/
public KeyManagerDTO name(String name) {
Expand Down Expand Up @@ -108,36 +126,36 @@ public void setEnabled(Boolean enabled) {

/**
**/
public KeyManagerDTO tenantDomain(String tenantDomain) {
this.tenantDomain = tenantDomain;
public KeyManagerDTO organization(String organization) {
this.organization = organization;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("tenantDomain")
public String getTenantDomain() {
return tenantDomain;
@JsonProperty("organization")
public String getOrganization() {
return organization;
}
public void setTenantDomain(String tenantDomain) {
this.tenantDomain = tenantDomain;
public void setOrganization(String organization) {
this.organization = organization;
}

/**
**/
public KeyManagerDTO _configuration(Object _configuration) {
this._configuration = _configuration;
public KeyManagerDTO additionalProperties(Object additionalProperties) {
this.additionalProperties = additionalProperties;
return this;
}


@ApiModelProperty(value = "")
@JsonProperty("configuration")
public Object getConfiguration() {
return _configuration;
@JsonProperty("additionalProperties")
public Object getAdditionalProperties() {
return additionalProperties;
}
public void setConfiguration(Object _configuration) {
this._configuration = _configuration;
public void setAdditionalProperties(Object additionalProperties) {
this.additionalProperties = additionalProperties;
}

/**
Expand Down Expand Up @@ -168,29 +186,31 @@ public boolean equals(java.lang.Object o) {
return false;
}
KeyManagerDTO keyManager = (KeyManagerDTO) o;
return Objects.equals(name, keyManager.name) &&
return Objects.equals(uuid, keyManager.uuid) &&
Objects.equals(name, keyManager.name) &&
Objects.equals(type, keyManager.type) &&
Objects.equals(enabled, keyManager.enabled) &&
Objects.equals(tenantDomain, keyManager.tenantDomain) &&
Objects.equals(_configuration, keyManager._configuration) &&
Objects.equals(organization, keyManager.organization) &&
Objects.equals(additionalProperties, keyManager.additionalProperties) &&
Objects.equals(tokenType, keyManager.tokenType);
}

@Override
public int hashCode() {
return Objects.hash(name, type, enabled, tenantDomain, _configuration, tokenType);
return Objects.hash(uuid, name, type, enabled, organization, additionalProperties, tokenType);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class KeyManagerDTO {\n");

sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n");
sb.append(" tenantDomain: ").append(toIndentedString(tenantDomain)).append("\n");
sb.append(" _configuration: ").append(toIndentedString(_configuration)).append("\n");
sb.append(" organization: ").append(toIndentedString(organization)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public static KeyManagerDTO toKeyManagerDTO(String tenantDomain,
KeyManagerConfigurationDTO keyManagerConfigurationDTO) {

KeyManagerDTO keyManagerDTO = new KeyManagerDTO();
keyManagerDTO.setUuid(keyManagerConfigurationDTO.getUuid());
keyManagerDTO.setEnabled(keyManagerConfigurationDTO.isEnabled());
keyManagerDTO.setName(keyManagerConfigurationDTO.getName());
keyManagerDTO.setTenantDomain(keyManagerConfigurationDTO.getOrganization());
keyManagerDTO.setType(keyManagerConfigurationDTO.getType());
keyManagerDTO.setTokenType(KeyManagerDTO.TokenTypeEnum.fromValue(keyManagerConfigurationDTO.getTokenType()));
keyManagerDTO.setConfiguration(keyManagerConfigurationDTO.getAdditionalProperties());
keyManagerDTO.setAdditionalProperties(keyManagerConfigurationDTO.getAdditionalProperties());
return keyManagerDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,15 +1000,17 @@ definitions:

KeyManager:
properties:
uuid:
type: string
name:
type: string
type:
type: string
enabled:
type: boolean
tenantDomain:
organization:
type: string
configuration:
additionalProperties:
type: object
tokenType:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@
},
"KeyManager" : {
"properties" : {
"uuid" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
Expand All @@ -1285,10 +1288,10 @@
"enabled" : {
"type" : "boolean"
},
"tenantDomain" : {
"organization" : {
"type" : "string"
},
"configuration" : {
"additionalProperties" : {
"type" : "object",
"properties" : { }
},
Expand Down
Loading

0 comments on commit f3b122e

Please sign in to comment.