AuthenticationProviderInitialiser.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.server.security.auth.sasl;
22 
23 import java.util.Map;
24 
25 import javax.security.auth.callback.CallbackHandler;
26 import javax.security.sasl.SaslServerFactory;
27 
28 import org.apache.commons.configuration.Configuration;
29 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
30 
31 public interface AuthenticationProviderInitialiser
32 {
33     /**
34      @return the mechanism's name. This will be used in the list of mechanism's advertised to the
35      * client.
36      */
37     String getMechanismName();
38 
39     /**
40      * Initialise the authentication provider.
41      @param baseConfigPath the path in the config file that points to any config options for this provider. Each
42      * provider can have its own set of configuration options
43      @param configuration the Apache Commons Configuration instance used to configure this provider
44      @param principalDatabases the set of principal databases that are available
45      @throws Exception needs refined Exception is too broad.
46      */
47     void initialise(String baseConfigPath, Configuration configuration,
48                     Map<String, PrincipalDatabase> principalDatabasesthrows Exception;
49 
50     /**
51      * Initialise the authentication provider.     
52      @param db The principal database to initialise with
53      */
54     void initialise(PrincipalDatabase db);
55 
56 
57     /**
58      @return the callback handler that should be used to process authentication requests for this mechanism. This will
59      * be called after initialise and will be stored by the authentication manager. The callback handler <b>must</b> be
60      * fully threadsafe.
61      */
62     CallbackHandler getCallbackHandler();
63 
64     /**
65      * Get the properties that must be passed in to the Sasl.createSaslServer method.
66      @return the properties, which may be null
67      */
68     Map<String, ?> getProperties();
69 
70     /**
71      * Get the class that is the server factory. This is used for the JCA registration.
72      @return null if no JCA registration is required, otherwise return the class
73      * that will be used in JCA registration
74      */
75     Class<? extends SaslServerFactory> getServerFactoryClassForJCARegistration();
76 }