22 */ |
22 */ |
23 |
23 |
24 import java.io.File; |
24 import java.io.File; |
25 import java.io.FileOutputStream; |
25 import java.io.FileOutputStream; |
26 import java.io.IOException; |
26 import java.io.IOException; |
|
27 import java.net.InetAddress; |
|
28 import java.net.UnknownHostException; |
27 import java.security.Security; |
29 import java.security.Security; |
28 import javax.security.auth.callback.Callback; |
30 import javax.security.auth.callback.Callback; |
29 import javax.security.auth.callback.CallbackHandler; |
31 import javax.security.auth.callback.CallbackHandler; |
30 import javax.security.auth.callback.NameCallback; |
32 import javax.security.auth.callback.NameCallback; |
31 import javax.security.auth.callback.PasswordCallback; |
33 import javax.security.auth.callback.PasswordCallback; |
42 * new OneKDC(null).writeJaasConf(); |
44 * new OneKDC(null).writeJaasConf(); |
43 * </pre> |
45 * </pre> |
44 */ |
46 */ |
45 public class OneKDC extends KDC { |
47 public class OneKDC extends KDC { |
46 |
48 |
|
49 // The krb5 codes would try to canonicalize hostnames before creating |
|
50 // a service principal name, so let's find out the canonicalized form |
|
51 // of localhost first. The following codes mimic the process inside |
|
52 // PrincipalName.java. |
|
53 static String localhost = "localhost"; |
|
54 static { |
|
55 try { |
|
56 localhost = InetAddress.getByName(localhost) |
|
57 .getCanonicalHostName(); |
|
58 } catch (UnknownHostException uhe) { |
|
59 ; // Ignore, localhost is still "localhost" |
|
60 } |
|
61 } |
47 public static final String USER = "dummy"; |
62 public static final String USER = "dummy"; |
48 public static final char[] PASS = "bogus".toCharArray(); |
63 public static final char[] PASS = "bogus".toCharArray(); |
49 public static final String SERVER = "server/localhost"; |
64 public static String SERVER = "server/" + localhost; |
50 public static final String BACKEND = "backend/localhost"; |
65 public static String BACKEND = "backend/" + localhost; |
51 public static final String KRB5_CONF = "localkdc-krb5.conf"; |
66 public static final String KRB5_CONF = "localkdc-krb5.conf"; |
52 public static final String KTAB = "localkdc.ktab"; |
67 public static final String KTAB = "localkdc.ktab"; |
53 public static final String JAAS_CONF = "localkdc-jaas.conf"; |
68 public static final String JAAS_CONF = "localkdc-jaas.conf"; |
54 public static final String REALM = "RABBIT.HOLE"; |
69 public static final String REALM = "RABBIT.HOLE"; |
55 |
70 |