Skip to content

Commit 8491aed

Browse files
committed
minor wordlist import display/debug output enhancements
1 parent 31dc60b commit 8491aed

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void restReadWordlistData( final PwmRequest pwmRequest )
257257
presentableValues.add( new DisplayElement(
258258
wordlistType.name() + "_sha256Hash",
259259
DisplayElement.Type.string,
260-
"SHA1 Checksum",
260+
"SHA256 Checksum",
261261
wordlistStatus.getRemoteInfo().getHash() ) );
262262
}
263263
}

server/src/main/java/password/pwm/svc/wordlist/WordlistImporter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ private enum DebugKey
8181
ImportTime,
8282
EstimatedRemainingTime,
8383
WordsImported,
84+
DiskFreeSpace,
8485
ZipFile,
8586
WordTypes,
8687
WordsPerTxn,
@@ -315,7 +316,6 @@ private void populationComplete( )
315316
{
316317
flushBuffer();
317318
getLogger().info( this::makeStatString );
318-
getLogger().trace( () -> "beginning wordlist size query" );
319319
final long wordlistSize = wordlistBucket.size();
320320

321321
getLogger().info( () -> "population complete, added " + wordlistSize
@@ -416,6 +416,8 @@ private Map<DebugKey, String> makeStatValues()
416416
stats.put( DebugKey.WordsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getWordsPerTransaction().getAverage() ) );
417417
stats.put( DebugKey.CharsPerTxn, PwmNumberFormat.forDefaultLocale().format( (long) importStatistics.getCharsPerTransaction().getAverage() ) );
418418

419+
stats.put( DebugKey.DiskFreeSpace, StringUtil.formatDiskSize( wordlistBucket.spaceRemaining() ) );
420+
419421
if ( bytesSkipped > 0 )
420422
{
421423
stats.put( DebugKey.BytesSkipped, StringUtil.formatDiskSizeforDebug( bytesSkipped ) );

server/src/main/java/password/pwm/util/macro/InternalMacros.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import password.pwm.PwmConstants;
2525
import password.pwm.PwmEnvironment;
2626
import password.pwm.config.PwmSetting;
27+
import password.pwm.config.PwmSettingCategory;
2728
import password.pwm.error.PwmUnrecoverableException;
2829
import password.pwm.http.ContextManager;
2930
import password.pwm.util.java.StringUtil;
@@ -47,6 +48,7 @@ public abstract class InternalMacros
4748
{
4849
final Map<Class<? extends MacroImplementation>, MacroImplementation.Scope> defaultMacros = new HashMap<>();
4950
defaultMacros.put( PwmSettingReference.class, MacroImplementation.Scope.Static );
51+
defaultMacros.put( PwmSettingCategoryReference.class, MacroImplementation.Scope.Static );
5052
defaultMacros.put( PwmAppName.class, MacroImplementation.Scope.Static );
5153
defaultMacros.put( PwmVendorName.class, MacroImplementation.Scope.Static );
5254
defaultMacros.put( PwmContextPath.class, MacroImplementation.Scope.System );
@@ -95,6 +97,32 @@ public String replaceValue( final String matchValue, final MacroRequestInfo macr
9597
}
9698
}
9799

100+
public static class PwmSettingCategoryReference extends InternalAbstractMacro
101+
{
102+
private static final Pattern PATTERN = Pattern.compile( "@PwmSettingCategoryReference" + PATTERN_OPTIONAL_PARAMETER_MATCH + "@" );
103+
104+
public Pattern getRegExPattern( )
105+
{
106+
return PATTERN;
107+
}
108+
109+
public String replaceValue( final String matchValue, final MacroRequestInfo macroRequestInfo )
110+
throws MacroParseException
111+
{
112+
final String settingKeyStr = matchValue.substring( 29, matchValue.length() - 1 );
113+
if ( settingKeyStr.isEmpty() )
114+
{
115+
throw new MacroParseException( "PwmSettingCategoryReference macro requires a setting key value" );
116+
}
117+
final PwmSettingCategory category = PwmSettingCategory.forKey( settingKeyStr );
118+
if ( category == null )
119+
{
120+
throw new MacroParseException( "PwmSettingCategoryReference macro has unknown key value '" + settingKeyStr + "'" );
121+
}
122+
return category.toMenuLocationDebug( null, PwmConstants.DEFAULT_LOCALE );
123+
}
124+
}
125+
98126
public static class PwmContextPath extends InternalAbstractMacro
99127
{
100128
private static final Pattern PATTERN = Pattern.compile( "@PwmContextPath@" );

server/src/main/resources/password/pwm/i18n/Config.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Display_SettingNavigationSeparator=\u0020\u21e8\u0020
6464
Display_SettingNavigationNullProfile=[profile]
6565
Display_RememberLogin=Remember password for %1%.
6666
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>
67+
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.
6768
Label_UserPasswordAttribute=[User Password]
6869
Label_Seedlist=Seed List
6970
Label_Wordlist=Word List

webapp/src/main/webapp/public/resources/js/configmanager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ PWM_CONFIG.initConfigManagerWordlistPage = function() {
356356
var uploadOptions = {};
357357
uploadOptions['url'] = 'wordlists?processAction=uploadWordlist&wordlist=' + type;
358358
uploadOptions['title'] = 'Upload ' + label;
359+
uploadOptions['text'] = PWM_CONFIG.showString('Display_UploadWordlist');
359360
uploadOptions['nextFunction'] = function () {
360361
PWM_MAIN.showDialog({
361362
title: 'Finished', text: 'Upload Completed', okAction: function () {

0 commit comments

Comments
 (0)