KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > auth > DefaultAuthenticator


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.auth;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.apache.juddi.error.RegistryException;
21
22 /**
23  * This is a simple implementation of jUDDI's Authenticator interface.
24  *
25  * @author Steve Viens (sviens@apache.org)
26  */

27 public class DefaultAuthenticator implements Authenticator
28 {
29   // private reference to the jUDDI logger
30
private static Log log = LogFactory.getLog(DefaultAuthenticator.class);
31
32   /**
33    *
34    */

35   public DefaultAuthenticator()
36   {
37   }
38
39   /**
40    *
41    */

42   public String JavaDoc authenticate(String JavaDoc userID,String JavaDoc credential)
43     throws RegistryException
44   {
45     return userID;
46   }
47
48
49   /***************************************************************************/
50   /***************************** TEST DRIVER *********************************/
51   /***************************************************************************/
52
53
54   public static void main(String JavaDoc[] args)
55     throws Exception JavaDoc
56   {
57     Authenticator auth = new DefaultAuthenticator();
58
59     try {
60       System.out.print("anou_mana/password: ");
61       auth.authenticate("anou_mana","password");
62       System.out.println("successfully authenticated");
63     }
64     catch(Exception JavaDoc ex) {
65       System.out.println(ex.getMessage());
66     }
67
68     try {
69       System.out.print("anou_mana/badpass: ");
70       auth.authenticate("anou_mana","badpass");
71       System.out.println("successfully authenticated");
72     }
73     catch(Exception JavaDoc ex) {
74       System.out.println(ex.getMessage());
75     }
76
77     try {
78       System.out.print("bozo/clown: ");
79       auth.authenticate("bozo","clown");
80       System.out.println("successfully authenticated");
81     }
82     catch(Exception JavaDoc ex) {
83       System.out.println(ex.getMessage());
84     }
85
86     try {
87       System.out.print("sviens/password: ");
88       auth.authenticate("sviens","password");
89       System.out.println("successfully authenticated");
90     }
91     catch(Exception JavaDoc ex) {
92       System.out.println(ex.getMessage());
93     }
94   }
95 }
Popular Tags