Commit 72453499afc45bd8d71a6f26942d65440065691f
1 parent
0d5f09a9
Remove security manager after nosql test completion.
Showing
3 changed files
with
1 additions
and
80 deletions
... | ... | @@ -28,14 +28,6 @@ import java.util.Arrays; |
28 | 28 | "org.thingsboard.server.rules.lifecycle.sql.*Test"}) |
29 | 29 | public class RuleEngineSqlTestSuite { |
30 | 30 | |
31 | - static { | |
32 | - SecurityManager appsm = System.getSecurityManager(); | |
33 | - System.out.println("SECURITY MANAGER = " + appsm); | |
34 | - if (appsm != null) { | |
35 | - System.out.println("SECURITY MANAGER CLASS = " + appsm.getClass()); | |
36 | - } | |
37 | - } | |
38 | - | |
39 | 31 | @ClassRule |
40 | 32 | public static CustomSqlUnit sqlUnit = new CustomSqlUnit( |
41 | 33 | Arrays.asList("sql/schema-ts.sql", "sql/schema-entities.sql", "sql/system-data.sql"), | ... | ... |
... | ... | @@ -15,21 +15,11 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.system; |
17 | 17 | |
18 | -import net.bytebuddy.asm.AsmVisitorWrapper; | |
19 | -import net.bytebuddy.asm.MemberSubstitution; | |
20 | -import net.bytebuddy.matcher.ElementMatchers; | |
21 | -import org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager; | |
22 | -import org.hibernate.HibernateException; | |
23 | -import org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState; | |
24 | -import org.hibernate.bytecode.internal.bytebuddy.HibernateMethodLookupDispatcher; | |
25 | 18 | import org.junit.ClassRule; |
26 | 19 | import org.junit.extensions.cpsuite.ClasspathSuite; |
27 | 20 | import org.junit.runner.RunWith; |
28 | 21 | import org.thingsboard.server.dao.CustomSqlUnit; |
29 | 22 | |
30 | -import java.lang.reflect.Method; | |
31 | -import java.security.AccessController; | |
32 | -import java.security.PrivilegedAction; | |
33 | 23 | import java.util.Arrays; |
34 | 24 | |
35 | 25 | /** |
... | ... | @@ -46,68 +36,6 @@ public class SystemSqlTestSuite { |
46 | 36 | if (appsm != null) { |
47 | 37 | System.out.println("SECURITY MANAGER CLASS = " + appsm.getClass()); |
48 | 38 | } |
49 | - | |
50 | - AsmVisitorWrapper.ForDeclaredMethods getDeclaredMethodMemberSubstitution; | |
51 | - AsmVisitorWrapper.ForDeclaredMethods getMethodMemberSubstitution; | |
52 | - | |
53 | - //if ( System.getSecurityManager() != null ) { | |
54 | - getDeclaredMethodMemberSubstitution = getDeclaredMethodMemberSubstitution(); | |
55 | - getMethodMemberSubstitution = getMethodMemberSubstitution(); | |
56 | - //} | |
57 | - //else { | |
58 | - // getDeclaredMethodMemberSubstitution = null; | |
59 | - // getMethodMemberSubstitution = null; | |
60 | - //} | |
61 | - | |
62 | - System.out.println("getDeclaredMethodMemberSubstitution = " + getDeclaredMethodMemberSubstitution); | |
63 | - System.out.println("getMethodMemberSubstitution = " + getMethodMemberSubstitution); | |
64 | - } | |
65 | - | |
66 | - private static class GetDeclaredMethodAction implements PrivilegedAction<Method> { | |
67 | - private final Class<?> clazz; | |
68 | - private final String methodName; | |
69 | - private final Class<?>[] parameterTypes; | |
70 | - | |
71 | - private GetDeclaredMethodAction(Class<?> clazz, String methodName, Class<?>... parameterTypes) { | |
72 | - this.clazz = clazz; | |
73 | - this.methodName = methodName; | |
74 | - this.parameterTypes = parameterTypes; | |
75 | - } | |
76 | - | |
77 | - @Override | |
78 | - public Method run() { | |
79 | - try { | |
80 | - Method method = clazz.getDeclaredMethod( methodName, parameterTypes ); | |
81 | - | |
82 | - return method; | |
83 | - } | |
84 | - catch (NoSuchMethodException e) { | |
85 | - throw new HibernateException( "Unable to prepare getDeclaredMethod()/getMethod() substitution", e ); | |
86 | - } | |
87 | - } | |
88 | - } | |
89 | - | |
90 | - | |
91 | - private static AsmVisitorWrapper.ForDeclaredMethods getDeclaredMethodMemberSubstitution() { | |
92 | - // this should only be called if the security manager is enabled, thus the privileged calls | |
93 | - return MemberSubstitution.relaxed() | |
94 | - .method( ElementMatchers.is( AccessController.doPrivileged( new SystemSqlTestSuite.GetDeclaredMethodAction( Class.class, | |
95 | - "getDeclaredMethod", String.class, Class[].class ) ) ) ) | |
96 | - .replaceWith( | |
97 | - AccessController.doPrivileged( new SystemSqlTestSuite.GetDeclaredMethodAction( HibernateMethodLookupDispatcher.class, | |
98 | - "getDeclaredMethod", Class.class, String.class, Class[].class ) ) ) | |
99 | - .on( ElementMatchers.isTypeInitializer() ); | |
100 | - } | |
101 | - | |
102 | - private static AsmVisitorWrapper.ForDeclaredMethods getMethodMemberSubstitution() { | |
103 | - // this should only be called if the security manager is enabled, thus the privileged calls | |
104 | - return MemberSubstitution.relaxed() | |
105 | - .method( ElementMatchers.is( AccessController.doPrivileged( new SystemSqlTestSuite.GetDeclaredMethodAction( Class.class, | |
106 | - "getMethod", String.class, Class[].class ) ) ) ) | |
107 | - .replaceWith( | |
108 | - AccessController.doPrivileged( new SystemSqlTestSuite.GetDeclaredMethodAction( HibernateMethodLookupDispatcher.class, | |
109 | - "getMethod", Class.class, String.class, Class[].class ) ) ) | |
110 | - .on( ElementMatchers.isTypeInitializer() ); | |
111 | 39 | } |
112 | 40 | |
113 | 41 | @ClassRule | ... | ... |