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<D extends Domain, B extends 
Builder<D, B>> {
 
-    }
-
-    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;
         }
 
-        public Domain build() {
+        public D build() {
             return this.domain;
         }
     }
 
-    private String key;
-
-    private String jdbcDriver;
-
-    private String jdbcURL;
-
-    private String dbSchema;
-
-    private String dbUsername;
-
-    private String dbPassword;
-
-    private TransactionIsolation transactionIsolation = 
TransactionIsolation.TRANSACTION_READ_COMMITTED;
-
-    private int poolMaxActive = 10;
-
-    private int poolMinIdle = 2;
-
-    private String auditSql = "audit.sql";
-
-    private String orm = "META-INF/spring-orm.xml";
-
-    private String databasePlatform;
-
-    private String adminPassword;
-
-    private CipherAlgorithm adminCipherAlgorithm = CipherAlgorithm.SHA512;
-
-    private String content;
-
-    private String keymasterConfParams;
-
-    public String getKey() {
-        return key;
-    }
-
-    public String getJdbcDriver() {
-        return jdbcDriver;
-    }
-
-    public String getJdbcURL() {
-        return jdbcURL;
-    }
-
-    public String getDbSchema() {
-        return dbSchema;
-    }
-
-    public String getDbUsername() {
-        return dbUsername;
-    }
+    protected static String read(final String filename) {
+        String read = null;
+        try {
+            read = IOUtils.toString(Domain.class.getResourceAsStream('/' + 
filename));
+        } catch (IOException e) {
+            LOG.error("Could not read {}", filename, e);
+        }
 
-    public String getDbPassword() {
-        return dbPassword;
+        return read;
     }
 
-    public TransactionIsolation getTransactionIsolation() {
-        return transactionIsolation;
-    }
+    protected String key;
 
-    public int getPoolMaxActive() {
-        return poolMaxActive;
-    }
+    protected String adminPassword;
 
-    public void setPoolMaxActive(final int poolMaxActive) {
-        this.poolMaxActive = poolMaxActive;
-    }
+    protected CipherAlgorithm adminCipherAlgorithm = CipherAlgorithm.SHA512;
 
-    public int getPoolMinIdle() {
-        return poolMinIdle;
-    }
+    protected String content;
 
-    public void setPoolMinIdle(final int poolMinIdle) {
-        this.poolMinIdle = poolMinIdle;
-    }
+    protected String keymasterConfParams;
 
-    public String getAuditSql() {
-        return auditSql;
+    @JsonProperty("_class")
+    public String getDiscriminator() {
+        return getClass().getName();
     }
 
-    public String getOrm() {
-        return orm;
+    public void setDiscriminator(final String discriminator) {

Review Comment:
   ## Useless parameter
   
   The parameter 'discriminator' is never used.
   
   [Show more 
details](https://github.com/apache/syncope/security/code-scanning/1525)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@syncope.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to