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\PlainChallenge;
16use FreeDSx\Sasl\Exception\SaslException;
17use FreeDSx\Sasl\Security\SecurityLayerInterface;
18use FreeDSx\Sasl\SecurityStrength;
19
20/**
21 * The PLAIN mechanism.
22 *
23 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
24 */
25class PlainMechanism implements MechanismInterface
26{
27    public const NAME = 'PLAIN';
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 PlainChallenge();
43    }
44
45    /**
46     * {@inheritDoc}
47     */
48    public function securityStrength(): SecurityStrength
49    {
50        return new SecurityStrength(
51            false,
52            false,
53            true,
54            true,
55            0
56        );
57    }
58
59    /**
60     * {@inheritDoc}
61     */
62    public function securityLayer(): SecurityLayerInterface
63    {
64       throw new SaslException('The PLAIN mechanism does not support a security layer.');
65    }
66}
67