github-advanced-security[bot] commented on code in PR #628:
URL: https://github.com/apache/syncope/pull/628#discussion_r1500556449
##
common/keymaster/client-api/src/main/java/org/apache/syncope/common/keymaster/client/api/model/Domain.java:
##
@@ -18,208 +18,97 @@
*/
package org.apache.syncope.common.keymaster.client.api.model;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.io.IOException;
import java.io.Serializable;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.cxf.helpers.IOUtils;
import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class Domain implements Serializable {
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include =
JsonTypeInfo.As.EXISTING_PROPERTY, property = "_class")
+@JsonPropertyOrder(value = { "_class", "key" })
+public abstract class Domain implements Serializable {
private static final long serialVersionUID = -5881851479361505961L;
private static final Logger LOG = LoggerFactory.getLogger(Domain.class);
-public enum TransactionIsolation {
-TRANSACTION_NONE,
-TRANSACTION_READ_COMMITTED,
-TRANSACTION_READ_UNCOMMITTED,
-TRANSACTION_REPEATABLE_READ,
-TRANSACTION_SERIALIZABLE
+protected abstract static class Builder> {
-}
-
-public static class Builder {
-
-private final Domain domain;
+protected final D domain;
-public Builder(final String key) {
-this.domain = new Domain();
+Builder(final D domain, final String key) {
+this.domain = domain;
this.domain.key = key;
}
-public Builder jdbcDriver(final String jdbcDriver) {
-this.domain.jdbcDriver = jdbcDriver;
-return this;
-}
-
-public Builder jdbcURL(final String jdbcURL) {
-this.domain.jdbcURL = jdbcURL;
-return this;
-}
-
-public Builder dbSchema(final String dbSchema) {
-if (StringUtils.isNotBlank(dbSchema)) {
-this.domain.dbSchema = dbSchema;
-}
-return this;
-}
-
-public Builder dbUsername(final String dbUsername) {
-this.domain.dbUsername = dbUsername;
-return this;
-}
-
-public Builder dbPassword(final String dbPassword) {
-this.domain.dbPassword = dbPassword;
-return this;
-}
-
-public Builder transactionIsolation(final TransactionIsolation
transactionIsolation) {
-this.domain.transactionIsolation = transactionIsolation;
-return this;
-}
-
-public Builder poolMaxActive(final int poolMaxActive) {
-this.domain.poolMaxActive = poolMaxActive;
-return this;
-}
-
-public Builder poolMinIdle(final int poolMinIdle) {
-this.domain.poolMinIdle = poolMinIdle;
-return this;
-}
-
-public Builder auditSql(final String auditSql) {
-this.domain.auditSql = auditSql;
-return this;
-}
-
-public Builder orm(final String orm) {
-this.domain.orm = orm;
-return this;
-}
-
-public Builder databasePlatform(final String databasePlatform) {
-this.domain.databasePlatform = databasePlatform;
-return this;
-}
-
-public Builder adminPassword(final String adminPassword) {
+@SuppressWarnings("unchecked")
+public B adminPassword(final String adminPassword) {
this.domain.adminPassword = adminPassword;
-return this;
+return (B) this;
}
-public Builder adminCipherAlgorithm(final CipherAlgorithm
adminCipherAlgorithm) {
+@SuppressWarnings("unchecked")
+public B adminCipherAlgorithm(final CipherAlgorithm
adminCipherAlgorithm) {
this.domain.adminCipherAlgorithm = adminCipherAlgorithm;
-return this;
+return (B) this;
}
-public Builder content(final String content) {
+@SuppressWarnings("unchecked")
+public B content(final String content) {
this.domain.content = content;
-return this;
+return (B) this;
}
-public Builder keymasterConfParams(final String keymasterConfParams) {
+@SuppressWarnings("unchecked")
+public B keymasterConfParams(final String keymasterConfParams) {
this.domain.keymasterConfParams = keymasterConfParams;
-return this;
+return (B) this;
}