KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > cert > LDAPCertStoreParameters


1 /*
2  * @(#)LDAPCertStoreParameters.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.security.cert;
9
10 /**
11  * Parameters used as input for the LDAP <code>CertStore</code> algorithm.
12  * <p>
13  * This class is used to provide necessary configuration parameters (server
14  * name and port number) to implementations of the LDAP <code>CertStore</code>
15  * algorithm.
16  * <p>
17  * <b>Concurrent Access</b>
18  * <p>
19  * Unless otherwise specified, the methods defined in this class are not
20  * thread-safe. Multiple threads that need to access a single
21  * object concurrently should synchronize amongst themselves and
22  * provide the necessary locking. Multiple threads each manipulating
23  * separate objects need not synchronize.
24  *
25  * @version 1.8 12/19/03
26  * @since 1.4
27  * @author Steve Hanna
28  * @see CertStore
29  */

30 public class LDAPCertStoreParameters implements CertStoreParameters JavaDoc {
31
32     private static final int LDAP_DEFAULT_PORT = 389;
33
34     /**
35      * the port number of the LDAP server
36      */

37     private int port;
38
39     /**
40      * the DNS name of the LDAP server
41      */

42     private String JavaDoc serverName;
43
44     /**
45      * Creates an instance of <code>LDAPCertStoreParameters</code> with the
46      * specified parameter values.
47      *
48      * @param serverName the DNS name of the LDAP server
49      * @param port the port number of the LDAP server
50      * @exception NullPointerException if <code>serverName</code> is
51      * <code>null</code>
52      */

53     public LDAPCertStoreParameters(String JavaDoc serverName, int port) {
54         if (serverName == null)
55             throw new NullPointerException JavaDoc();
56         this.serverName = serverName;
57         this.port = port;
58     }
59
60     /**
61      * Creates an instance of <code>LDAPCertStoreParameters</code> with the
62      * specified server name and a default port of 389.
63      *
64      * @param serverName the DNS name of the LDAP server
65      * @exception NullPointerException if <code>serverName</code> is
66      * <code>null</code>
67      */

68     public LDAPCertStoreParameters(String JavaDoc serverName) {
69     this(serverName, LDAP_DEFAULT_PORT);
70     }
71
72     /**
73      * Creates an instance of <code>LDAPCertStoreParameters</code> with the
74      * default parameter values (server name "localhost", port 389).
75      */

76     public LDAPCertStoreParameters() {
77         this("localhost", LDAP_DEFAULT_PORT);
78     }
79
80     /**
81      * Returns the DNS name of the LDAP server.
82      *
83      * @return the name (not <code>null</code>)
84      */

85     public String JavaDoc getServerName() {
86         return serverName;
87     }
88
89     /**
90      * Returns the port number of the LDAP server.
91      *
92      * @return the port number
93      */

94     public int getPort() {
95         return port;
96     }
97
98     /**
99      * Returns a copy of this object. Changes to the copy will not affect
100      * the original and vice versa.
101      * <p>
102      * Note: this method currently performs a shallow copy of the object
103      * (simply calls <code>Object.clone()</code>). This may be changed in a
104      * future revision to perform a deep copy if new parameters are added
105      * that should not be shared.
106      *
107      * @return the copy
108      */

109     public Object JavaDoc clone() {
110         try {
111             return super.clone();
112         } catch (CloneNotSupportedException JavaDoc e) {
113             /* Cannot happen */
114             throw new InternalError JavaDoc(e.toString());
115         }
116     }
117
118     /**
119      * Returns a formatted string describing the parameters.
120      *
121      * @return a formatted string describing the parameters
122      */

123     public String JavaDoc toString() {
124         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
125         sb.append("LDAPCertStoreParameters: [\n");
126
127         sb.append(" serverName: " + serverName + "\n");
128         sb.append(" port: " + port + "\n");
129         sb.append("]");
130         return sb.toString();
131     }
132 }
133
Popular Tags