use of org.jruby.embed.ScriptingContainer in project zeppelin by apache.
the class HbaseInterpreter method open.
@Override
public void open() {
this.scriptingContainer = new ScriptingContainer(LocalContextScope.SINGLETON);
this.writer = new StringWriter();
scriptingContainer.setOutput(this.writer);
if (!Boolean.parseBoolean(getProperty(HBASE_TEST_MODE))) {
String hbase_home = getProperty(HBASE_HOME);
String ruby_src = getProperty(HBASE_RUBY_SRC);
Path abs_ruby_src = Paths.get(hbase_home, ruby_src).toAbsolutePath();
logger.info("Home:" + hbase_home);
logger.info("Ruby Src:" + ruby_src);
File f = abs_ruby_src.toFile();
if (!f.exists() || !f.isDirectory()) {
throw new InterpreterException("HBase ruby sources is not available at '" + abs_ruby_src + "'");
}
logger.info("Absolute Ruby Source:" + abs_ruby_src.toString());
// hirb.rb:41 requires the following system property to be set.
Properties sysProps = System.getProperties();
sysProps.setProperty(HBASE_RUBY_SRC, abs_ruby_src.toString());
Path abs_hirb_path = Paths.get(hbase_home, "bin/hirb.rb");
try {
FileInputStream fis = new FileInputStream(abs_hirb_path.toFile());
this.scriptingContainer.runScriptlet(fis, "hirb.rb");
fis.close();
} catch (IOException e) {
throw new InterpreterException(e.getCause());
}
}
}
use of org.jruby.embed.ScriptingContainer in project sass-java by darrinholst.
the class Compiler method compile.
public void compile() {
initialize();
new ScriptingContainer().runScriptlet(buildCompileScript());
}
use of org.jruby.embed.ScriptingContainer in project sass-java by darrinholst.
the class Compiler method initialize.
private void initialize() {
if (!initialized) {
new ScriptingContainer().runScriptlet(buildInitializationScript());
initialized = true;
}
}
use of org.jruby.embed.ScriptingContainer in project spring-security-oauth by spring-projects.
the class RubyJwtIntegrationTests method canDecodeRubyHmacSignedToken.
@Test
public void canDecodeRubyHmacSignedToken() throws Exception {
ScriptingContainer container = new ScriptingContainer();
container.put("@token", "xxx");
String script = "require \"jwt\"\n" + "@token = JWT.encode({\"some\" => \"payload\"}, \"secret\", \"HS256\")\n" + "puts @token";
container.runScriptlet(script);
String token = (String) container.get("@token");
Jwt jwt = JwtHelper.decodeAndVerify(token, hmac);
assertEquals(TEST_CLAIMS, jwt.getClaims());
container.terminate();
}
use of org.jruby.embed.ScriptingContainer in project spring-security-oauth by spring-projects.
the class RubyJwtIntegrationTests method rubyCanDecodeHmacSignedToken.
@Test
public void rubyCanDecodeHmacSignedToken() throws Exception {
Jwt jwt = JwtHelper.encode(TEST_CLAIMS, hmac);
ScriptingContainer container = new ScriptingContainer();
container.put("@token", jwt.getEncoded());
container.put("@claims", "");
String script = "require \"jwt\"\n" + "@claims = JWT.decode(@token, \"secret\", \"HS256\")[0].to_json\n" + "puts @claims";
container.runScriptlet(script);
assertEquals(TEST_CLAIMS, container.get("@claims"));
}
Aggregations