Changeset 11897


Ignore:
Timestamp:
05/18/09 21:16:14 (14 years ago)
Author:
astalla
Message:

Initial attempt at JNLP - Java Web Start. This currently needs full
security permissions to run.

Location:
branches/jnlp/abcl/src/org/armedbear/lisp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/jnlp/abcl/src/org/armedbear/lisp/Interpreter.java

    r11745 r11897  
    4040import java.io.InputStreamReader;
    4141import java.io.OutputStream;
     42import java.security.*;
    4243
    4344public final class Interpreter extends Lisp
     
    128129    private Interpreter()
    129130    {
     131 
     132  Policy.setPolicy
     133      (new Policy() {
     134        public PermissionCollection getPermissions(CodeSource codesource) {
     135      Permissions perms = new Permissions();
     136      perms.add(new AllPermission());
     137      return (perms);
     138        }
     139    });
    130140        jlisp = false;
    131141        inputStream = null;
  • branches/jnlp/abcl/src/org/armedbear/lisp/Lisp.java

    r11889 r11897  
    10241024          }
    10251025      }
    1026     if (device instanceof Pathname)
    1027       {
    1028         // We're loading a fasl from j.jar.
     1026    if (device instanceof Pathname) {
     1027        // We're loading a fasl from a jar.
    10291028        URL url = Lisp.class.getResource(namestring);
    1030         if (url != null)
    1031           {
    1032             try
    1033               {
    1034                 String s = url.toString();
    1035                 String zipFileName;
    1036                 String entryName;
    1037                 if (s.startsWith("jar:file:"))
    1038                   {
    1039                     s = s.substring(9);
    1040                     int index = s.lastIndexOf('!');
    1041                     if (index >= 0)
    1042                       {
    1043                         zipFileName = s.substring(0, index);
    1044                         entryName = s.substring(index + 1);
    1045                         if (entryName.length() > 0 && entryName.charAt(0) == '/')
    1046                           entryName = entryName.substring(1);
    1047                         if (Utilities.isPlatformWindows)
    1048                           {
    1049                             // "/C:/Documents%20and%20Settings/peter/Desktop/j.jar"
    1050                             if (zipFileName.length() > 0 && zipFileName.charAt(0) == '/')
    1051                               zipFileName = zipFileName.substring(1);
    1052                           }
    1053                         zipFileName = URLDecoder.decode(zipFileName, "UTF-8");
    1054                         ZipFile zipFile = new ZipFile(zipFileName);
    1055                         try
    1056                           {
    1057                             ZipEntry entry = zipFile.getEntry(entryName);
    1058                             if (entry != null)
    1059                               {
    1060                                 long size = entry.getSize();
    1061                                 InputStream in = zipFile.getInputStream(entry);
    1062                                 LispObject obj = loadCompiledFunction(in, (int) size);
    1063                                 return obj != null ? obj : NIL;
    1064                               }
    1065                           }
    1066                         finally
    1067                           {
    1068                             zipFile.close();
    1069                           }
    1070                       }
    1071                   }
    1072               }
     1029        if (url != null) {
     1030            try {
     1031    InputStream input = url.openStream();
     1032    java.io.ByteArrayOutputStream baos =
     1033        new java.io.ByteArrayOutputStream();
     1034               
     1035    byte[] bytes = new byte[4096];
     1036    int n = 0;
     1037    while (n >= 0) {
     1038        n = input.read(bytes, 0, 4096);
     1039        if(n >= 0) {
     1040      baos.write(bytes, 0, n);
     1041        }
     1042    }
     1043    input.close();
     1044    bytes = baos.toByteArray();
     1045    baos.close();
     1046    JavaClassLoader loader = new JavaClassLoader();
     1047    Class c =
     1048        loader.loadClassFromByteArray(null, bytes, 0, bytes.length);
     1049    if (c != null) {
     1050        Class[] parameterTypes = new Class[0];
     1051        Constructor constructor =
     1052      c.getConstructor(parameterTypes);
     1053        Object[] initargs = new Object[0];
     1054        LispObject obj =
     1055      (LispObject) constructor.newInstance(initargs);
     1056        if (obj instanceof Function)
     1057      ((Function)obj).setClassBytes(bytes);
     1058        return obj != null ? obj : NIL;
     1059    }
     1060      }
    10731061            catch (VerifyError e)
    10741062              {
  • branches/jnlp/abcl/src/org/armedbear/lisp/Load.java

    r11889 r11897  
    301301                        try {
    302302                            in = url.openStream();
    303                             if ("jar".equals(url.getProtocol()))
     303                            if ("jar".equals(url.getProtocol()) &&
     304        url.getPath().startsWith("file:")) {
    304305                                pathname = new Pathname(url);
     306          }
    305307                            truename = getPath(url);
    306308                        }
Note: See TracChangeset for help on using the changeset viewer.