소스 검색

remove spotbugs exclusion for DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED.

jrivard@gmail.com 6 년 전
부모
커밋
db09b29214
2개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      build/spotbugs-exclude.xml
  2. 8 1
      server/src/main/java/password/pwm/util/db/JDBCDriverLoader.java

+ 1 - 1
build/spotbugs-exclude.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <FindBugsFilter>
     <Match>
-        <Bug pattern="SE_NO_SERIALVERSIONID,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED,SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
+        <Bug pattern="SE_NO_SERIALVERSIONID,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
     </Match>
     <Match>
         <!-- due to bug https://github.com/spotbugs/spotbugs/issues/493 in spotbugs 3.1.3 -->

+ 8 - 1
server/src/main/java/password/pwm/util/db/JDBCDriverLoader.java

@@ -41,6 +41,8 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.sql.Driver;
 import java.util.ArrayList;
 import java.util.List;
@@ -149,6 +151,7 @@ public class JDBCDriverLoader
 
         private static final PwmLogger LOGGER = PwmLogger.forClass( XeusJarClassDriverLoader.class, true );
 
+
         @Override
         public Driver loadDriver( final PwmApplication pwmApplication, final DBConfiguration dbConfiguration )
                 throws DatabaseException
@@ -158,7 +161,11 @@ public class JDBCDriverLoader
             try
             {
                 LOGGER.debug( "loading JDBC database driver stored in configuration" );
-                final JarClassLoader jarClassLoader = new JarClassLoader();
+
+                final JarClassLoader jarClassLoader = AccessController.doPrivileged(
+                        ( PrivilegedAction<JarClassLoader> ) JarClassLoader::new
+                );
+
                 jarClassLoader.add( new ByteArrayInputStream( jdbcDriverBytes ) );
                 final JclObjectFactory jclObjectFactory = JclObjectFactory.getInstance( true );