import java.security.*;
import java.applet.Applet;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import netscape.javascript.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.URL;
import java.awt.datatransfer.*;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
public final class DOHRobot extends Applet{
// order of execution:
// wait for user to trust applet
// load security manager to prevent Safari hang
// discover document root in screen coordinates
// discover keyboard capabilities
// tell doh to continue with the test
// link to doh
// To invoke doh, call eval with window.eval("jsexp")
// Note that the "window" is an iframe!
// You might need to break out of the iframe with an intermediate function
// in the parent window.
private JSObject window = null;
// java.awt.Robot
// drives the test
// you need to sign the applet JAR for this to work
private Robot robot = null;
// In order to preserve the execution order of Robot commands,
// we have to serialize commands by having them join() the previous one.
// Otherwise, if you run doh.robot.typeKeys("dijit"), you frequently get something
// like "diijt"
private static Thread previousThread = null;
// Keyboard discovery.
// At init, the Robot types keys into a textbox and JavaScript tells the
// Robot what it got back.
// charMap maps characters to the KeyEvent that generates the character on
// the user's machine.
// charMap uses the Java 1.4.2 (lack of) template syntax for wider
// compatibility.
private static HashMap charMap = null;
// Java key constants to iterate over
// not all are available on all machines!
private Vector vkKeys = null;
// some state variables
private boolean shift = false;
private boolean altgraph = false;
private boolean ctrl = false;
private boolean alt = false;
private boolean meta = false;
private boolean numlockDisabled = false;
// shake hands with JavaScript the first keypess to wake up FF2/Mac
private boolean jsready = false;
private String keystring = "";
// Firebug gets a little too curious about our applet for its own good
// setting firebugIgnore to true ensures Firebug doesn't break the applet
public boolean firebugIgnore = true;
private static String os=System.getProperty("os.name").toUpperCase();
private static Toolkit toolkit=Toolkit.getDefaultToolkit();
private SecurityManager securitymanager;
private double key = -1;
// The screen x,y of the document upper left corner.
// We only set it once so people are less likely to take it over.
private boolean inited = false;
private int docScreenX = -100;
private int docScreenY = -100;
private int docScreenXMax;
private int docScreenYMax;
private boolean mouseSecurity = false;
// The last reported mouse x,y.
// If this is different from the real one, something's up.
private int lastMouseX;
private int lastMouseY;
public int dir=1;
// save a pointer to doh.robot for fast access
JSObject dohrobot = null;
// java.awt.Applet methods
public void stop(){
window = null;
dohrobot = null;
// only secure code run once
if(key != -2){
// prevent further execution of secure functions
key = -2;
// Java calls this when you close the window.
// It plays nice and restores the old security manager.
AccessController.doPrivileged(new PrivilegedAction(){
public Object run(){
log("Stop");
securitymanager.checkTopLevelWindow(null);
log("Security manager reset");
return null;
}
});
}
}
final private class onvisible extends ComponentAdapter{
public void componentShown(ComponentEvent evt){
// sets the security manager to fix a bug in liveconnect in Safari on Mac
if(key != -1){ return; }
Thread thread = new Thread(){
public void run(){
window = (JSObject) JSObject.getWindow(applet());
AccessController.doPrivileged(new PrivilegedAction(){
public Object run(){
log("> init Robot");
try{
SecurityManager oldsecurity = System.getSecurityManager();
boolean needsSecurityManager = applet().getParameter("needsSecurityManager").equals("true");
log("Socket connections managed? "+needsSecurityManager);
try{
securitymanager = oldsecurity;
securitymanager.checkTopLevelWindow(null);
// xdomain
if(charMap == null){
if(!confirm("DOH has detected that the current Web page is attempting to access DOH,\n"+
"but belongs to a different domain than the one you agreed to let DOH automate.\n"+
"If you did not intend to start a new DOH test by visiting this Web page,\n"+
"press Cancel now and leave the Web page.\n"+
"Otherwise, press OK to trust this domain to automate DOH tests.")){
stop();
return null;
}
}
log("Found old security manager");
}catch(Exception e){
e.printStackTrace();
log("Making new security manager");
securitymanager = new RobotSecurityManager(needsSecurityManager,
oldsecurity);
securitymanager.checkTopLevelWindow(null);
System.setSecurityManager(securitymanager);
}
// instantiate the Robot
robot = new Robot();
robot.setAutoWaitForIdle(true);
}catch(Exception e){
log("Error calling _init_: "+e.getMessage());
key = -2;
e.printStackTrace();
}
log("< init Robot");
return null;
}
});
if(key == -2){
// applet not trusted
// start the test without it
window.eval("doh.robot._appletDead=true;doh.run();");
}else{
// now that the applet has really started, let doh know it's ok to use it
log("_initRobot");
try{
dohrobot = (JSObject) window.eval("doh.robot");
dohrobot.call("_initRobot", new Object[]{ applet() });
}catch(Exception e){
e.printStackTrace();
}
}
}
};
thread.start();
}
}
public void init(){
// ensure isShowing = true
addComponentListener(new onvisible());
}
// loading functions
public void _setKey(double key){
if(key == -1){
return;
}else if(this.key == -1){
this.key = key;
}
}
private boolean mouseSecure() throws Exception{
// Use MouseInfo to ensure that mouse is inside browser.
// Only works in Java 1.5, but the DOHRobot must compile for 1.4.
if(!mouseSecurity){ return true; }
Class mouseInfoClass;
Class pointerInfoClass;
try{
mouseInfoClass = Class.forName("java.awt.MouseInfo");
pointerInfoClass = Class.forName("java.awt.PointerInfo");
}catch(ClassNotFoundException e){
// Java 1.4
e.printStackTrace();
return true;
}
Method getPointerInfo = mouseInfoClass.getMethod("getPointerInfo", new Class[0]);
Method getLocation = pointerInfoClass.getMethod("getLocation", new Class[0]);
Object pointer=null;
try{
pointer = getPointerInfo.invoke(pointerInfoClass,new Object[0]);
}catch(java.lang.reflect.InvocationTargetException e){
e.getTargetException().printStackTrace();
}
Point mousePosition = (Point)(getLocation.invoke(pointer,new Object[0]));
return mousePosition.x >= docScreenX
&& mousePosition.x <= docScreenXMax
&& mousePosition.y >= docScreenY
&& mousePosition.y <= docScreenYMax;
}
private boolean isSecure(double key){
boolean result = this.key != -1 && this.key != -2 && this.key == key;
try{
result=result&&mouseSecure();
}catch(Exception e){
e.printStackTrace();
result=false;
}
if(!result&&this.key!=-2){
this.key=-2;
window.eval("doh.robot._appletDead=true;");
log("User aborted test; mouse moved off of browser");
alert("User aborted test; mouse moved off of browser.");
}
log("Key secure: " + result);
return result;
}
public void _callLoaded(final double sec){
log("> _callLoaded Robot");
Thread thread = new Thread(){
public void run(){
if(!isSecure(sec)){
retur
没有合适的资源?快使用搜索试试~ 我知道了~
ZendFramework anzhuangnbao1
共3349个文件
js:1826个
png:362个
css:259个
需积分: 0 218 下载量 156 浏览量
2011-03-08
12:53:13
上传
评论
收藏 11.89MB RAR 举报
温馨提示
ZendFramework anzhuangnbao1 ZendFramework anzhuangnbao1
资源推荐
资源详情
资源评论
收起资源包目录
ZendFramework anzhuangnbao1 (3349个子文件)
africa 11KB
antarctica 3KB
Storage.as 12KB
DojoExternalInterface.as 5KB
ExpressInstall.as 2KB
asia 26KB
australasia 11KB
backward 4KB
build.bat 2KB
compilerobot.bat 388B
build.bat 261B
catalog 182B
dijit.css 46KB
iphone.css 17KB
android.css 16KB
TabContainer.css 13KB
TabContainer.css 13KB
TabContainer.css 13KB
Slider.css 12KB
Grid.css 8KB
FilePickerTextBox.css 8KB
Calendar.css 7KB
claroGrid.css 7KB
TabContainer.css 7KB
Calendar.css 7KB
ExpandoPane.css 6KB
stylesheet.css 6KB
tundraGrid.css 6KB
Toolbar.css 6KB
commonIcons.css 5KB
Dialog.css 5KB
Menu.css 5KB
toolbar.css 5KB
nihiloGrid.css 5KB
soriaGrid.css 5KB
Button.css 5KB
Common.css 5KB
iphone-compat.css 5KB
iphone-app.css 5KB
commonIcons_rtl.css 5KB
android-compat.css 5KB
buttons.css 5KB
dojo.css 5KB
Button.css 4KB
Slider.css 4KB
Dialog.css 4KB
Slider.css 4KB
NumberSpinner.css 4KB
Dialog.css 4KB
FloatingPane.css 4KB
BorderContainer.css 4KB
Slider.css 4KB
Dialog.css 4KB
editorPlugins.css 4KB
firebug.css 4KB
TimePicker.css 4KB
Button.css 4KB
Portlet.css 4KB
CollapsibleToolbar.css 4KB
Button.css 4KB
RollingList.css 4KB
editorIcons.css 4KB
AccordionContainer.css 4KB
FileUploader.css 4KB
CheckedMultiSelect.css 3KB
ToggleSplitter.css 3KB
Tree.css 3KB
Player.css 3KB
FileInput.css 3KB
Select.css 3KB
Calendar.css 3KB
Calendar.css 3KB
EnhancedGrid.css 3KB
Calendar.css 3KB
video_app.css 3KB
dijit_rtl.css 3KB
TabContainer_rtl.css 3KB
claroEnhancedGrid.css 3KB
Lightbox.css 2KB
Tree.css 2KB
Toolbar.css 2KB
Tree.css 2KB
Tree.css 2KB
Common.css 2KB
SlideShow.css 2KB
tundraEnhancedGrid.css 2KB
HtmlFeedEntryViewer.css 2KB
RadioButton.css 2KB
ThumbnailPicker.css 2KB
Dialog.css 2KB
Checkbox.css 2KB
document.css 2KB
Common.css 2KB
TitlePane.css 2KB
Common.css 2KB
HtmlFeedEntryEditor.css 2KB
Toolbar.css 2KB
Toolbar.css 2KB
Common.css 2KB
video_browser.css 2KB
共 3349 条
- 1
- 2
- 3
- 4
- 5
- 6
- 34
资源评论
swrain
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功