8225425: java.lang.UnsatisfiedLinkError: net.dll: Can't find dependent libraries

Reviewed-by: dfuchs, alanb, erikj
This commit is contained in:
Chris Hegarty 2019-08-19 14:28:43 +01:00
parent ff9d768630
commit cbfcd9c72e
4 changed files with 237 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -202,7 +202,17 @@ public class NTLMAuthentication extends AuthenticationInfo {
}
}
static native boolean isTrustedSite(String url);
private static final boolean isTrustedSiteAvailable = isTrustedSiteAvailable();
private static native boolean isTrustedSiteAvailable();
private static boolean isTrustedSite(String url) {
if (isTrustedSiteAvailable)
return isTrustedSite0(url);
return false;
}
private static native boolean isTrustedSite0(String url);
/**
* Not supported. Must use the setHeaders() method

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,19 +26,44 @@
#include <jni.h>
#include <windows.h>
#include "jni_util.h"
#include "jdk_util.h"
#include <urlmon.h>
JNIEXPORT jboolean JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSite(JNIEnv *env, jclass clazz, jstring url )
{
typedef HRESULT (WINAPI *CoInternetCreateSecurityManagerType)
(IServiceProvider*,IInternetSecurityManager**,DWORD);
static CoInternetCreateSecurityManagerType fn_CoInternetCreateSecurityManager;
JNIEXPORT jboolean JNICALL
Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSiteAvailable
(JNIEnv *env, jclass clazz)
{
HMODULE libUrlmon = JDK_LoadSystemLibrary("urlmon.dll");
if (libUrlmon != NULL) {
fn_CoInternetCreateSecurityManager = (CoInternetCreateSecurityManagerType)
GetProcAddress(libUrlmon, "CoInternetCreateSecurityManager");
if (fn_CoInternetCreateSecurityManager != NULL) {
return JNI_TRUE;
}
}
return JNI_FALSE;
}
JNIEXPORT jboolean JNICALL
Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSite0
(JNIEnv *env, jclass clazz, jstring url)
{
HRESULT hr;
DWORD dwZone;
DWORD pPolicy = 0;
IInternetSecurityManager *spSecurityManager;
jboolean ret;
if (fn_CoInternetCreateSecurityManager == NULL)
return JNI_FALSE;
// Create IInternetSecurityManager
hr = CoInternetCreateSecurityManager(NULL, &spSecurityManager, (DWORD)0);
hr = fn_CoInternetCreateSecurityManager(NULL, &spSecurityManager, (DWORD)0);
if (FAILED(hr)) {
return JNI_FALSE;
}