View Javadoc

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.juddi.error.RegistryException;
19  
20  /***
21   * This is a simple implementation of jUDDI's Authenticator interface.
22   *
23   * @author Steve Viens (sviens@apache.org)
24   */
25  public class DefaultAuthenticator implements Authenticator
26  {
27    /***
28     *
29     */
30    public DefaultAuthenticator()
31    {
32    }
33  
34    /***
35     *
36     */
37    public String authenticate(String userID,String credential)
38      throws RegistryException
39    {
40      return userID;
41    }
42  
43  
44    /****************************************************************************/
45    /****************************** TEST DRIVER *********************************/
46    /****************************************************************************/
47  
48  
49    public static void main(String[] args)
50      throws Exception
51    {
52      Authenticator auth = new DefaultAuthenticator();
53  
54      try {
55        System.out.print("anou_mana/password: ");
56        auth.authenticate("anou_mana","password");
57        System.out.println("successfully authenticated");
58      }
59      catch(Exception ex) {
60        System.out.println(ex.getMessage());
61      }
62  
63      try {
64        System.out.print("anou_mana/badpass: ");
65        auth.authenticate("anou_mana","badpass");
66        System.out.println("successfully authenticated");
67      }
68      catch(Exception ex) {
69        System.out.println(ex.getMessage());
70      }
71  
72      try {
73        System.out.print("bozo/clown: ");
74        auth.authenticate("bozo","clown");
75        System.out.println("successfully authenticated");
76      }
77      catch(Exception ex) {
78        System.out.println(ex.getMessage());
79      }
80  
81      try {
82        System.out.print("sviens/password: ");
83        auth.authenticate("sviens","password");
84        System.out.println("successfully authenticated");
85      }
86      catch(Exception ex) {
87        System.out.println(ex.getMessage());
88      }
89    }
90  }