Mercurial Hosting > luan
comparison src/luan/Luan.java @ 1330:f41919741100
fix security
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 11 Feb 2019 01:38:55 -0700 |
parents | 9fa8b8389578 |
children | 25746915a241 |
comparison
equal
deleted
inserted
replaced
1329:5a39b006acd1 | 1330:f41919741100 |
---|---|
200 Utils.checkNotNull(v); | 200 Utils.checkNotNull(v); |
201 return v; | 201 return v; |
202 } | 202 } |
203 */ | 203 */ |
204 | 204 |
205 | |
206 | |
207 // security | |
208 | |
209 public interface Security { | |
210 public void check(LuanState luan,LuanClosure closure,String op,Object... args) throws LuanException; | |
211 } | |
212 | |
213 private static String SECURITY_KEY = "Luan.Security"; | |
214 | |
215 public static void checkSecurity(LuanState luan,String op,Object... args) throws LuanException { | |
216 check(luan,1,op,args); | |
217 } | |
218 | |
219 public static void checkCallerSecurity(LuanState luan,String op,Object... args) throws LuanException { | |
220 check(luan,2,op,args); | |
221 } | |
222 | |
223 private static void check(LuanState luan,int i,String op,Object... args) throws LuanException { | |
224 Security s = (Security)luan.registry().get(SECURITY_KEY); | |
225 if( s!=null ) | |
226 s.check(luan,luan.peek(),op,args); | |
227 } | |
228 | |
229 public static Security setSecurity(LuanState luan,Security s) { | |
230 return (Security)luan.registry().put(SECURITY_KEY,s); | |
231 } | |
232 | |
233 | |
205 private Luan() {} // never | 234 private Luan() {} // never |
206 } | 235 } |