Skip to content

Commit

Permalink
handling for jvmversion 21, setting security manager now in ServerSid…
Browse files Browse the repository at this point in the history
…eUtils
  • Loading branch information
dvayanu committed Jan 24, 2024
1 parent c24d1b7 commit 6ace331
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,8 @@ public void generate(TypeElement type, Filer filer, Map<String,String> options)
writeString("public static void main(String a[]) throws Exception{");
increaseIdent();

writeCommentLine("//for jvm version >17 we do not work with security manager, as its been deprecated");
writeStatement("String jvmVersion = System.getProperty(\"java.version\")");
writeStatement("boolean doSetSecurityManager = false");
writeStatement("int jvmVersionNumber = Integer.parseInt(jvmVersion.substring(0, jvmVersion.indexOf('.')))");
writeStatement("doSetSecurityManager = jvmVersionNumber < 17");


writeString("if (doSetSecurityManager){");
increaseIdent();
writeString("if (System.getSecurityManager()==null)");
increaseIdent();
writeCommentLine("We allow all operations.");
writeString("System.setSecurityManager(new SecurityManager(){");
writeIncreasedString("public void checkPermission(Permission perm) { }");
writeStatement("})");
decreaseIdent();
closeBlock("if doSetSecurityManager");
writeCommentLine("the security manager decision and setting is now done by server side utils");
writeStatement("org.distributeme.core.util.ServerSideUtils.setSecurityManagerIfRequired()");
emptyline();

writeString("try {");
Expand Down

0 comments on commit 6ace331

Please sign in to comment.