aboutsummaryrefslogtreecommitdiff
path: root/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c')
-rw-r--r--src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c b/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c
index db771d8cc2..65f2cabda4 100644
--- a/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c
+++ b/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthentication.c
@@ -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,11 +26,34 @@
#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;
@@ -38,8 +61,11 @@ JNIEXPORT jboolean JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthenticatio
jboolean ret;
LPCWSTR bstrURL;
+ 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;
}