diff --git a/src/META-INF/classes/AppserverIo/Apps/Example/Services/SchemaProcessor.php b/src/META-INF/classes/AppserverIo/Apps/Example/Services/SchemaProcessor.php
index 9d6fe38..8edd88d 100755
--- a/src/META-INF/classes/AppserverIo/Apps/Example/Services/SchemaProcessor.php
+++ b/src/META-INF/classes/AppserverIo/Apps/Example/Services/SchemaProcessor.php
@@ -72,19 +72,26 @@ class SchemaProcessor extends AbstractPersistenceProcessor implements SchemaProc
* @var array
*/
protected $users = array(
- array('appserver', 'appserver.i0', array('Customer')),
- array('appserver_01', 'appserver.i0', array('Customer')),
- array('appserver_02', 'appserver.i0', array('Customer')),
- array('appserver_03', 'appserver.i0', array('Customer')),
- array('appserver_04', 'appserver.i0', array('Customer')),
- array('appserver_05', 'appserver.i0', array('Customer')),
- array('appserver_06', 'appserver.i0', array('Customer')),
- array('appserver_07', 'appserver.i0', array('Customer')),
- array('appserver_08', 'appserver.i0', array('Customer')),
- array('appserver_09', 'appserver.i0', array('Customer')),
+ array('appserver', 'appserver.i0', 'salt', array('Customer')),
+ array('appserver_01', 'appserver.i0', 'salt01', array('Customer')),
+ array('appserver_02', 'appserver.i0', 'salt02', array('Customer')),
+ array('appserver_03', 'appserver.i0', 'salt03', array('Customer')),
+ array('appserver_04', 'appserver.i0', 'salt04', array('Customer')),
+ array('appserver_05', 'appserver.i0', 'salt05', array('Customer')),
+ array('appserver_06', 'appserver.i0', 'salt06', array('Customer')),
+ array('appserver_07', 'appserver.i0', 'salt07', array('Customer')),
+ array('appserver_08', 'appserver.i0', 'salt08', array('Customer')),
+ array('appserver_09', 'appserver.i0', 'salt09', array('Customer')),
array('guest', 'appserver.i0', array('Guest'))
);
+ /**
+ * The hash algorithm to hash the passwords with
+ *
+ * @var string
+ */
+ protected $hashAlgorithm;
+
/**
* Example method that should be invoked after constructor.
*
@@ -96,6 +103,7 @@ public function initialize()
$this->getSystemLogger()->info(
sprintf('%s has successfully been invoked by @PostConstruct annotation', __METHOD__)
);
+ $this->hashAlgorithm = 'sha512';
}
/**
@@ -232,7 +240,7 @@ public function createDefaultCredentials()
// create the default credentials
foreach ($this->users as $userData) {
// extract the user data
- list ($username, $password, $roleNames) = $userData;
+ list ($username, $password, $salt, $roleNames) = $userData;
// query whether or not, the user has already been created
if ($repository->findOneByUsername($username)) {
@@ -244,7 +252,8 @@ public function createDefaultCredentials()
$user->setEmail(sprintf('%s@appserver.io', $username));
$user->setUsername($username);
$user->setUserLocale('en_US');
- $user->setPassword(md5($password));
+ $user->setPassword(hash($this->hashAlgorithm, $salt . $password));
+ $user->setSalt($salt);
$user->setEnabled(true);
$user->setRate(1000);
$user->setContractedHours(160);
diff --git a/src/META-INF/context.xml b/src/META-INF/context.xml
index a9d5120..64669ff 100644
--- a/src/META-INF/context.xml
+++ b/src/META-INF/context.xml
@@ -28,7 +28,8 @@
php:env/${container.name}/ds/appserver.io-example-application
select password from user where username = ?
select r.name, 'Roles' from role r inner join user p on r.userIdFk = p.userId where p.username = ?
- SHA-512
+ select salt from user where username = ?
+ sha512
hex
useFirstPass
@@ -40,4 +41,4 @@
-
\ No newline at end of file
+
diff --git a/src/common/classes/AppserverIo/Apps/Example/Entities/Impl/User.php b/src/common/classes/AppserverIo/Apps/Example/Entities/Impl/User.php
old mode 100755
new mode 100644
index e448e36..3dbd018
--- a/src/common/classes/AppserverIo/Apps/Example/Entities/Impl/User.php
+++ b/src/common/classes/AppserverIo/Apps/Example/Entities/Impl/User.php
@@ -75,6 +75,13 @@ class User
*/
protected $password;
+ /**
+ * @var string
+ *
+ * @ORM\Column(type="string")
+ */
+ protected $salt;
+
/**
* @var boolean
*
@@ -397,4 +404,26 @@ public function getRoles()
{
return $this->roles;
}
+
+ /**
+ * Returns the value of the class member salt.
+ *
+ * @return string Holds the value of the class member salt
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * Sets the value for the class member salt.
+ *
+ * @param string $salt Holds the value for the class member salt
+ *
+ * @return void
+ */
+ public function setSalt($salt)
+ {
+ $this->salt = $salt;
+ }
}