1 18 package org.apache.batik.bridge; 19 20 import org.apache.batik.util.ParsedURL; 21 22 30 public class DefaultScriptSecurity implements ScriptSecurity { 31 public static final String DATA_PROTOCOL = "data"; 32 36 public static final String ERROR_CANNOT_ACCESS_DOCUMENT_URL 37 = "DefaultScriptSecurity.error.cannot.access.document.url"; 38 39 43 public static final String ERROR_SCRIPT_FROM_DIFFERENT_URL 44 = "DefaultScriptSecurity.error.script.from.different.url"; 45 46 50 protected SecurityException se; 51 52 57 public void checkLoadScript(){ 58 if (se != null) { 59 throw se; 60 } 61 } 62 63 73 public DefaultScriptSecurity(String scriptType, 74 ParsedURL scriptURL, 75 ParsedURL docURL){ 76 if (docURL == null) { 79 se = new SecurityException 80 (Messages.formatMessage(ERROR_CANNOT_ACCESS_DOCUMENT_URL, 81 new Object []{scriptURL})); 82 } else { 83 String docHost = docURL.getHost(); 84 String scriptHost = scriptURL.getHost(); 85 86 if ((docHost != scriptHost) && 87 ((docHost == null) || (!docHost.equals(scriptHost)))) { 88 if ( !docURL.equals(scriptURL) 89 && 90 (scriptURL == null 91 || 92 !DATA_PROTOCOL.equals(scriptURL.getProtocol()) )) { 93 se = new SecurityException 94 (Messages.formatMessage(ERROR_SCRIPT_FROM_DIFFERENT_URL, 95 new Object []{scriptURL})); 96 } 97 } 98 } 99 100 } 101 } 102 103 104 105 | Popular Tags |