浏览代码

minor wordlist import display/debug output enhancements

Jason Rivard 5 年之前
父节点
当前提交
8491aed616

+ 1 - 1
server/src/main/java/password/pwm/http/servlet/configmanager/ConfigManagerWordlistServlet.java

@@ -257,7 +257,7 @@ public class ConfigManagerWordlistServlet extends AbstractPwmServlet
                         presentableValues.add( new DisplayElement(
                         presentableValues.add( new DisplayElement(
                                 wordlistType.name() + "_sha256Hash",
                                 wordlistType.name() + "_sha256Hash",
                                 DisplayElement.Type.string,
                                 DisplayElement.Type.string,
-                                "SHA1 Checksum",
+                                "SHA256 Checksum",
                                 wordlistStatus.getRemoteInfo().getHash() ) );
                                 wordlistStatus.getRemoteInfo().getHash() ) );
                     }
                     }
                 }
                 }

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

@@ -81,6 +81,7 @@ class WordlistImporter implements Runnable
         ImportTime,
         ImportTime,
         EstimatedRemainingTime,
         EstimatedRemainingTime,
         WordsImported,
         WordsImported,
+        DiskFreeSpace,
         ZipFile,
         ZipFile,
         WordTypes,
         WordTypes,
         WordsPerTxn,
         WordsPerTxn,
@@ -315,7 +316,6 @@ class WordlistImporter implements Runnable
     {
     {
         flushBuffer();
         flushBuffer();
         getLogger().info( this::makeStatString );
         getLogger().info( this::makeStatString );
-        getLogger().trace( () -> "beginning wordlist size query" );
         final long wordlistSize = wordlistBucket.size();
         final long wordlistSize = wordlistBucket.size();
 
 
         getLogger().info( () -> "population complete, added " + wordlistSize
         getLogger().info( () -> "population complete, added " + wordlistSize
@@ -416,6 +416,8 @@ class WordlistImporter implements Runnable
         stats.put( DebugKey.WordsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getWordsPerTransaction().getAverage() ) );
         stats.put( DebugKey.WordsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getWordsPerTransaction().getAverage() ) );
         stats.put( DebugKey.CharsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getCharsPerTransaction().getAverage() ) );
         stats.put( DebugKey.CharsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getCharsPerTransaction().getAverage() ) );
 
 
+        stats.put( DebugKey.DiskFreeSpace, StringUtil.formatDiskSize( wordlistBucket.spaceRemaining() ) );
+
         if ( bytesSkipped > 0 )
         if ( bytesSkipped > 0 )
         {
         {
             stats.put( DebugKey.BytesSkipped, StringUtil.formatDiskSizeforDebug( bytesSkipped ) );
             stats.put( DebugKey.BytesSkipped, StringUtil.formatDiskSizeforDebug( bytesSkipped ) );

+ 28 - 0
server/src/main/java/password/pwm/util/macro/InternalMacros.java

@@ -24,6 +24,7 @@ import password.pwm.PwmApplication;
 import password.pwm.PwmConstants;
 import password.pwm.PwmConstants;
 import password.pwm.PwmEnvironment;
 import password.pwm.PwmEnvironment;
 import password.pwm.config.PwmSetting;
 import password.pwm.config.PwmSetting;
+import password.pwm.config.PwmSettingCategory;
 import password.pwm.error.PwmUnrecoverableException;
 import password.pwm.error.PwmUnrecoverableException;
 import password.pwm.http.ContextManager;
 import password.pwm.http.ContextManager;
 import password.pwm.util.java.StringUtil;
 import password.pwm.util.java.StringUtil;
@@ -47,6 +48,7 @@ public abstract class InternalMacros
     {
     {
         final Map<Class<? extends MacroImplementation>, MacroImplementation.Scope> defaultMacros = new HashMap<>();
         final Map<Class<? extends MacroImplementation>, MacroImplementation.Scope> defaultMacros = new HashMap<>();
         defaultMacros.put( PwmSettingReference.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmSettingReference.class, MacroImplementation.Scope.Static );
+        defaultMacros.put( PwmSettingCategoryReference.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmAppName.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmAppName.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmVendorName.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmVendorName.class, MacroImplementation.Scope.Static );
         defaultMacros.put( PwmContextPath.class, MacroImplementation.Scope.System );
         defaultMacros.put( PwmContextPath.class, MacroImplementation.Scope.System );
@@ -95,6 +97,32 @@ public abstract class InternalMacros
         }
         }
     }
     }
 
 
