pssht  latest
SSH server library written in PHP
None.php
1 <?php
2 
3 /*
4 * This file is part of pssht.
5 *
6 * (c) François Poirotte <clicky@erebot.net>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 
13 
15 
22 class None implements AuthenticationInterface
23 {
24  public static function getName()
25  {
26  return 'none';
27  }
28 
29  public function check(
30  \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base $message,
31  \fpoirotte\Pssht\Transport $transport,
32  array &$context
33  ) {
34  if (!($message instanceof \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\None)) {
35  throw new \InvalidArgumentException();
36  }
37 
38  return self::CHECK_OK;
39  }
40 
41  public function authenticate(
42  \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base $message,
43  \fpoirotte\Pssht\Transport $transport,
44  array &$context
45  ) {
46  if (!($message instanceof \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\None)) {
47  throw new \InvalidArgumentException();
48  }
49 
50  $logging = \Plop\Plop::getInstance();
51  $reverse = gethostbyaddr($transport->getAddress());
52  $logging->info(
53  'Rejected anonymous connection from remote host ' .
54  '"%(reverse)s" (%(address)s) to "%(luser)s": ' .
55  'anonymous login is not permitted',
56  array(
57  'luser' => escape($message->getUserName()),
58  'reverse' => $reverse,
59  'address' => $transport->getAddress(),
60  )
61  );
62  return self::AUTH_REJECT;
63  }
64 }
check(\fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base $message,\fpoirotte\Pssht\Transport $transport, array &$context)
Definition: None.php:29
authenticate(\fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base $message,\fpoirotte\Pssht\Transport $transport, array &$context)
Definition: None.php:41
static getName()
Return the name of the algorithm.
Definition: None.php:24