xref: /plugin/pureldap/vendor/freedsx/sasl/src/FreeDSx/Sasl/Mechanism/CramMD5Mechanism.php (revision 0b3fd2d31e4d1997548a8fbc53fa771027c4a47f)
1*0b3fd2d3SAndreas Gohr<?php
2*0b3fd2d3SAndreas Gohr
3*0b3fd2d3SAndreas Gohr/**
4*0b3fd2d3SAndreas Gohr * This file is part of the FreeDSx SASL package.
5*0b3fd2d3SAndreas Gohr *
6*0b3fd2d3SAndreas Gohr * (c) Chad Sikorra <Chad.Sikorra@gmail.com>
7*0b3fd2d3SAndreas Gohr *
8*0b3fd2d3SAndreas Gohr * For the full copyright and license information, please view the LICENSE
9*0b3fd2d3SAndreas Gohr * file that was distributed with this source code.
10*0b3fd2d3SAndreas Gohr */
11*0b3fd2d3SAndreas Gohr
12*0b3fd2d3SAndreas Gohrnamespace FreeDSx\Sasl\Mechanism;
13*0b3fd2d3SAndreas Gohr
14*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\Challenge\ChallengeInterface;
15*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\Challenge\CramMD5Challenge;
16*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\Exception\SaslException;
17*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\Security\SecurityLayerInterface;
18*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\SecurityStrength;
19*0b3fd2d3SAndreas Gohr
20*0b3fd2d3SAndreas Gohr/**
21*0b3fd2d3SAndreas Gohr * The CRAM-MD5 mechanism.
22*0b3fd2d3SAndreas Gohr *
23*0b3fd2d3SAndreas Gohr * @author Chad Sikorra <Chad.Sikorra@gmail.com>
24*0b3fd2d3SAndreas Gohr */
25*0b3fd2d3SAndreas Gohrclass CramMD5Mechanism implements MechanismInterface
26*0b3fd2d3SAndreas Gohr{
27*0b3fd2d3SAndreas Gohr    public const NAME = 'CRAM-MD5';
28*0b3fd2d3SAndreas Gohr
29*0b3fd2d3SAndreas Gohr    /**
30*0b3fd2d3SAndreas Gohr     * {@inheritDoc}
31*0b3fd2d3SAndreas Gohr     */
32*0b3fd2d3SAndreas Gohr    public function getName(): string
33*0b3fd2d3SAndreas Gohr    {
34*0b3fd2d3SAndreas Gohr        return self::NAME;
35*0b3fd2d3SAndreas Gohr    }
36*0b3fd2d3SAndreas Gohr
37*0b3fd2d3SAndreas Gohr    /**
38*0b3fd2d3SAndreas Gohr     * {@inheritDoc}
39*0b3fd2d3SAndreas Gohr     */
40*0b3fd2d3SAndreas Gohr    public function challenge(): ChallengeInterface
41*0b3fd2d3SAndreas Gohr    {
42*0b3fd2d3SAndreas Gohr        return new CramMD5Challenge();
43*0b3fd2d3SAndreas Gohr    }
44*0b3fd2d3SAndreas Gohr
45*0b3fd2d3SAndreas Gohr    /**
46*0b3fd2d3SAndreas Gohr     * {@inheritDoc}
47*0b3fd2d3SAndreas Gohr     */
48*0b3fd2d3SAndreas Gohr    public function securityStrength(): SecurityStrength
49*0b3fd2d3SAndreas Gohr    {
50*0b3fd2d3SAndreas Gohr        return new SecurityStrength(
51*0b3fd2d3SAndreas Gohr            false,
52*0b3fd2d3SAndreas Gohr            false,
53*0b3fd2d3SAndreas Gohr            true,
54*0b3fd2d3SAndreas Gohr            false,
55*0b3fd2d3SAndreas Gohr            0
56*0b3fd2d3SAndreas Gohr        );
57*0b3fd2d3SAndreas Gohr    }
58*0b3fd2d3SAndreas Gohr
59*0b3fd2d3SAndreas Gohr    /**
60*0b3fd2d3SAndreas Gohr     * {@inheritDoc}
61*0b3fd2d3SAndreas Gohr     */
62*0b3fd2d3SAndreas Gohr    public function securityLayer(): SecurityLayerInterface
63*0b3fd2d3SAndreas Gohr    {
64*0b3fd2d3SAndreas Gohr        throw new SaslException('CRAM-MD5 does not support a security layer.');
65*0b3fd2d3SAndreas Gohr    }
66*0b3fd2d3SAndreas Gohr}
67