aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/ldap/LdapConstants.java
blob: a693954304ace23211883d75c0ae4c5f8856397e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.service.ldap;

import javax.naming.directory.*;

/**
 * Constants used by the LDAP service.
 *
 * @author Sebastien Mazy
 */
public interface LdapConstants
{
    /**
     * security methods used to connect to the remote host
     * and their default port
     */
    public static enum Encryption
    {
        /**
         * No encryption.
         */
        CLEAR(389, "ldap://"),

        /**
         * SSL encryption.
         */
        SSL(636, "ldaps://");

        private final int defaultPort;
        private final String protocolString;

        Encryption(int defaultPort, String protocolString)
        {
            this.defaultPort = defaultPort;
            this.protocolString = protocolString;
        }

        /**
         * Returns the default port for this security method.
         *
         * @return the default port for this security method.
         */
        public int defaultPort()
        {
            return this.defaultPort;
        }

        /**
         * Returns the protocol string for this security method.
         *
         * @return the protocol string
         */
        public String protocolString()
        {
            return this.protocolString;
        }

        /**
         * Returns default value for encryption.
         *
         * @return default value for encryption
         */
        public static Encryption defaultValue()
        {
            return CLEAR;
        }
    }

    /**
     * Authentication methods.
     */
    public static enum Auth
    {
        /**
         * No authentication.
         */
        NONE,

        /**
         * Authentication with login and password.
         */
        SIMPLE;

        /**
         * Returns default value for authentication.
         *
         * @return default value for authentication
         */
        public static Auth defaultValue()
        {
            return NONE;
        }
    }

    /**
     * search scope in the directory: one level, subtree
     */
    public static enum Scope
    {
        /**
         * Subtree search.
         */
        SUB(SearchControls.SUBTREE_SCOPE),

        /**
         * One level search.
         */
        ONE(SearchControls.ONELEVEL_SCOPE);

        private int constant;

        Scope(int constant)
        {
            this.constant = constant;
        }

        /**
         * Returns default value for scope.
         *
         * @return default value for scope
         */
        public static Scope defaultValue()
        {
            return SUB;
        }

        /**
         * Returns the matching constant field from SearchControls
         *
         * @return the matching constant field
         */
        public int getConstant()
        {
            return this.constant;
        }
    }

    /**
     * How long should we wait for the connection to establish?
     * (in ms)
     */
    public static final String LDAP_CONNECT_TIMEOUT = "5000";

    /**
     * How long should we wait for a LDAP response?
     * (in ms)
     */
    public static final String LDAP_READ_TIMEOUT = "60000";
}