001package com.identityworksllc.iiq.common.task.export; 002 003import java.io.Serializable; 004import java.util.Objects; 005import java.util.Properties; 006 007/** 008 * A record / vo class used to pass connection info to the export partition. Your driver 009 * should already have been registered here. 010 */ 011public final class ExportConnectionInfo implements Serializable { 012 /** 013 * The driver class (currently not used) 014 */ 015 private String driver; 016 017 /** 018 * The encrypted password - will fail if not encrypted 019 */ 020 private String encryptedPassword; 021 022 /** 023 * Any additional driver options, unique per driver 024 */ 025 private Properties options; 026 027 /** 028 * The JDBC URL string 029 */ 030 private String url; 031 032 /** 033 * The username to connect 034 */ 035 private String username; 036 037 /** 038 * Construct an empty connection info 039 */ 040 public ExportConnectionInfo() { 041 this.options = new Properties(); 042 } 043 044 /** 045 * Construct a connection info with the given URL, username, and password 046 * @param url The URL 047 * @param username The username 048 * @param encryptedPassword The encrypted password 049 */ 050 public ExportConnectionInfo(String url, String username, String encryptedPassword) { 051 this(); 052 053 if (!Objects.requireNonNull(encryptedPassword, "encryptedPassword").contains(":ACP:")) { 054 throw new IllegalArgumentException("The password must in IIQ encrypted format"); 055 } 056 057 this.url = Objects.requireNonNull(url, "url"); 058 this.username = Objects.requireNonNull(username, "username"); 059 this.encryptedPassword = encryptedPassword; 060 } 061 062 /** 063 * Construct a connection info with the given URL, username, and password 064 * @param url The URL 065 * @param username The username 066 * @param encryptedPassword The encrypted password 067 * @param options The driver-specific connection options 068 */ 069 public ExportConnectionInfo(String url, String username, String encryptedPassword, Properties options) { 070 this(); 071 072 if (!Objects.requireNonNull(encryptedPassword, "encryptedPassword").contains(":ACP:")) { 073 throw new IllegalArgumentException("The password must in IIQ encrypted format"); 074 } 075 076 this.url = Objects.requireNonNull(url, "url"); 077 this.username = Objects.requireNonNull(username, "username"); 078 this.encryptedPassword = encryptedPassword; 079 this.options = options; 080 } 081 082 @Override 083 public boolean equals(Object o) { 084 if (this == o) return true; 085 if (o == null || getClass() != o.getClass()) return false; 086 ExportConnectionInfo that = (ExportConnectionInfo) o; 087 return Objects.equals(driver, that.driver) && Objects.equals(encryptedPassword, that.encryptedPassword) && Objects.equals(options, that.options) && Objects.equals(url, that.url) && Objects.equals(username, that.username); 088 } 089 090 public String getDriver() { 091 return driver; 092 } 093 094 public String getEncryptedPassword() { 095 return encryptedPassword; 096 } 097 098 public Properties getOptions() { 099 return options; 100 } 101 102 public String getUrl() { 103 return url; 104 } 105 106 public String getUsername() { 107 return username; 108 } 109 110 @Override 111 public int hashCode() { 112 return Objects.hash(driver, encryptedPassword, options, url, username); 113 } 114 115 public void setDriver(String driver) { 116 this.driver = driver; 117 } 118 119 public void setEncryptedPassword(String encryptedPassword) { 120 this.encryptedPassword = encryptedPassword; 121 } 122 123 public void setOptions(Properties options) { 124 this.options = options; 125 } 126 127 public void setUrl(String url) { 128 this.url = url; 129 } 130 131 public void setUsername(String username) { 132 this.username = username; 133 } 134}