You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ap...@apache.org on 2014/01/09 11:20:06 UTC
[1/2] git commit: updated refs/heads/4.3 to 12f3568
Updated Branches:
refs/heads/4.3 7584cf906 -> 12f3568e9
CLOUDSTACK-5790: decrypted ldap hostname and port during upgrade as they are not encrypted now.
Signed-off-by: Abhinandan Prateek <ap...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/12f3568e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/12f3568e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/12f3568e
Branch: refs/heads/4.3
Commit: 12f3568e97f27784568bed9dd61260d444b9ef14
Parents: dfabe23
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Wed Jan 8 18:12:55 2014 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Thu Jan 9 15:43:21 2014 +0530
----------------------------------------------------------------------
.../com/cloud/upgrade/dao/Upgrade421to430.java | 38 ++++++++++++++++++--
setup/db/db/schema-421to430.sql | 3 --
2 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12f3568e/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
index 471307a..268a27d 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
@@ -21,10 +21,11 @@ import java.io.File;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Properties;
+import java.sql.Types;
-import com.cloud.utils.db.DbProperties;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import com.cloud.utils.crypt.DBEncryptionUtil;
@@ -90,6 +91,39 @@ public class Upgrade421to430 implements DbUpgrade {
pstmt.setString(3, desc);
pstmt.executeUpdate();
}
+
+ /**
+ * if encrypted, decrypt the ldap hostname and port and then update as they are not encrypted now.
+ */
+ pstmt = conn.prepareStatement("SELECT conf.value FROM `cloud`.`configuration` conf WHERE conf.name='ldap.hostname'");
+ ResultSet resultSet = pstmt.executeQuery();
+ String hostname = null;
+ String port;
+ int portNumber = 0;
+ if (resultSet.next()) {
+ hostname = DBEncryptionUtil.decrypt(resultSet.getString(1));
+ }
+
+ pstmt = conn.prepareStatement("SELECT conf.value FROM `cloud`.`configuration` conf WHERE conf.name='ldap.port'");
+ resultSet = pstmt.executeQuery();
+ if (resultSet.next()) {
+ port = DBEncryptionUtil.decrypt(resultSet.getString(1));
+ if (StringUtils.isNotBlank(port)) {
+ portNumber = Integer.valueOf(port);
+ }
+ }
+
+ if (StringUtils.isNotBlank(hostname)) {
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`ldap_configuration`(hostname, port) VALUES(?,?)");
+ pstmt.setString(1, hostname);
+ if (portNumber != 0) {
+ pstmt.setInt(2, portNumber);
+ } else {
+ pstmt.setNull(2, Types.INTEGER);
+ }
+ pstmt.executeUpdate();
+ }
+
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to insert ldap configuration values ", e);
} catch (UnsupportedEncodingException e) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12f3568e/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index d1d8792..c1f9780 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -616,9 +616,6 @@ CREATE TABLE `cloud`.`ldap_configuration` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-INSERT INTO `cloud`.`ldap_configuration`(hostname) SELECT conf.value FROM `cloud`.`configuration` conf WHERE conf.name='ldap.hostname' ;
-UPDATE `cloud`.`ldap_configuration` SET port=(SELECT conf.value FROM `cloud`.`configuration` conf WHERE conf.name='ldap.port') WHERE hostname = (SELECT conf.value FROM `cloud` .`configuration` conf WHERE conf.name='ldap.hostname');
-
UPDATE `cloud`.`volumes` SET display_volume=1 where id>0;
create table `cloud`.`monitoring_services` (
[2/2] git commit: updated refs/heads/4.3 to 12f3568
Posted by ap...@apache.org.
Revert "CLOUDSTACK-5435 enabled encryption for ldap params"
This reverts commit 24392c15f561fa07fd5f707bbfa6910d880c3a3b.
Signed-off-by: Abhinandan Prateek <ap...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dfabe233
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dfabe233
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dfabe233
Branch: refs/heads/4.3
Commit: dfabe2334b5a16c58809164feec66cd5b3110a52
Parents: 7584cf9
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Wed Jan 8 14:16:56 2014 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Thu Jan 9 15:43:21 2014 +0530
----------------------------------------------------------------------
.../apache/cloudstack/api/command/LDAPConfigCmd.java | 6 +++---
.../api/response/LdapConfigurationResponse.java | 8 ++++----
.../apache/cloudstack/ldap/LdapConfigurationVO.java | 14 +++++---------
.../org/apache/cloudstack/ldap/LdapManagerImpl.java | 4 ++--
setup/db/db/schema-421to430.sql | 2 +-
5 files changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfabe233/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
index 53d3877..3faf8b7 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
@@ -188,7 +188,7 @@ public class LDAPConfigCmd extends BaseCmd {
} else {
boolean result = this.updateLDAP();
if (result) {
- LDAPConfigResponse lr = this.createLDAPConfigResponse(getHostname(), getPort().toString(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
+ LDAPConfigResponse lr = this.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
lr.setResponseName(getCommandName());
this.setResponseObject(lr);
}
@@ -196,10 +196,10 @@ public class LDAPConfigCmd extends BaseCmd {
}
- private LDAPConfigResponse createLDAPConfigResponse(String hostname, String port, Boolean useSSL, String queryFilter, String searchBase, String bindDN) {
+ private LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String searchBase, String bindDN) {
LDAPConfigResponse lr = new LDAPConfigResponse();
lr.setHostname(hostname);
- lr.setPort(port);
+ lr.setPort(port.toString());
lr.setUseSSL(useSSL.toString());
lr.setQueryFilter(queryFilter);
lr.setBindDN(bindDN);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfabe233/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/response/LdapConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/response/LdapConfigurationResponse.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/response/LdapConfigurationResponse.java
index caabbe7..39d5bae 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/response/LdapConfigurationResponse.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/response/LdapConfigurationResponse.java
@@ -28,7 +28,7 @@ public class LdapConfigurationResponse extends BaseResponse {
@SerializedName("port")
@Param(description = "port")
- private String port;
+ private int port;
public LdapConfigurationResponse() {
super();
@@ -39,7 +39,7 @@ public class LdapConfigurationResponse extends BaseResponse {
this.hostname = hostname;
}
- public LdapConfigurationResponse(final String hostname, final String port) {
+ public LdapConfigurationResponse(final String hostname, final int port) {
this.hostname = hostname;
this.port = port;
}
@@ -48,7 +48,7 @@ public class LdapConfigurationResponse extends BaseResponse {
return hostname;
}
- public String getPort() {
+ public int getPort() {
return port;
}
@@ -56,7 +56,7 @@ public class LdapConfigurationResponse extends BaseResponse {
this.hostname = hostname;
}
- public void setPort(final String port) {
+ public void setPort(final int port) {
this.port = port;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfabe233/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapConfigurationVO.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapConfigurationVO.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapConfigurationVO.java
index 2fb6332..98e42f8 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapConfigurationVO.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapConfigurationVO.java
@@ -23,30 +23,26 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
-import com.cloud.utils.db.Encrypt;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name = "ldap_configuration")
public class LdapConfigurationVO implements InternalIdentity {
+ @Column(name = "hostname")
+ private String hostname;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
- @Encrypt
- @Column(name = "hostname")
- private String hostname;
-
- @Encrypt
@Column(name = "port")
- private String port;
+ private int port;
public LdapConfigurationVO() {
}
- public LdapConfigurationVO(final String hostname, final String port) {
+ public LdapConfigurationVO(final String hostname, final int port) {
this.hostname = hostname;
this.port = port;
}
@@ -60,7 +56,7 @@ public class LdapConfigurationVO implements InternalIdentity {
return id;
}
- public String getPort() {
+ public int getPort() {
return port;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfabe233/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
index c2158f4..578ebce 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
@@ -67,10 +67,10 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
try {
final String providerUrl = "ldap://" + hostname + ":" + port;
_ldapContextFactory.createBindContext(providerUrl);
- configuration = new LdapConfigurationVO(hostname, Integer.toString(port));
+ configuration = new LdapConfigurationVO(hostname, port);
_ldapConfigurationDao.persist(configuration);
s_logger.info("Added new ldap server with hostname: " + hostname);
- return new LdapConfigurationResponse(hostname, Integer.toString(port));
+ return new LdapConfigurationResponse(hostname, port);
} catch (final NamingException e) {
throw new InvalidParameterValueException("Unable to bind to the given LDAP server");
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dfabe233/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 06e6a27..d1d8792 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -612,7 +612,7 @@ INSERT INTO `cloud`.`configuration`(category, instance, component, name, value,
CREATE TABLE `cloud`.`ldap_configuration` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`hostname` varchar(255) NOT NULL COMMENT 'the hostname of the ldap server',
- `port` varchar(255) COMMENT 'port that the ldap server is listening on',
+ `port` int(10) COMMENT 'port that the ldap server is listening on',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;