pw
is not used because
- * for GSS there is only one single PasswordAuthentication which is
- * independant of host/port/... info.
+ * Constructor used for both WWW and proxy entries.
+ * @param hci a schemed object.
*/
- public NegotiateAuthentication(boolean isProxy, URL url,
- PasswordAuthentication pw, String scheme) {
- super(isProxy?PROXY_AUTHENTICATION:SERVER_AUTHENTICATION,
- NEGOTIATE_AUTH, url, "");
- this.scheme = scheme;
- }
-
- /**
- * Constructor used for proxy entries
- */
- public NegotiateAuthentication(boolean isProxy, String host, int port,
- PasswordAuthentication pw, String scheme) {
- super(isProxy?PROXY_AUTHENTICATION:SERVER_AUTHENTICATION,
- NEGOTIATE_AUTH,host, port, "");
- this.scheme = scheme;
+ public NegotiateAuthentication(HttpCallerInfo hci) {
+ super(RequestorType.PROXY==hci.authType?
+ PROXY_AUTHENTICATION:SERVER_AUTHENTICATION,
+ hci.scheme.equalsIgnoreCase("Negotiate")?
+ NEGOTIATE_AUTH:KERBEROS_AUTH,
+ hci.url, "");
+ this.hci = hci;
}
/**
@@ -95,32 +84,29 @@ class NegotiateAuthentication extends AuthenticationInfo {
}
/**
- * Find out if a hostname supports Negotiate protocol. In order to find
- * out yes or no, an initialization of a Negotiator object against
- * hostname and scheme is tried. The generated object will be cached
- * under the name of hostname at a success try.supported
, so no need to try again.
+ * If this method is called for the second time on an HttpCallerInfo with
+ * the same hostname, the answer is retrieved from cache.
*
- * @param hostname hostname to test
- * @param scheme scheme to test
* @return true if supported
*/
- synchronized public static boolean isSupported(String hostname,
- String scheme) {
+ synchronized public static boolean isSupported(HttpCallerInfo hci) {
if (supported == null) {
supported = new HashMap http.negotiate.mechanism.oid
,
- * defaults SPNEGO
+ * http.negotiate.mechanism.oid
, defaults SPNEGO
*
* Attention: This method references krb5.conf settings. If you need to
* setup krb5.conf later, please call Config.refresh()
after
* the new setting. For example:
*
- * kdc.writeKtab("/etc/kdc/ktab"); // Config is initialized, + * KDC.writeKtab("/etc/kdc/ktab", kdc); // Config is initialized, * System.setProperty("java.security.krb5.conf", "/home/mykrb5.conf"); * Config.refresh(); *@@ -223,20 +223,31 @@ public class KDC { * @throws sun.security.krb5.KrbException for any realm and/or principal * name error. */ - public void writeKtab(String tab) throws IOException, KrbException { + public static void writeMultiKtab(String tab, KDC... kdcs) + throws IOException, KrbException { KeyTab ktab = KeyTab.create(tab); - for (String name : passwords.keySet()) { - if (name.equals("krbtgt/" + realm)) { - continue; - } - ktab.addEntry(new PrincipalName(name + "@" + realm, - name.indexOf('/') < 0 ? - PrincipalName.KRB_NT_UNKNOWN : - PrincipalName.KRB_NT_SRV_HST), passwords.get(name)); + for (KDC kdc: kdcs) { + for (String name : kdc.passwords.keySet()) { + if (name.equals("krbtgt/" + kdc.realm)) { + continue; + } + ktab.addEntry(new PrincipalName(name + "@" + kdc.realm, + name.indexOf('/') < 0 ? + PrincipalName.KRB_NT_UNKNOWN : + PrincipalName.KRB_NT_SRV_HST), + kdc.passwords.get(name)); + } } ktab.save(); } + /** + * Write a ktab for this KDC. + */ + public void writeKtab(String tab) throws IOException, KrbException { + KDC.writeMultiKtab(tab, this); + } + /** * Adds a new principal to this realm with a given password. * @param user the principal's name. For a service principal, use the diff --git a/test/sun/security/krb5/auto/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor b/test/sun/security/krb5/auto/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor new file mode 100644 index 0000000000000000000000000000000000000000..32f3a09bb472ceb7c47f07fbb543806150364fe5 --- /dev/null +++ b/test/sun/security/krb5/auto/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor @@ -0,0 +1 @@ +HttpNegotiateServer