KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > ldap > impl > LDAPServiceImpl


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  */

5
6 package org.exoplatform.services.ldap.impl;
7
8
9
10
11 import org.apache.commons.logging.Log;
12 import org.exoplatform.services.exception.ExoServiceException;
13 import org.exoplatform.services.ldap.LDAPService;
14 import org.exoplatform.services.log.LogService;
15
16 import netscape.ldap.*;
17
18
19 /**
20  * Created y the eXo platform team
21  * User: Daniel Summer
22  * Date: 25/5/2004
23  */

24 public class LDAPServiceImpl implements LDAPService {
25     
26     private LDAPConnection conn = new LDAPConnection();
27     private Log log_;
28
29     public LDAPServiceImpl(LogService logService) {
30         
31         this.log_ = logService.getLog("org.exoplatform.services.ldap");
32
33     }
34
35     public void connect(
36     java.lang.String JavaDoc host,
37     int port)
38     throws ExoServiceException {
39         try {
40             conn.connect(host, port);
41         } catch (LDAPException e) {
42             throw new ExoServiceException(e);
43         }
44     }
45
46     public void authenticate(
47     java.lang.String JavaDoc dn,
48     java.lang.String JavaDoc passwd)
49     throws ExoServiceException {
50         try {
51             conn.authenticate(dn, passwd);
52         } catch (LDAPException e) {
53             throw new ExoServiceException(e);
54         }
55     }
56
57
58     public void add(LDAPEntry entry) throws ExoServiceException {
59         
60         try {
61             conn.add(entry);
62         } catch (LDAPException e) {
63             throw new ExoServiceException(e);
64         }
65     }
66
67
68     public void delete(String JavaDoc DN) throws ExoServiceException {
69         
70         try {
71             conn.delete(DN);
72         } catch (LDAPException e) {
73             throw new ExoServiceException(e);
74         }
75
76     }
77
78
79     public void modify(String JavaDoc DN, LDAPModification mod)
80         throws ExoServiceException {
81         
82         try {
83             conn.modify(DN, mod);
84         } catch (LDAPException e) {
85             throw new ExoServiceException(e);
86         }
87     }
88
89
90     public LDAPEntry read(String JavaDoc DN) throws ExoServiceException {
91         
92         try {
93             return conn.read(DN);
94         } catch (LDAPException e) {
95             throw new ExoServiceException(e);
96         }
97     }
98
99
100     public void rename(String JavaDoc DN, String JavaDoc newRDN, boolean deleteOldRDN)
101         throws ExoServiceException {
102         
103         try {
104             conn.rename(DN, newRDN, deleteOldRDN);
105         } catch (LDAPException e) {
106             throw new ExoServiceException(e);
107         }
108     }
109
110
111     public LDAPSearchResults search(
112         String JavaDoc base,
113         int scope,
114         String JavaDoc filter,
115         String JavaDoc[] attrs,
116         boolean attrsOnly)
117         throws ExoServiceException {
118         
119         try {
120             return conn.search(base, scope, filter, attrs, attrsOnly);
121         } catch (LDAPException e) {
122             throw new ExoServiceException(e);
123         }
124     }
125     
126     public void disconnect()
127         throws ExoServiceException {
128         
129         try {
130             conn.disconnect();
131         } catch (LDAPException e) {
132             throw new ExoServiceException(e);
133         }
134     }
135
136
137
138     public void modify(String JavaDoc DN, LDAPModification[] mods)
139         throws ExoServiceException {
140             try {
141                 conn.modify(DN, mods);
142             } catch (LDAPException e) {
143                 throw new ExoServiceException(e);
144             }
145
146     }
147     
148     public void modify(String JavaDoc DN, LDAPModificationSet mods)
149         throws ExoServiceException {
150             try {
151                 conn.modify(DN, mods);
152             } catch (LDAPException e) {
153                 throw new ExoServiceException(e);
154             }
155
156     }
157
158 }
159
Popular Tags