Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
aec835c6
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看板
提交
aec835c6
编写于
11月 23, 2011
作者:
C
coffeys
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7102369: remove java.rmi.server.codebase property parsing from registyimpl
7094468: rmiregistry clean up Reviewed-by: smarks
上级
8693edee
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
278 addition
and
25 deletion
+278
-25
src/share/classes/sun/rmi/registry/RegistryImpl.java
src/share/classes/sun/rmi/registry/RegistryImpl.java
+8
-23
src/share/classes/sun/rmi/server/LoaderHandler.java
src/share/classes/sun/rmi/server/LoaderHandler.java
+2
-2
test/java/rmi/registry/readTest/readTest.java
test/java/rmi/registry/readTest/readTest.java
+58
-0
test/java/rmi/registry/readTest/readTest.sh
test/java/rmi/registry/readTest/readTest.sh
+95
-0
test/java/rmi/registry/readTest/testPkg/Client.java
test/java/rmi/registry/readTest/testPkg/Client.java
+48
-0
test/java/rmi/registry/readTest/testPkg/Hello.java
test/java/rmi/registry/readTest/testPkg/Hello.java
+31
-0
test/java/rmi/registry/readTest/testPkg/Server.java
test/java/rmi/registry/readTest/testPkg/Server.java
+36
-0
未找到文件。
src/share/classes/sun/rmi/registry/RegistryImpl.java
浏览文件 @
aec835c6
/*
* Copyright (c) 1996, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 20
11
, 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
...
...
@@ -29,6 +29,7 @@ import java.util.Enumeration;
import
java.util.Hashtable
;
import
java.util.MissingResourceException
;
import
java.util.ResourceBundle
;
import
java.io.FilePermission
;
import
java.io.IOException
;
import
java.net.*
;
import
java.rmi.*
;
...
...
@@ -54,7 +55,6 @@ import sun.rmi.server.UnicastServerRef2;
import
sun.rmi.transport.LiveRef
;
import
sun.rmi.transport.ObjectTable
;
import
sun.rmi.transport.Target
;
import
sun.security.action.GetPropertyAction
;
/**
* A "registry" exists on every node that allows RMI connections to
...
...
@@ -335,19 +335,6 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
URL
[]
urls
=
sun
.
misc
.
URLClassPath
.
pathToURLs
(
envcp
);
ClassLoader
cl
=
new
URLClassLoader
(
urls
);
String
codebaseProperty
=
null
;
String
prop
=
java
.
security
.
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"java.rmi.server.codebase"
));
if
(
prop
!=
null
&&
prop
.
trim
().
length
()
>
0
)
{
codebaseProperty
=
prop
;
}
URL
[]
codebaseURLs
=
null
;
if
(
codebaseProperty
!=
null
)
{
codebaseURLs
=
sun
.
misc
.
URLClassPath
.
pathToURLs
(
codebaseProperty
);
}
else
{
codebaseURLs
=
new
URL
[
0
];
}
/*
* Fix bugid 4242317: Classes defined by this class loader should
* be annotated with the value of the "java.rmi.server.codebase"
...
...
@@ -365,7 +352,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
public
RegistryImpl
run
()
throws
RemoteException
{
return
new
RegistryImpl
(
regPort
);
}
},
getAccessControlContext
(
codebaseURLs
));
},
getAccessControlContext
());
}
catch
(
PrivilegedActionException
ex
)
{
throw
(
RemoteException
)
ex
.
getException
();
}
...
...
@@ -391,11 +378,11 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
}
/**
* Generates an AccessControlContext
from several URL
s.
* Generates an AccessControlContext
with minimal permission
s.
* The approach used here is taken from the similar method
* getAccessControlContext() in the sun.applet.AppletPanel class.
*/
private
static
AccessControlContext
getAccessControlContext
(
URL
[]
urls
)
{
private
static
AccessControlContext
getAccessControlContext
()
{
// begin with permissions granted to all code in current policy
PermissionCollection
perms
=
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
PermissionCollection
>()
{
...
...
@@ -420,17 +407,15 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
perms
.
add
(
new
RuntimePermission
(
"accessClassInPackage.sun.*"
));
// add permissions required to load from codebase URL path
LoaderHandler
.
addPermissionsForURLs
(
urls
,
perms
,
false
);
perms
.
add
(
new
FilePermission
(
"<<ALL FILES>>"
,
"read"
));
/*
* Create an AccessControlContext that consists of a single
* protection domain with only the permissions calculated above.
*/
ProtectionDomain
pd
=
new
ProtectionDomain
(
new
CodeSource
((
urls
.
length
>
0
?
urls
[
0
]
:
null
),
(
java
.
security
.
cert
.
Certificate
[])
null
),
perms
);
new
CodeSource
(
null
,
(
java
.
security
.
cert
.
Certificate
[])
null
),
perms
);
return
new
AccessControlContext
(
new
ProtectionDomain
[]
{
pd
});
}
}
src/share/classes/sun/rmi/server/LoaderHandler.java
浏览文件 @
aec835c6
/*
* Copyright (c) 1996, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 20
11
, 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
...
...
@@ -1031,7 +1031,7 @@ public final class LoaderHandler {
* loader. A given permission is only added to the collection if
* it is not already implied by the collection.
*/
p
ublic
static
void
addPermissionsForURLs
(
URL
[]
urls
,
p
rivate
static
void
addPermissionsForURLs
(
URL
[]
urls
,
PermissionCollection
perms
,
boolean
forLoader
)
{
...
...
test/java/rmi/registry/readTest/readTest.java
0 → 100644
浏览文件 @
aec835c6
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.rmi.registry.Registry
;
import
java.rmi.registry.LocateRegistry
;
import
java.rmi.RemoteException
;
import
java.rmi.server.UnicastRemoteObject
;
public
class
readTest
{
public
static
void
main
(
String
args
[])
throws
Exception
{
int
port
=
7491
;
try
{
testPkg
.
Server
obj
=
new
testPkg
.
Server
();
testPkg
.
Hello
stub
=
(
testPkg
.
Hello
)
UnicastRemoteObject
.
exportObject
(
obj
,
0
);
// Bind the remote object's stub in the registry
Registry
registry
=
LocateRegistry
.
getRegistry
(
port
);
registry
.
bind
(
"Hello"
,
stub
);
System
.
err
.
println
(
"Server ready"
);
// now, let's test client
testPkg
.
Client
client
=
new
testPkg
.
Client
(
port
);
String
testStubReturn
=
client
.
testStub
();
if
(!
testStubReturn
.
equals
(
obj
.
hello
))
{
throw
new
RuntimeException
(
"Test Fails : unexpected string from stub call"
);
}
else
{
System
.
out
.
println
(
"Test passed"
);
}
registry
.
unbind
(
"Hello"
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Server exception: "
+
e
.
toString
());
e
.
printStackTrace
();
}
}
}
test/java/rmi/registry/readTest/readTest.sh
0 → 100644
浏览文件 @
aec835c6
#
# Copyright (c) 2011, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 7102369 7094468 7100592
# @summary remove java.rmi.server.codebase property parsing from registyimpl
# @run shell readTest.sh
OS
=
`
uname
-s
`
case
"
$OS
"
in
SunOS
|
Linux
)
PS
=
":"
FS
=
"/"
FILEURL
=
"file:"
;;
Windows
*
|
CYGWIN
*
)
PS
=
";"
FS
=
"
\\
"
FILEURL
=
"file:/"
;;
*
)
echo
"Unrecognized system!"
exit
1
;
;;
esac
cp
-r
${
TESTSRC
}${
FS
}*
.
${
TESTJAVA
}${
FS
}
bin
${
FS
}
javac testPkg
${
FS
}*
java
${
TESTJAVA
}${
FS
}
bin
${
FS
}
javac readTest.java
mkdir
rmi_tmp
RMIREG_OUT
=
rmi.out
#start rmiregistry without any local classes on classpath
cd
rmi_tmp
${
TESTJAVA
}${
FS
}
bin
${
FS
}
rmiregistry 7491
>
..
${
FS
}${
RMIREG_OUT
}
2>&1 &
RMIREG_PID
=
$!
# allow some time to start
sleep
3
cd
..
# trailing / after code base is important for rmi codebase property.
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java
-Djava
.rmi.server.codebase
=
${
FILEURL
}
`
pwd
`
/ readTest
>
OUT.TXT 2>&1 &
TEST_PID
=
$!
#bulk of testcase - let it run for a while
sleep
5
#we're done, kill processes first
kill
-9
${
RMIREG_PID
}
${
TEST_PID
}
sleep
3
echo
"Test output : "
cat
OUT.TXT
echo
"=============="
echo
"rmiregistry output : "
cat
${
RMIREG_OUT
}
echo
"=============="
grep
"Server ready"
OUT.TXT
result1
=
$?
grep
"Test passed"
OUT.TXT
result2
=
$?
if
[
$result1
-eq
0
-a
$result2
-eq
0
]
then
echo
"Passed"
exitCode
=
0
;
else
echo
"Failed"
exitCode
=
1
fi
rm
-rf
OUT.TXT
${
RMIREG_OUT
}
rmi_tmp
exit
${
exitCode
}
test/java/rmi/registry/readTest/testPkg/Client.java
0 → 100644
浏览文件 @
aec835c6
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
testPkg
;
import
java.rmi.registry.LocateRegistry
;
import
java.rmi.registry.Registry
;
public
class
Client
{
int
port
;
public
Client
(
int
p
)
{
port
=
p
;
}
public
String
testStub
()
throws
Exception
{
try
{
Registry
registry
=
LocateRegistry
.
getRegistry
(
port
);
Hello
stub
=
(
Hello
)
registry
.
lookup
(
"Hello"
);
String
response
=
stub
.
sayHello
();
return
response
;
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Client exception: "
+
e
.
toString
());
throw
e
;
}
}
}
test/java/rmi/registry/readTest/testPkg/Hello.java
0 → 100644
浏览文件 @
aec835c6
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
testPkg
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
public
interface
Hello
extends
Remote
{
String
sayHello
()
throws
RemoteException
;
}
test/java/rmi/registry/readTest/testPkg/Server.java
0 → 100644
浏览文件 @
aec835c6
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
testPkg
;
public
class
Server
implements
Hello
{
public
String
hello
=
"Hello, world!"
;
public
Server
()
{}
public
String
sayHello
()
{
return
hello
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录