1 /* 2 3 Derby - Class org.apache.derby.authentication.UserAuthenticator 4 5 Licensed to the Apache Software Foundation (ASF) under one or more 6 contributor license agreements. See the NOTICE file distributed with 7 this work for additional information regarding copyright ownership. 8 The ASF licenses this file to You under the Apache License, Version 2.0 9 (the "License"); you may not use this file except in compliance with 10 the License. You may obtain a copy of the License at 11 12 http://www.apache.org/licenses/LICENSE-2.0 13 14 Unless required by applicable law or agreed to in writing, software 15 distributed under the License is distributed on an "AS IS" BASIS, 16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 See the License for the specific language governing permissions and 18 limitations under the License. 19 20 */ 21 22 package org.apache.derby.authentication; 23 24 import java.util.Properties; 25 import java.sql.SQLException; 26 27 /** 28 * The UserAuthenticator interface provides operations to authenticate 29 * a user's credentials in order to successfully connect to a database. 30 * 31 * Any user authentication schemes could be implemented using this interface 32 * and registered at start-up time. 33 * <p> 34 * If an application requires its own authentication scheme, then it can 35 * implement this interface and register as the authentication scheme 36 * that Derby should call upon connection requests to the system. 37 See the dcoumentation for the property <I>derby.authentication.provider</I> 38 * <p> 39 * A typical example would be to implement user authentication using 40 * LDAP, Sun NIS+, or even Windows User Domain, using this interface. 41 * <p> 42 * <i>Note</i>: Additional connection attributes can be specified on the 43 * database connection URL and/or Properties object on jdbc connection. Values 44 * for these attributes can be retrieved at runtime by the (specialized) 45 * authentication scheme to further help user authentication, if one needs 46 * additional info other than user, password, and database name. 47 * 48 * 49 */ 50 51 public interface UserAuthenticator 52 { 53 54 /** 55 * Authenticate a user's credentials. 56 * <BR> 57 * E.g. if connection url is 58 * <code>jdbc:derby:testdb;user=Fred;password=ScT7dmM2</code> 59 * then the userName will be Fred and within the Derby user authorization 60 * system, Fred becomes a case-insensitive authorization identifier and 61 * is known as FRED 62 *<BR> 63 * if connection url is 64 * <code>jdbc:derby:testdb;user="Fred";password=ScT7dmM2</code> 65 * then the userName will be "Fred" and within the Derby user authorization 66 * system, Fred becomes a case-sensitive authorization identifier and is 67 * known as Fred 68 * <BR> 69 * 70 * @param userName The user's name for the connection request. May be 71 * null. The user name is passed in as is from the 72 * connection request. 73 * Derby will pass in the user name that is set on 74 * connection request as is, without changing the 75 * casing and without removing the delimiter quotes 76 * if any. 77 * 78 * @param userPassword The user's password for the connection request. 79 * May be null. 80 * 81 * @param databaseName The database that the user wants to connect to. 82 * Will be null if this is system level authentication. 83 * 84 * @param info A Properties object that contains additional 85 * connection information, that can help to 86 * authenticate the user. It has properties of the 87 * 'info' object passed as part of 88 * DriverManager.getConnection() call and any 89 * attributes set on the JDBC URL. 90 * 91 * @return false if the connection request should be denied, true if the 92 * connection request should proceed. If false is returned the 93 * connection attempt will receive a SQLException with SQL State 94 * 08004. 95 * 96 * @exception java.sql.SQLException An exception processing the request, 97 * connection request will be denied. The SQL exception will 98 * be returned to the connection attempt. 99 */ 100 public boolean authenticateUser(String userName, 101 String userPassword, 102 String databaseName, 103 Properties info 104 ) 105 throws SQLException; 106 } 107