+    public static class PwmSettingCategoryReference extends InternalAbstractMacro
+    {
+        private static final Pattern PATTERN = Pattern.compile( "@PwmSettingCategoryReference" + PATTERN_OPTIONAL_PARAMETER_MATCH + "@" );
+
+        public Pattern getRegExPattern( )
+        {
+            return PATTERN;
+        }
+
+        public String replaceValue( final String matchValue, final MacroRequestInfo macroRequestInfo )
+                throws MacroParseException
+        {
+            final String settingKeyStr = matchValue.substring( 29, matchValue.length() - 1 );
+            if ( settingKeyStr.isEmpty() )
+            {
+                throw new MacroParseException( "PwmSettingCategoryReference macro requires a setting key value" );
+            }
+            final PwmSettingCategory category = PwmSettingCategory.forKey( settingKeyStr );
+            if ( category == null )
+            {
+                throw new MacroParseException( "PwmSettingCategoryReference macro has unknown key value '" + settingKeyStr + "'" );
+            }
+            return category.toMenuLocationDebug( null, PwmConstants.DEFAULT_LOCALE );
+        }
+    }
+
     public static class PwmContextPath extends InternalAbstractMacro
     public static class PwmContextPath extends InternalAbstractMacro
     {
     {
         private static final Pattern PATTERN = Pattern.compile( "@PwmContextPath@" );
         private static final Pattern PATTERN = Pattern.compile( "@PwmContextPath@" );

+ 1 - 0
server/src/main/resources/password/pwm/i18n/Config.properties

@@ -64,6 +64,7 @@ Display_SettingNavigationSeparator=\u0020\u21e8\u0020
 Display_SettingNavigationNullProfile=[profile]
 Display_SettingNavigationNullProfile=[profile]
 Display_RememberLogin=Remember password for %1%.
 Display_RememberLogin=Remember password for %1%.
 Display_ProfileNamingRules=<p>Profile names have the following requirements\:</p><ul><li>Start with a letter (a-Z)</li><li>Contain only letters, numbers and hyphens</li><li>Length between 2 and 15 characters</li></ul>
 Display_ProfileNamingRules=<p>Profile names have the following requirements\:</p><ul><li>Start with a letter (a-Z)</li><li>Contain only letters, numbers and hyphens</li><li>Length between 2 and 15 characters</li></ul>
+Display_UploadWordlist=This direct upload process should only be used for test purposes.  For non-test purposes, use the settings at @PwmSettingCategoryReference:WORDLISTS@ to configure automatic import and updates of the word list.<br/><br/>Word lists uploaded here are subject to be cleared during software updates, configuration changes and other events.
 Label_UserPasswordAttribute=[User Password]
 Label_UserPasswordAttribute=[User Password]
 Label_Seedlist=Seed List
 Label_Seedlist=Seed List
 Label_Wordlist=Word List
 Label_Wordlist=Word List

+ 1 - 0
webapp/src/main/webapp/public/resources/js/configmanager.js

@@ -356,6 +356,7 @@ PWM_CONFIG.initConfigManagerWordlistPage = function() {
         var uploadOptions = {};
         var uploadOptions = {};
         uploadOptions['url'] = 'wordlists?processAction=uploadWordlist&wordlist=' + type;
         uploadOptions['url'] = 'wordlists?processAction=uploadWordlist&wordlist=' + type;
         uploadOptions['title'] = 'Upload ' + label;
         uploadOptions['title'] = 'Upload ' + label;
+        uploadOptions['text'] = PWM_CONFIG.showString('Display_UploadWordlist');
         uploadOptions['nextFunction'] = function () {
         uploadOptions['nextFunction'] = function () {
             PWM_MAIN.showDialog({
             PWM_MAIN.showDialog({
                 title: 'Finished', text: 'Upload Completed', okAction: function () {
                 title: 'Finished', text: 'Upload Completed', okAction: function () {