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