Mercurial Hosting > luan
comparison core/src/luan/modules/IoLuan.java @ 301:a6bf8ff720f8
add java security
git-svn-id: https://luan-java.googlecode.com/svn/trunk@302 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 17 Dec 2014 12:35:57 +0000 |
parents | a74559240b4f |
children | 9e9bb358b2df |
comparison
equal
deleted
inserted
replaced
300:9fb523472035 | 301:a6bf8ff720f8 |
---|---|
331 public static final class LuanFile extends LuanIO { | 331 public static final class LuanFile extends LuanIO { |
332 private final File file; | 332 private final File file; |
333 | 333 |
334 private LuanFile(LuanState luan,File file) throws LuanException { | 334 private LuanFile(LuanState luan,File file) throws LuanException { |
335 this(file); | 335 this(file); |
336 check(luan,"file",file.toString()); | 336 check(luan,"file:"+file.toString()); |
337 } | 337 } |
338 | 338 |
339 private LuanFile(File file) { | 339 private LuanFile(File file) { |
340 this.file = file; | 340 this.file = file; |
341 } | 341 } |
422 | 422 |
423 public static LuanTable classpath(LuanState luan,String name) throws LuanException { | 423 public static LuanTable classpath(LuanState luan,String name) throws LuanException { |
424 if( name.contains("//") ) | 424 if( name.contains("//") ) |
425 return null; | 425 return null; |
426 String path = name; | 426 String path = name; |
427 check(luan,"classpath",path); | 427 check(luan,"classpath:"+path); |
428 URL url; | 428 URL url; |
429 if( !path.contains("#") ) { | 429 if( !path.contains("#") ) { |
430 url = ClassLoader.getSystemResource(path); | 430 url = ClassLoader.getSystemResource(path); |
431 } else { | 431 } else { |
432 String[] a = path.split("#"); | 432 String[] a = path.split("#"); |
593 | 593 |
594 | 594 |
595 // security | 595 // security |
596 | 596 |
597 public interface Security { | 597 public interface Security { |
598 public void check(LuanState luan,String scheme,String name) throws LuanException; | 598 public void check(LuanState luan,String name) throws LuanException; |
599 } | 599 } |
600 | 600 |
601 private static String SECURITY_KEY = "Io.Security"; | 601 private static String SECURITY_KEY = "Io.Security"; |
602 | 602 |
603 private static void check(LuanState luan,String scheme,String name) throws LuanException { | 603 private static void check(LuanState luan,String name) throws LuanException { |
604 Security s = (Security)luan.registry().get(SECURITY_KEY); | 604 Security s = (Security)luan.registry().get(SECURITY_KEY); |
605 if( s!=null ) | 605 if( s!=null ) |
606 s.check(luan,scheme,name); | 606 s.check(luan,name); |
607 } | 607 } |
608 | 608 |
609 public static void setSecurity(LuanState luan,Security s) { | 609 public static void setSecurity(LuanState luan,Security s) { |
610 luan.registry().put(SECURITY_KEY,s); | 610 luan.registry().put(SECURITY_KEY,s); |
611 } | 611 } |