Changeset bf62350bdabd0655c6703d349850d47ebebcb9d6

Show
Ignore:
Timestamp:
01/27/12 04:37:06 (2 years ago)
Author:
Theo Schlossnagle <jesus@lethargy.org>
git-committer:
Theo Schlossnagle <jesus@lethargy.org> 1327639026 -0800
git-parent:

[8c735aa0718a2a3a4a9072c7534b0330dc3cc003], [ad037ded4b14f9fe690f91990a34e0bc0de5a888]

git-author:
Theo Schlossnagle <jesus@lethargy.org> 1327639026 -0800
Message:

Merge pull request #48 from neophenix/master

JDBC DSN and basic SSL support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/java/com/omniti/jezebel/check/JDBC.java

    rb553f9a rad037de  
    4747  protected abstract String jdbcConnectUrl(String host, String port, String db); 
    4848  protected abstract String defaultPort(); 
     49  protected abstract Map<String,String> setupBasicSSL(); 
    4950 
    5051  public void perform(Map<String,String> check, 
    5152                      Map<String,String> config, 
    5253                      ResmonResult rr) { 
     54    String dsn = config.remove("dsn"); 
     55    if (dsn != null) { 
     56      String[] split = dsn.split("[ ]+"); 
     57      for (String s : split) { 
     58        String[] kv = s.split("="); 
     59        if (kv[0] != null && 2 == kv.length && kv[1] != null) { 
     60          if (kv[0].equals("dbname")) { 
     61            kv[0] = "database"; 
     62          } 
     63          config.put(kv[0],kv[1]); 
     64        } 
     65      } 
     66    } 
    5367    String database = config.remove("database"); 
    5468    String username = config.remove("user"); 
    5569    String password = config.remove("password"); 
    56     String port = config.remove("port"); 
     70    String port     = config.remove("port"); 
    5771    if(port == null) port = defaultPort(); 
     72 
    5873    String sql = config.remove("sql"); 
    5974    String url = jdbcConnectUrl(check.get("target_ip"), port, database); 
     
    6176    props.setProperty("user", username == null ? "" : username); 
    6277    props.setProperty("password", password == null ? "" : password); 
     78    if (config.containsKey("sslmode")) { 
     79      String sslmode = config.remove("sslmode"); 
     80      if (sslmode != null && ! sslmode.equals("disable")) { 
     81        Map<String,String> sslprops = setupBasicSSL(); 
     82        Set<Map.Entry<String,String>> set; 
     83        set = sslprops.entrySet(); 
     84        if (set != null) { 
     85          Iterator<Map.Entry<String,String>> i = set.iterator(); 
     86          while(i.hasNext()) { 
     87            Map.Entry<String,String> e = i.next(); 
     88            props.setProperty(e.getKey(), e.getValue()); 
     89          } 
     90        } 
     91      } 
     92    } 
    6393    Set<Map.Entry<String,String>> set; 
    6494    set = config.entrySet(); 
     
    74104      } 
    75105    } 
     106 
    76107    sql = JezebelTools.interpolate(sql, check, config); 
    77108 
  • src/java/com/omniti/jezebel/check/mysql.java

    r92fd1d9 rad037de  
    3232 
    3333package com.omniti.jezebel.check; 
     34import java.util.Map; 
     35import java.util.HashMap; 
    3436import com.omniti.jezebel.check.JDBC; 
    3537import com.omniti.jezebel.JezebelCheck; 
     
    4143    return "jdbc:mysql://" + host + ":" + port + "/" + db; 
    4244  } 
     45  protected Map<String,String> setupBasicSSL() { 
     46    HashMap<String,String> props = new HashMap<String,String>(); 
     47    props.put("useSSL", "true"); 
     48    props.put("verifyServerCertificate", "false"); 
     49    return props; 
     50  } 
    4351} 
  • src/java/com/omniti/jezebel/check/oracle.java

    r92fd1d9 rad037de  
    3232 
    3333package com.omniti.jezebel.check; 
     34import java.util.Map; 
     35import java.util.HashMap; 
    3436import com.omniti.jezebel.check.JDBC; 
    3537import com.omniti.jezebel.JezebelCheck; 
     
    4143    return "jdbc:oracle:thin:@" + host + ":" + port + ":" + db; 
    4244  } 
     45  protected Map<String,String> setupBasicSSL() { 
     46    HashMap<String,String> props = new HashMap<String,String>(); 
     47    props.put("oracle.net.ssl_cipher_suites", "(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5,SSL_DH_anon_WITH_DES_CBC_SHA)"); 
     48    return props; 
     49  } 
    4350} 
  • src/java/com/omniti/jezebel/check/postgres.java

    r92fd1d9 rad037de  
    3232 
    3333package com.omniti.jezebel.check; 
     34import java.util.Map; 
     35import java.util.HashMap; 
    3436import com.omniti.jezebel.check.JDBC; 
    3537import com.omniti.jezebel.JezebelCheck; 
     
    4143    return "jdbc:postgresql://" + host + ":" + port + "/" + db; 
    4244  } 
     45  protected Map<String,String> setupBasicSSL() { 
     46    HashMap<String,String> props = new HashMap<String,String>(); 
     47    props.put("ssl", "true"); 
     48    props.put("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); 
     49    return props; 
     50  } 
    4351} 
  • src/java/com/omniti/jezebel/check/sqlserver.java

    r92fd1d9 rad037de  
    3232 
    3333package com.omniti.jezebel.check; 
     34import java.util.Map; 
     35import java.util.HashMap; 
    3436import com.omniti.jezebel.check.JDBC; 
    3537import com.omniti.jezebel.JezebelCheck; 
     
    4143    return "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + db; 
    4244  } 
     45  protected Map<String,String> setupBasicSSL() { 
     46    HashMap<String,String> props = new HashMap<String,String>(); 
     47    props.put("encrypt", "true"); 
     48    props.put("trustServerCertificate", "true"); 
     49    return props; 
     50  } 
    4351}