diff --git a/core/src/com/cloud/user/UserAccountVO.java b/core/src/com/cloud/user/UserAccountVO.java index 69f4cb747fd..2ea74e870ae 100644 --- a/core/src/com/cloud/user/UserAccountVO.java +++ b/core/src/com/cloud/user/UserAccountVO.java @@ -44,7 +44,7 @@ public class UserAccountVO implements UserAccount { @Column(name="username") private String username = null; - @Column(name="password", encryptable=true) + @Column(name="password") private String password = null; @Column(name="firstname") @@ -65,7 +65,7 @@ public class UserAccountVO implements UserAccount { @Column(name="api_key") private String apiKey = null; - @Column(name="secret_key") + @Column(name="secret_key", encryptable=true) private String secretKey = null; @Column(name=GenericDao.CREATED_COLUMN) diff --git a/core/src/com/cloud/user/UserVO.java b/core/src/com/cloud/user/UserVO.java index c781f19350e..a3ab4595b7d 100644 --- a/core/src/com/cloud/user/UserVO.java +++ b/core/src/com/cloud/user/UserVO.java @@ -52,7 +52,7 @@ public class UserVO implements User, Identity { @Column(name = "username") private String username = null; - @Column(name = "password", encryptable=true) + @Column(name = "password") private String password = null; @Column(name = "firstname") @@ -71,7 +71,7 @@ public class UserVO implements User, Identity { @Enumerated(value=EnumType.STRING) private State state; - @Column(name = "api_key", encryptable=true) + @Column(name = "api_key") private String apiKey = null; @Column(name = "secret_key", encryptable=true) diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 3055739e60d..f2c06274850 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -347,7 +347,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { // now insert the user insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created) " + - "VALUES (" + id + ",'" + username + "','" + DBEncryptionUtil.encrypt(sb.toString()) + "', 2, '" + firstname + "','" + lastname + "',now())"; + "VALUES (" + id + ",'" + username + "','" + sb.toString() + "', 2, '" + firstname + "','" + lastname + "',now())"; txn = Transaction.currentTxn(); diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java index 248ac10a3f2..f6bf61b32a5 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -134,7 +134,7 @@ public class Upgrade2214to30 implements DbUpgrade { } catch (SQLException e) { throw new CloudRuntimeException("Unable encrypt host_details values"); } catch (UnsupportedEncodingException e) { - throw new CloudRuntimeException("Unable encrypt configuration values"); + throw new CloudRuntimeException("Unable encrypt host_details values"); } finally { try { if (rs != null) { @@ -170,7 +170,7 @@ public class Upgrade2214to30 implements DbUpgrade { } catch (SQLException e) { throw new CloudRuntimeException("Unable encrypt vm_instance vnc_password"); } catch (UnsupportedEncodingException e) { - throw new CloudRuntimeException("Unable encrypt configuration values"); + throw new CloudRuntimeException("Unable encrypt vm_instance vnc_password"); } finally { try { if (rs != null) { @@ -189,39 +189,25 @@ public class Upgrade2214to30 implements DbUpgrade { PreparedStatement pstmt = null; ResultSet rs = null; try { - pstmt = conn.prepareStatement("select id, password, api_key, secret_key from user"); + pstmt = conn.prepareStatement("select id, secret_key from user"); rs = pstmt.executeQuery(); while (rs.next()) { long id = rs.getLong(1); - String password = rs.getString(2); - String encryptedPassword = DBEncryptionUtil.encrypt(password); - String apiKey = rs.getString(3); - String encryptedApiKey = DBEncryptionUtil.encrypt(apiKey); - String secretKey = rs.getString(4); + String secretKey = rs.getString(2); String encryptedSecretKey = DBEncryptionUtil.encrypt(secretKey); - pstmt = conn.prepareStatement("update user set password=?, api_key=?, secret_key=? where id=?"); - if(encryptedPassword == null){ + pstmt = conn.prepareStatement("update user set secret_key=? where id=?"); + if(encryptedSecretKey == null){ pstmt.setNull(1, Types.VARCHAR); } else { - pstmt.setBytes(1, encryptedPassword.getBytes("UTF-8")); + pstmt.setBytes(1, encryptedSecretKey.getBytes("UTF-8")); } - if(encryptedApiKey == null){ - pstmt.setNull(2, Types.VARCHAR); - } else { - pstmt.setBytes(2, encryptedApiKey.getBytes("UTF-8")); - } - if(encryptedSecretKey == null){ - pstmt.setNull(3, Types.VARCHAR); - } else { - pstmt.setBytes(3, encryptedSecretKey.getBytes("UTF-8")); - } - pstmt.setLong(4, id); + pstmt.setLong(2, id); pstmt.executeUpdate(); } } catch (SQLException e) { - throw new CloudRuntimeException("Unable encrypt user credentials"); + throw new CloudRuntimeException("Unable encrypt user secret key"); } catch (UnsupportedEncodingException e) { - throw new CloudRuntimeException("Unable encrypt configuration values"); + throw new CloudRuntimeException("Unable encrypt user secret key"); } finally { try { if (rs != null) { diff --git a/server/src/com/cloud/user/dao/AccountDaoImpl.java b/server/src/com/cloud/user/dao/AccountDaoImpl.java index 7af8945d85c..6f7c50ba63e 100755 --- a/server/src/com/cloud/user/dao/AccountDaoImpl.java +++ b/server/src/com/cloud/user/dao/AccountDaoImpl.java @@ -112,7 +112,7 @@ public class AccountDaoImpl extends GenericDaoBase implements A try { String sql = FIND_USER_ACCOUNT_BY_API_KEY; pstmt = txn.prepareAutoCloseStatement(sql); - pstmt.setString(1, DBEncryptionUtil.encrypt(apiKey)); + pstmt.setString(1, apiKey); ResultSet rs = pstmt.executeQuery(); // TODO: make sure we don't have more than 1 result? ApiKey had better be unique if (rs.next()) {