1 18 package org.apache.batik.bridge; 19 20 import java.net.URL ; 21 import java.net.URLClassLoader ; 22 import java.security.CodeSource ; 23 import java.security.cert.Certificate ; 24 import java.security.Permission ; 25 import java.security.PermissionCollection ; 26 import java.security.Policy ; 27 import java.util.Enumeration ; 28 29 41 public class DocumentJarClassLoader extends URLClassLoader { 42 46 protected CodeSource documentCodeSource = null; 47 48 51 public DocumentJarClassLoader(URL jarURL, 52 URL documentURL){ 53 super(new URL []{jarURL}); 54 55 if (documentURL != null) { 56 documentCodeSource = new CodeSource 57 (documentURL, (Certificate [])null); 58 } 59 } 60 61 76 protected PermissionCollection getPermissions(CodeSource codesource) 77 { 78 Policy p = Policy.getPolicy(); 81 82 PermissionCollection pc = null; 83 if (p != null) { 84 pc = p.getPermissions(codesource); 85 } 86 87 if (documentCodeSource != null){ 89 PermissionCollection urlPC 90 = super.getPermissions(documentCodeSource); 91 92 if (pc != null) { 93 Enumeration items = urlPC.elements(); 94 while (items.hasMoreElements()) { 95 pc.add((Permission )(items.nextElement())); 96 } 97 } else { 98 pc = urlPC; 99 } 100 } 101 102 return pc; 103 } 104 } 105 | Popular Tags |