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.crammd5;
22
23 import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
24 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
25
26 import javax.security.sasl.SaslServerFactory;
27
28 public class CRAMMD5Initialiser extends UsernamePasswordInitialiser
29 {
30 private HashDirection _hashDirection;
31
32 public enum HashDirection
33 {
34 INCOMMING, PASSWORD_FILE
35 }
36
37
38 public String getMechanismName()
39 {
40 return "CRAM-MD5";
41 }
42
43 public Class<? extends SaslServerFactory> getServerFactoryClassForJCARegistration()
44 {
45 // since the CRAM-MD5 provider is registered as part of the JDK, we do not
46 // return the factory class here since we do not need to register it ourselves.
47 if (_hashDirection == HashDirection.PASSWORD_FILE)
48 {
49 return null;
50 }
51 else
52 {
53 //fixme we need a server that will correctly has the incomming plain text for comparison to file.
54 _logger.warn("we need a server that will correctly convert the incomming plain text for comparison to file.");
55 return null;
56 }
57 }
58
59 public void initialise(PrincipalDatabase passwordFile)
60 {
61 initialise(passwordFile, HashDirection.PASSWORD_FILE);
62 }
63
64 public void initialise(PrincipalDatabase passwordFile, HashDirection direction)
65 {
66 super.initialise(passwordFile);
67
68 _hashDirection = direction;
69 }
70
71 }
|