Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
12c1b68e
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
12c1b68e
编写于
5月 21, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8077155: LoginContext Subject ignored by jdk8 sun.net.www.protocol.http.HttpURLConnection
Reviewed-by: michaelm
上级
fa3ea526
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
160 addition
and
7 deletion
+160
-7
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
.../classes/sun/net/www/protocol/http/HttpURLConnection.java
+4
-4
test/sun/security/krb5/auto/HttpNegotiateServer.java
test/sun/security/krb5/auto/HttpNegotiateServer.java
+156
-3
未找到文件。
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
浏览文件 @
12c1b68e
...
...
@@ -982,7 +982,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
SocketPermission
p
=
URLtoSocketPermission
(
this
.
url
);
if
(
p
!=
null
)
{
try
{
AccessController
.
doPrivileged
(
AccessController
.
doPrivileged
WithCombiner
(
new
PrivilegedExceptionAction
<
Void
>()
{
public
Void
run
()
throws
IOException
{
plainConnect0
();
...
...
@@ -1243,7 +1243,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if
(
p
!=
null
)
{
try
{
return
AccessController
.
doPrivileged
(
return
AccessController
.
doPrivileged
WithCombiner
(
new
PrivilegedExceptionAction
<
OutputStream
>()
{
public
OutputStream
run
()
throws
IOException
{
return
getOutputStream0
();
...
...
@@ -1426,7 +1426,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if
(
p
!=
null
)
{
try
{
return
AccessController
.
doPrivileged
(
return
AccessController
.
doPrivileged
WithCombiner
(
new
PrivilegedExceptionAction
<
InputStream
>()
{
public
InputStream
run
()
throws
IOException
{
return
getInputStream0
();
...
...
@@ -2568,7 +2568,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if
(
p
!=
null
)
{
try
{
return
AccessController
.
doPrivileged
(
return
AccessController
.
doPrivileged
WithCombiner
(
new
PrivilegedExceptionAction
<
Boolean
>()
{
public
Boolean
run
()
throws
IOException
{
return
followRedirect0
(
loc
,
stat
,
locUrl0
);
...
...
test/sun/security/krb5/auto/HttpNegotiateServer.java
浏览文件 @
12c1b68e
...
...
@@ -40,16 +40,28 @@ import java.io.BufferedReader;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.InetSocketAddress
;
import
java.net.PasswordAuthentication
;
import
java.net.Proxy
;
import
java.net.URL
;
import
java.security.PrivilegedExceptionAction
;
import
java.net.URLConnection
;
import
java.security.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.security.auth.Subject
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.security.auth.callback.NameCallback
;
import
javax.security.auth.callback.PasswordCallback
;
import
javax.security.auth.callback.UnsupportedCallbackException
;
import
javax.security.auth.login.AppConfigurationEntry
;
import
javax.security.auth.login.Configuration
;
import
javax.security.auth.login.LoginContext
;
import
javax.security.auth.login.LoginException
;
import
javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag
;
import
org.ietf.jgss.GSSContext
;
import
org.ietf.jgss.GSSCredential
;
import
org.ietf.jgss.GSSManager
;
...
...
@@ -191,7 +203,7 @@ public class HttpNegotiateServer {
proxyUrl
=
new
URL
(
"http://nosuchplace/a/b/c"
);
try
{
Exception
e1
=
null
,
e2
=
null
;
Exception
e1
=
null
,
e2
=
null
,
e3
=
null
;
try
{
test6578647
();
}
catch
(
Exception
e
)
{
...
...
@@ -204,7 +216,14 @@ public class HttpNegotiateServer {
e2
=
e
;
e
.
printStackTrace
();
}
if
(
e1
!=
null
||
e2
!=
null
)
{
try
{
test8077155
();
}
catch
(
Exception
e
)
{
e3
=
e
;
e
.
printStackTrace
();
}
if
(
e1
!=
null
||
e2
!=
null
||
e3
!=
null
)
{
throw
new
RuntimeException
(
"Test error"
);
}
}
finally
{
...
...
@@ -248,6 +267,121 @@ public class HttpNegotiateServer {
}
}
static
void
testConnect
()
{
InputStream
inputStream
=
null
;
try
{
URL
url
=
webUrl
;
URLConnection
conn
=
url
.
openConnection
();
conn
.
connect
();
inputStream
=
conn
.
getInputStream
();
byte
[]
b
=
new
byte
[
inputStream
.
available
()];
for
(
int
j
=
0
;
j
<
b
.
length
;
j
++)
{
b
[
j
]
=
(
byte
)
inputStream
.
read
();
}
String
s
=
new
String
(
b
);
System
.
out
.
println
(
"Length: "
+
s
.
length
());
System
.
out
.
println
(
s
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
finally
{
if
(
inputStream
!=
null
)
{
try
{
inputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
static
void
test8077155
()
throws
Exception
{
final
String
username
=
WEB_USER
;
final
char
[]
password
=
WEB_PASS
;
SecurityManager
security
=
new
SecurityManager
();
Policy
.
setPolicy
(
new
SecurityPolicy
());
System
.
setSecurityManager
(
security
);
CallbackHandler
callback
=
new
CallbackHandler
()
{
@Override
public
void
handle
(
Callback
[]
pCallbacks
)
throws
IOException
,
UnsupportedCallbackException
{
for
(
Callback
cb
:
pCallbacks
)
{
if
(
cb
instanceof
NameCallback
)
{
NameCallback
ncb
=
(
NameCallback
)
cb
;
ncb
.
setName
(
username
);
}
else
if
(
cb
instanceof
PasswordCallback
)
{
PasswordCallback
pwdcb
=
(
PasswordCallback
)
cb
;
pwdcb
.
setPassword
(
password
);
}
}
}
};
final
String
jaasConfigName
=
"oracle.test.kerberos.login"
;
final
String
krb5LoginModule
=
"com.sun.security.auth.module.Krb5LoginModule"
;
Configuration
loginConfig
=
new
Configuration
()
{
@Override
public
AppConfigurationEntry
[]
getAppConfigurationEntry
(
String
name
)
{
if
(!
jaasConfigName
.
equals
(
name
))
{
return
new
AppConfigurationEntry
[
0
];
}
Map
<
String
,
String
>
options
=
new
HashMap
<
String
,
String
>();
options
.
put
(
"useTicketCache"
,
Boolean
.
FALSE
.
toString
());
options
.
put
(
"useKeyTab"
,
Boolean
.
FALSE
.
toString
());
return
new
AppConfigurationEntry
[]
{
new
AppConfigurationEntry
(
krb5LoginModule
,
LoginModuleControlFlag
.
REQUIRED
,
options
)
};
}
};
// oracle context/subject/login
LoginContext
context
=
null
;
try
{
context
=
new
LoginContext
(
"oracle.test.kerberos.login"
,
null
,
callback
,
loginConfig
);
context
.
login
();
}
catch
(
LoginException
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
ex
);
}
Subject
subject
=
context
.
getSubject
();
final
PrivilegedExceptionAction
<
Object
>
test_action
=
new
PrivilegedExceptionAction
<
Object
>()
{
public
Object
run
()
throws
Exception
{
testConnect
();
return
null
;
}
};
System
.
err
.
println
(
"\n\nExpecting to succeed when executing with the the logged in subject."
);
try
{
Subject
.
doAs
(
subject
,
test_action
);
System
.
err
.
println
(
"\n\nConnection succeed when executing with the the logged in subject."
);
}
catch
(
PrivilegedActionException
e
)
{
System
.
err
.
println
(
"\n\nFailure unexpected when executing with the the logged in subject."
);
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Failed to login as subject"
);
}
try
{
System
.
err
.
println
(
"\n\nExpecting to fail when running with the current user's login."
);
testConnect
();
}
catch
(
Exception
ex
)
{
System
.
err
.
println
(
"\nConnect failed when running with the current user's login:\n"
+
ex
.
getMessage
());
}
}
/**
* Creates and starts an HTTP or proxy server that requires
* Negotiate authentication.
...
...
@@ -360,3 +494,22 @@ public class HttpNegotiateServer {
}
}
}
class
SecurityPolicy
extends
Policy
{
private
static
Permissions
perms
;
public
SecurityPolicy
()
{
super
();
if
(
perms
==
null
)
{
perms
=
new
Permissions
();
perms
.
add
(
new
AllPermission
());
}
}
@Override
public
PermissionCollection
getPermissions
(
CodeSource
codesource
)
{
return
perms
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录