KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > ra > userdatasource > DummyCustomUserDataSource


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.core.model.ra.userdatasource;
15
16 import java.util.ArrayList JavaDoc;
17 import java.util.Collection JavaDoc;
18 import java.util.Properties JavaDoc;
19
20 import org.apache.log4j.Logger;
21 import org.ejbca.core.model.SecConst;
22 import org.ejbca.core.model.log.Admin;
23 import org.ejbca.core.model.ra.UserDataVO;
24
25
26 /**
27  * This is an class used for testing and example purposes.
28  * I supposed to illustrat how to implement a custom userdata soruce to EJBCA.
29  *
30  *
31  * @version $Id: DummyCustomUserDataSource.java,v 1.1 2006/07/20 17:47:26 herrvendil Exp $
32  */

33 public class DummyCustomUserDataSource implements ICustomUserDataSource{
34             
35     private static Logger log = Logger.getLogger(DummyCustomUserDataSource.class);
36
37     /**
38      * Creates a new instance of DummyCustomUserDataSource
39      */

40     public DummyCustomUserDataSource() {}
41
42     /**
43      * @see org.ejbca.core.model.ca.publisher.ICustomPublisher#init(java.util.Properties)
44      */

45     public void init(Properties JavaDoc properties) {
46       // This method sets up the communication with the publisher
47

48       log.debug("Initializing DummyCustomUserDataSource");
49     }
50
51     /**
52      * A dummy fetch implementation that returns a UserDataVO if the searchstring "per" is given
53      * Othervise a empty collection is returned.
54      *
55      * @see org.ejbca.core.model.ra.userdatasource.BaseUserDataSource
56      */

57     public Collection JavaDoc fetch(Admin admin, String JavaDoc searchstring) throws UserDataSourceException {
58
59         ArrayList JavaDoc result = new ArrayList JavaDoc();
60         if(searchstring.equalsIgnoreCase("per")){
61             UserDataVO userDataVO = new UserDataVO("PER","CN=PER,C=SE",1,"RFC822NAME=per@test.com", "per@test.com",0,1,1,1,null,null,SecConst.TOKEN_SOFT_BROWSERGEN,0,null);
62             result.add(new UserDataSourceVO(userDataVO));
63         }
64         
65         return result;
66     }
67     
68     /**
69      * @see org.ejbca.core.model.ra.userdatasource.BaseUserDataSource
70      */

71     public void testConnection(Admin admin) throws UserDataSourceConnectionException {
72         log.debug("DummyCustomUserDataSource, Testing connection");
73     }
74
75     
76     protected void finalize() throws Throwable JavaDoc {
77         log.debug("DummyCustomUserDataSource, closing connection");
78         // This method closes the communication with the publisher.
79

80         super.finalize();
81     }
82
83
84     
85 }
86
Popular Tags