protected function getUsersPassword()
{
// load the application context
$application = RequestHandler::getApplicationContext();
/** @var \AppserverIo\Appserver\Core\Api\Node\DatabaseNode $databaseNode */
$databaseNode = $application->getNamingDirectory()->search($this->lookupName)->getDatabase();
// prepare the connection parameters and create the DBAL connection
$connection = DriverManager::getConnection(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode));
// try to load the principal's credential from the database
$statement = $connection->prepare($this->principalsQuery);
$statement->bindParam(1, $this->getUsername());
$statement->execute();
// close the PDO connection
if ($connection != null) {
try {
$connection->close();
} catch (\Exception $e) {
$application->getNamingDirectory()->search(NamingDirectoryKeys::SYSTEM_LOGGER)->error($e->__toString());
}
}
// query whether or not we've a password found or not
if ($row = $statement->fetch(\PDO::FETCH_NUM)) {
return new String($row[0]);
} else {
throw new LoginException('No matching username found in principals');
}
}