RealmWrapper::getConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * AppserverIo\Psr\Auth\RealmWrapper
5
*
6
* NOTICE OF LICENSE
7
*
8
* This source file is subject to the Open Software License (OSL 3.0)
9
* that is available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
* PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io-psr/auth
18
 * @link      http://www.appserver.io
19
*/
20
21
namespace AppserverIo\Psr\Auth;
22
23
use AppserverIo\Lang\String;
24
use AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface;
25
26
/**
27
 * Wrapper implementation for a object manager implementation.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2016 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/appserver-io-psr/auth
33
 * @link      http://www.appserver.io
34
 */
35
class RealmWrapper implements RealmInterface
36
{
37
38
    /**
39
     * The object manager instance to be wrapped.
40
     *
41
     * @var \AppserverIo\Psr\Auth\RealmInterface
42
     */
43
    protected $realm;
44
45
    /**
46
     * Injects the passed realm instance into this wrapper.
47
     *
48
     * @param \AppserverIo\Psr\Auth\RealmInterface $realm The realm instance used for initialization
49
     *
50
     * @return void
51
     */
52
    public function injectRealm(RealmInterface $realm)
53
    {
54
        $this->realm = $realm;
55
    }
56
57
    /**
58
     * Return's the realm instance.
59
     *
60
     * @return \AppserverIo\Psr\Auth\RealmInterface The realm instance
61
     */
62
    public function getRealm()
63
    {
64
        return $this->realm;
65
    }
66
67
    /**
68
     * Return's the name of the realm.
69
     *
70
     * @return string The realm's name
71
     */
72
    public function getName()
73
    {
74
        return $this->getRealm()->getName();
75
    }
76
77
    /**
78
     * Return's the realm's configuration.
79
     *
80
     * @return AppserverIo\Psr\Security\Auth\Login\SecurityDomainConfigurationInterface The realm's configuration
81
     */
82
    public function getConfiguration()
83
    {
84
        return $this->getRealm()->getConfiguration();
85
    }
86
87
    /**
88
     * Return's the exception stack.
89
     *
90
     * @return \AppserverIo\Collections\ArrayList The exception stack
91
     */
92
    public function getExceptionStack()
93
    {
94
        return $this->getRealm()->getExceptionStack();
95
    }
96
97
    /**
98
     * Tries to authenticate the user with the passed username and password.
99
     *
100
     * @param \AppserverIo\Lang\String $username The name of the user to authenticate
101
     * @param \AppserverIo\Lang\String $password The password used for authentication
102
     *
103
     * @return \AppserverIo\Security\PrincipalInterface|null The authenticated user principal
104
     */
105
    public function authenticate(String $username, String $password)
106
    {
107
        return $this->getRealm()->authenticate($username, $password);
108
    }
109
110
    /**
111
     * Tries to authenticate the user with the passed username and callback handler.
112
     *
113
     * @param \AppserverIo\Lang\String                                         $username        The name of the user to authenticate
114
     * @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler used to load the credentials
115
     *
116
     * @return \AppserverIo\Security\PrincipalInterface|null The authenticated user principal
117
     */
118
    public function authenticateByUsernameAndCallbackHandler(String $username, CallbackHandlerInterface $callbackHandler)
119
    {
120
        return $this->getRealm()->authenticateByUsernameAndCallbackHandler($username, $callbackHandler);
121
    }
122
}
123