protected Class<?> defineClassFromData(
     final File container, final byte[] classData, final String classname) throws IOException {
   this.definePackage(container, classname);
   final ProtectionDomain currentPd = Project.class.getProtectionDomain();
   final String classResource = this.getClassFilename(classname);
   final CodeSource src =
       new CodeSource(
           AntClassLoader.FILE_UTILS.getFileURL(container),
           this.getCertificates(container, classResource));
   final ProtectionDomain classesPd =
       new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals());
   return this.defineClass(classname, classData, 0, classData.length, classesPd);
 }
Example #2
0
 static Class loadAdapterClass(String className, byte[] classBytes) {
   Object staticDomain;
   Class domainClass = SecurityController.getStaticSecurityDomainClass();
   if (domainClass == CodeSource.class || domainClass == ProtectionDomain.class) {
     ProtectionDomain protectionDomain = JavaAdapter.class.getProtectionDomain();
     if (domainClass == CodeSource.class) {
       staticDomain = protectionDomain == null ? null : protectionDomain.getCodeSource();
     } else {
       staticDomain = protectionDomain;
     }
   } else {
     staticDomain = null;
   }
   GeneratedClassLoader loader = SecurityController.createLoader(null, staticDomain);
   Class result = loader.defineClass(className, classBytes);
   loader.linkClass(result);
   return result;
 }
Example #3
0
 static Class<?> loadAdapterClass(String className, byte[] classBytes) {
   Object staticDomain;
   Class<?> domainClass = SecurityController.getStaticSecurityDomainClass();
   if (domainClass == CodeSource.class || domainClass == ProtectionDomain.class) {
     // use the calling script's security domain if available
     ProtectionDomain protectionDomain = SecurityUtilities.getScriptProtectionDomain();
     if (protectionDomain == null) {
       protectionDomain = JavaAdapter.class.getProtectionDomain();
     }
     if (domainClass == CodeSource.class) {
       staticDomain = protectionDomain == null ? null : protectionDomain.getCodeSource();
     } else {
       staticDomain = protectionDomain;
     }
   } else {
     staticDomain = null;
   }
   GeneratedClassLoader loader = SecurityController.createLoader(null, staticDomain);
   Class<?> result = loader.defineClass(className, classBytes);
   loader.linkClass(result);
   return result;
 }