Jason Rivard 5 gadi atpakaļ
vecāks
revīzija
c92caf3e79

+ 1 - 4
build/spotbugs-exclude.xml

@@ -26,12 +26,9 @@
     <Match>
         <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
     </Match>
-    <Match>
-        <!-- due to bug https://github.com/spotbugs/spotbugs/issues/493 in spotbugs 3.1.3 -->
-        <Bug pattern="OBL_UNSATISFIED_OBLIGATION"/>
-    </Match>
     <Match>
         <!-- due to bug with java 11 -->
+        <!-- https://github.com/spotbugs/spotbugs/issues/756 -->
         <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
     </Match>
 </FindBugsFilter>

+ 5 - 1
onejar/src/main/java/password/pwm/onejar/ArgumentParser.java

@@ -187,7 +187,11 @@ public class ArgumentParser
                 System.out.println( msg );
                 throw new IllegalStateException( msg );
             }
-            onejarConfig.war( new FileInputStream( inputWarFile ) );
+
+            try ( InputStream inputStream = new FileInputStream( inputWarFile ) )
+            {
+                onejarConfig.war( inputStream );
+            }
         }
         else
         {

+ 1 - 0
pom.xml

@@ -214,6 +214,7 @@
                 <configuration>
                     <source>${maven.compiler.source}</source>
                     <target>${maven.compiler.target}</target>
+                    <showWarnings>true</showWarnings>
                 </configuration>
             </plugin>
             <plugin>

+ 5 - 9
pwm-cr/src/main/java/password/pwm/cr/ChaiXmlResponseSetSerializer.java

@@ -370,17 +370,13 @@ public class ChaiXmlResponseSetSerializer
             return;
         }
 
-        if ( storedChallengeItems != null )
+        for ( final StoredChallengeItem storedChallengeItem : storedChallengeItems )
         {
-            for ( final StoredChallengeItem storedChallengeItem : storedChallengeItems )
-            {
-                final StoredResponseItem storedResponseItem = storedChallengeItem.getAnswer();
-                final String responseElementName = elementNameForType( type );
-                final Element responseElement = challengeToXml( storedChallengeItem, storedResponseItem, responseElementName );
-                parentElement.addContent( responseElement );
-            }
+            final StoredResponseItem storedResponseItem = storedChallengeItem.getAnswer();
+            final String responseElementName = elementNameForType( type );
+            final Element responseElement = challengeToXml( storedChallengeItem, storedResponseItem, responseElementName );
+            parentElement.addContent( responseElement );
         }
-
     }
 
     private static Element challengeToXml(

+ 3 - 2
server/src/main/java/password/pwm/config/value/StringValue.java

@@ -27,6 +27,7 @@ import password.pwm.config.stored.StoredConfigXmlConstants;
 import password.pwm.config.stored.XmlOutputProcessData;
 import password.pwm.config.value.data.FormConfiguration;
 import password.pwm.util.java.JsonUtil;
+import password.pwm.util.java.StringUtil;
 import password.pwm.util.java.XmlElement;
 import password.pwm.util.java.XmlFactory;
 import password.pwm.util.secure.PwmSecurityKey;
@@ -86,14 +87,14 @@ public class StringValue extends AbstractValue implements StoredValue
     {
         if ( pwmSetting.isRequired() )
         {
-            if ( value == null || value.length() < 1 )
+            if ( StringUtil.isEmpty( value ) )
             {
                 return Collections.singletonList( "required value missing" );
             }
         }
 
         final Pattern pattern = pwmSetting.getRegExPattern();
-        if ( pattern != null && value != null )
+        if ( pattern != null )
         {
             final Matcher matcher = pattern.matcher( value );
             if ( value != null && value.length() > 0 && !matcher.matches() )

+ 9 - 7
server/src/main/java/password/pwm/config/value/data/CustomLinkConfiguration.java

@@ -20,6 +20,7 @@
 
 package password.pwm.config.value.data;
 
+import lombok.EqualsAndHashCode;
 import lombok.Value;
 import password.pwm.util.i18n.LocaleHelper;
 import password.pwm.util.java.JsonUtil;
@@ -33,6 +34,7 @@ import java.util.Map;
  * @author Richard A. Keil
  */
 @Value
+@EqualsAndHashCode( callSuper = false )
 public class CustomLinkConfiguration implements Serializable
 {
 
@@ -41,13 +43,13 @@ public class CustomLinkConfiguration implements Serializable
         text, url, select, checkbox, customLink
     }
 
-    private String name;
-    private Type type = Type.customLink;
-    private Map<String, String> labels = Collections.singletonMap( "", "" );
-    private Map<String, String> description = Collections.singletonMap( "", "" );
-    private String customLinkUrl = "";
-    private boolean customLinkNewWindow;
-    private Map<String, String> selectOptions = Collections.emptyMap();
+    private final String name;
+    private final Type type = Type.customLink;
+    private final Map<String, String> labels = Collections.singletonMap( "", "" );
+    private final Map<String, String> description = Collections.singletonMap( "", "" );
+    private final String customLinkUrl = "";
+    private final boolean customLinkNewWindow;
+    private final Map<String, String> selectOptions = Collections.emptyMap();
 
     public String getLabel( final Locale locale )
     {

+ 7 - 1
server/src/main/java/password/pwm/http/ContextManager.java

@@ -446,7 +446,13 @@ public class ContextManager implements Serializable
                     try
                     {
                         final PropertyConfigurationImporter importer = new PropertyConfigurationImporter();
-                        final StoredConfiguration storedConfiguration = importer.readConfiguration( new FileInputStream( silentPropertiesFile ) );
+
+                        final StoredConfiguration storedConfiguration;
+                        try ( InputStream fileInputStream = new FileInputStream( silentPropertiesFile ) )
+                        {
+                            storedConfiguration = importer.readConfiguration( fileInputStream );
+                        }
+
                         configReader.saveConfiguration( storedConfiguration, pwmApplication, SESSION_LABEL );
                         LOGGER.info( SESSION_LABEL, () -> "file " + silentPropertiesFile.getAbsolutePath() + " has been successfully imported and saved as configuration file" );
                         requestPwmApplicationRestart();

+ 1 - 1
server/src/main/java/password/pwm/svc/wordlist/WordlistInspector.java

@@ -321,7 +321,7 @@ class WordlistInspector implements Runnable
         boolean needsAutoImport = false;
         if ( remoteInfo == null )
         {
-            getLogger().warn( () -> "can't read remote wordlist data from url " + rootWordlist.getConfiguration().getAutoImportUrl() );
+            getLogger().warn( () -> "can not read remote wordlist data from url " + rootWordlist.getConfiguration().getAutoImportUrl() );
         }
         else
         {

+ 2 - 2
server/src/main/java/password/pwm/util/cli/commands/ImportPropertyConfigCommand.java

@@ -50,10 +50,10 @@ public class ImportPropertyConfigCommand extends AbstractCliCommand
 
         final File inputFile = ( File ) cliEnvironment.getOptions().get( CliParameters.REQUIRED_EXISTING_INPUT_FILE.getName() );
 
-        try
+        try ( FileInputStream fileInputStream = new FileInputStream( inputFile ) )
         {
             final PropertyConfigurationImporter importer = new PropertyConfigurationImporter();
-            final StoredConfiguration storedConfiguration = importer.readConfiguration( new FileInputStream( inputFile ) );
+            final StoredConfiguration storedConfiguration = importer.readConfiguration( fileInputStream );
 
             try ( OutputStream outputStream = new FileOutputStream( configFile ) )
             {