1<?php
2/**
3 * This file is part of the FreeDSx LDAP package.
4 *
5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11namespace FreeDSx\Ldap\Server\RequestHandler;
12
13use FreeDSx\Ldap\Entry\Entries;
14use FreeDSx\Ldap\Exception\OperationException;
15use FreeDSx\Ldap\Operation\Request\AddRequest;
16use FreeDSx\Ldap\Operation\Request\CompareRequest;
17use FreeDSx\Ldap\Operation\Request\DeleteRequest;
18use FreeDSx\Ldap\Operation\Request\ExtendedRequest;
19use FreeDSx\Ldap\Operation\Request\ModifyDnRequest;
20use FreeDSx\Ldap\Operation\Request\ModifyRequest;
21use FreeDSx\Ldap\Operation\Request\SearchRequest;
22use FreeDSx\Ldap\Server\RequestContext;
23
24/**
25 * This allows the LDAP server to run, but rejects everything. You can extend and selectively override specific request
26 * types to support what you want.
27 *
28 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
29 */
30class GenericRequestHandler implements RequestHandlerInterface
31{
32    /**
33     * {@inheritdoc}
34     */
35    public function add(RequestContext $context, AddRequest $add): void
36    {
37        throw new OperationException('The add operation is not supported.');
38    }
39
40    /**
41     * {@inheritdoc}
42     */
43    public function bind(string $username, string $password): bool
44    {
45        return false;
46    }
47
48    /**
49     * {@inheritdoc}
50     */
51    public function compare(RequestContext $context, CompareRequest $compare): bool
52    {
53        throw new OperationException('The compare operation is not supported.');
54    }
55
56    /**
57     * {@inheritdoc}
58     */
59    public function delete(RequestContext $context, DeleteRequest $delete): void
60    {
61        throw new OperationException('The delete operation is not supported.');
62    }
63
64    /**
65     * {@inheritdoc}
66     */
67    public function extended(RequestContext $context, ExtendedRequest $extended): void
68    {
69        throw new OperationException(sprintf('The extended operation %s is not supported.', $extended->getName()));
70    }
71
72    /**
73     * {@inheritdoc}
74     */
75    public function modify(RequestContext $context, ModifyRequest $modify): void
76    {
77        throw new OperationException('The modify operation is not supported.');
78    }
79
80    /**
81     * {@inheritdoc}
82     */
83    public function modifyDn(RequestContext $context, ModifyDnRequest $modifyDn): void
84    {
85        throw new OperationException('The modify dn operation is not supported.');
86    }
87
88    /**
89     * {@inheritdoc}
90     */
91    public function search(RequestContext $context, SearchRequest $search): Entries
92    {
93        throw new OperationException('The search operation is not supported.');
94    }
95}
96