Skip to content

Commit

Permalink
Remove existing passphrase implementation + Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed Jan 31, 2023
1 parent 0a79e40 commit 199f37d
Showing 1 changed file with 16 additions and 38 deletions.
54 changes: 16 additions & 38 deletions src/java/com/phenix/pct/PCTConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Map;

/**
* Object to add a database connection to a PCTRun task
* Represent a database connection in PCT tasks
*
* @author <a href="mailto:[email protected]">Gilles QUERRET </a>
*/
Expand All @@ -49,8 +49,7 @@ public class PCTConnection extends DataType {
private File paramFile = null;
private Boolean singleUser = null;
private Boolean readOnly = null;
private String passphrase = null;
private Map<String, PCTAlias> aliases = null;
private Map<String, PCTAlias> aliases = new HashMap<>();
private List<PCTRunOption> options = null;

/**
Expand Down Expand Up @@ -174,13 +173,6 @@ public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}

/**
* If true, append -Passphrase to connection string
*/
public void setPassphrase(String passphrase) {
this.passphrase = passphrase;
}

/**
* If true, opens the database in single-user mode
*
Expand All @@ -198,7 +190,7 @@ public void addOption(PCTRunOption option) {
}

/**
* Adds an alias to the current DB connection.
* Add an alias to the current DB connection.
*
* The previous method's name (addPCTAlias) was changed when I switched from Vector to HashMap
* as a container for PCTAlias. When using addPCTAlias, you enter the method with a newly
Expand All @@ -212,10 +204,6 @@ public void addConfiguredPCTAlias(PCTAlias alias) {
}

public void addConfiguredAlias(PCTAlias alias) {
if (this.aliases == null) {
aliases = new HashMap<>();
}

if (aliases.put(alias.getName(), alias) != null)
throw new BuildException(MessageFormat.format(
Messages.getString("PCTConnection.0"), alias.getName())); //$NON-NLS-1$
Expand All @@ -226,7 +214,7 @@ protected PCTConnection getRef() {
}

/**
* Checks if aliases defined
* Check if aliases defined
*
* @return True if aliases defined for this database connection
*/
Expand All @@ -236,7 +224,7 @@ public boolean hasAliases() {
}

/**
* Checks if an alias is defined
* Check if an alias is defined
*
* @param aliasName String
* @return True if alias defined for this database connection
Expand All @@ -247,7 +235,7 @@ public boolean hasNamedAlias(String aliasName) {
}

/**
* Returns an ordered list of connection parameters
* Return a list of connection parameters
*
* @return List of String
* @throws BuildException Something went wrong (dbName or paramFile not defined)
Expand Down Expand Up @@ -298,7 +286,6 @@ public List<String> getConnectParametersList() {
list.remove("-1");
}
}


if (cacheFile != null) {
list.add("-cache"); //$NON-NLS-1$
Expand All @@ -320,21 +307,14 @@ public List<String> getConnectParametersList() {
list.add(hostName);
}

if (readOnly != null ) {
if (readOnly != null) {
if (readOnly) {
list.add("-RO");
}
else
{
} else {
list.remove("-RO");
}
}

if (passphrase != null) {
list.add("-KeyStorePassPhrase");
list.add(passphrase);
}

if ((userName != null) && (userName.trim().length() > 0)) {
list.add("-U"); //$NON-NLS-1$
list.add(userName);
Expand All @@ -359,7 +339,7 @@ public List<String> getConnectParametersList() {

}
/**
* Returns a string which could be used by a CONNECT statement or directly in a _progres or
* Return a string which could be used by a CONNECT statement or directly in a _progres or
* prowin32 command line
*
* @return Connection string
Expand All @@ -375,9 +355,9 @@ public String createConnectString() {
}

/**
* Returns a string which could be used to connect a database from a background worker Pipe
* separated list, first entry is connection string, followed by aliases. Aliases are comma
* separated list, first entry is alias name, second is 1 if NO-ERROR, 0 w/o no-error
* Return a string which could be used to connect a database from a background worker. Pipe
* separated list, first entry is connection string, followed by aliases. Aliases are
* comma-separated lists, first entry is alias name, second is 1 if NO-ERROR, 0 w/o no-error
*
* @return Connection string
*/
Expand Down Expand Up @@ -406,16 +386,14 @@ public void createArguments(ExecTask task) {
}

/**
* Returns defined aliases for a database connection
* Return defined aliases for a database connection
*
* @return Collection
*/
public Collection<PCTAlias> getAliases() {
Map<String, PCTAlias> map = new HashMap<>();
if (aliases != null) {
for (String str : aliases.keySet()) {
map.put(str, aliases.get(str));
}
for (Map.Entry<String, PCTAlias> entry : aliases.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
if (isReference()) {
for (PCTAlias alias : getRef().getAliases()) {
Expand All @@ -427,7 +405,7 @@ public Collection<PCTAlias> getAliases() {
}

/**
* Returns database name
* Return database name
*
* @return String
*/
Expand Down

0 comments on commit 199f37d

Please sign in to comment.