|
@@ -21,8 +21,6 @@
|
|
package password.pwm.http.servlet.configeditor.data;
|
|
package password.pwm.http.servlet.configeditor.data;
|
|
|
|
|
|
import password.pwm.PwmConstants;
|
|
import password.pwm.PwmConstants;
|
|
-import password.pwm.PwmDomain;
|
|
|
|
-import password.pwm.PwmEnvironment;
|
|
|
|
import password.pwm.bean.DomainID;
|
|
import password.pwm.bean.DomainID;
|
|
import password.pwm.config.AppConfig;
|
|
import password.pwm.config.AppConfig;
|
|
import password.pwm.config.PwmSetting;
|
|
import password.pwm.config.PwmSetting;
|
|
@@ -51,6 +49,7 @@ import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.ResourceBundle;
|
|
import java.util.ResourceBundle;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Utility class for generating {@link NavTreeItem}s suitable for display in the
|
|
* Utility class for generating {@link NavTreeItem}s suitable for display in the
|
|
@@ -65,7 +64,7 @@ public class NavTreeDataMaker
|
|
private static final String DISPLAY_TEXT_NAME = "Display Text";
|
|
private static final String DISPLAY_TEXT_NAME = "Display Text";
|
|
|
|
|
|
public static List<NavTreeItem> makeNavTreeItems(
|
|
public static List<NavTreeItem> makeNavTreeItems(
|
|
- final PwmDomain pwmDomain,
|
|
|
|
|
|
+ final DomainID domainID,
|
|
final StoredConfiguration storedConfiguration,
|
|
final StoredConfiguration storedConfiguration,
|
|
final NavTreeSettings navTreeSettings
|
|
final NavTreeSettings navTreeSettings
|
|
)
|
|
)
|
|
@@ -77,10 +76,10 @@ public class NavTreeDataMaker
|
|
navigationData.add( makeRootNode() );
|
|
navigationData.add( makeRootNode() );
|
|
|
|
|
|
// add setting nodes
|
|
// add setting nodes
|
|
- navigationData.addAll( makeSettingNavItems( pwmDomain, storedConfiguration, navTreeSettings ) );
|
|
|
|
|
|
+ navigationData.addAll( makeCategoryNavItems( domainID, storedConfiguration, navTreeSettings ) );
|
|
|
|
|
|
// add display text nodes
|
|
// add display text nodes
|
|
- navigationData.addAll( makeDisplayTextNavItems( pwmDomain, storedConfiguration, navTreeSettings ) );
|
|
|
|
|
|
+ navigationData.addAll( makeDisplayTextNavItems( domainID, storedConfiguration, navTreeSettings ) );
|
|
|
|
|
|
NavTreeDataMaker.moveNavItemToTopOfList( PwmSettingCategory.NOTES.toString(), navigationData );
|
|
NavTreeDataMaker.moveNavItemToTopOfList( PwmSettingCategory.NOTES.toString(), navigationData );
|
|
NavTreeDataMaker.moveNavItemToTopOfList( PwmSettingCategory.TEMPLATES.toString(), navigationData );
|
|
NavTreeDataMaker.moveNavItemToTopOfList( PwmSettingCategory.TEMPLATES.toString(), navigationData );
|
|
@@ -100,13 +99,13 @@ public class NavTreeDataMaker
|
|
}
|
|
}
|
|
|
|
|
|
private static List<NavTreeItem> makeDisplayTextNavItems(
|
|
private static List<NavTreeItem> makeDisplayTextNavItems(
|
|
- final PwmDomain pwmDomain,
|
|
|
|
|
|
+ final DomainID domainId,
|
|
final StoredConfiguration storedConfiguration,
|
|
final StoredConfiguration storedConfiguration,
|
|
final NavTreeSettings navTreeSettings
|
|
final NavTreeSettings navTreeSettings
|
|
)
|
|
)
|
|
{
|
|
{
|
|
final DomainID domainID = navTreeSettings.getDomainManageMode() == DomainManageMode.domain
|
|
final DomainID domainID = navTreeSettings.getDomainManageMode() == DomainManageMode.domain
|
|
- ? pwmDomain.getDomainID()
|
|
|
|
|
|
+ ? domainId
|
|
: DomainID.systemId();
|
|
: DomainID.systemId();
|
|
|
|
|
|
return makeDisplayTextNavItemsForDomain( domainID, storedConfiguration, navTreeSettings );
|
|
return makeDisplayTextNavItemsForDomain( domainID, storedConfiguration, navTreeSettings );
|
|
@@ -204,80 +203,87 @@ public class NavTreeDataMaker
|
|
/**
|
|
/**
|
|
* Produces a collection of {@code NavTreeItem}.
|
|
* Produces a collection of {@code NavTreeItem}.
|
|
*/
|
|
*/
|
|
- private static List<NavTreeItem> makeSettingNavItems(
|
|
|
|
- final PwmDomain pwmDomain,
|
|
|
|
|
|
+ private static List<NavTreeItem> makeCategoryNavItems(
|
|
|
|
+ final DomainID domainId,
|
|
|
|
+ final StoredConfiguration storedConfiguration,
|
|
|
|
+ final NavTreeSettings navTreeSettings
|
|
|
|
+ )
|
|
|
|
+ {
|
|
|
|
+ return PwmSettingCategory.sortedValues().stream()
|
|
|
|
+ .filter( loopCategory -> categoryMatcher( domainId, loopCategory, null, storedConfiguration, navTreeSettings ) )
|
|
|
|
+ .flatMap( loopCategory -> navTreeItemsForCategory( loopCategory, domainId, storedConfiguration, navTreeSettings ).stream() )
|
|
|
|
+ .collect( Collectors.toUnmodifiableList() );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static List<NavTreeItem> navTreeItemsForCategory(
|
|
|
|
+ final PwmSettingCategory loopCategory,
|
|
|
|
+ final DomainID domainId,
|
|
final StoredConfiguration storedConfiguration,
|
|
final StoredConfiguration storedConfiguration,
|
|
final NavTreeSettings navTreeSettings
|
|
final NavTreeSettings navTreeSettings
|
|
)
|
|
)
|
|
{
|
|
{
|
|
final Locale locale = navTreeSettings.getLocale();
|
|
final Locale locale = navTreeSettings.getLocale();
|
|
- final List<NavTreeItem> navigationData = new ArrayList<>();
|
|
|
|
|
|
|
|
- for ( final PwmSettingCategory loopCategory : PwmSettingCategory.sortedValues() )
|
|
|
|
|
|
+ if ( !loopCategory.hasProfiles() )
|
|
{
|
|
{
|
|
- if ( !loopCategory.hasProfiles() )
|
|
|
|
- {
|
|
|
|
- // regular category, so output a standard nav tree item
|
|
|
|
- if ( categoryMatcher( pwmDomain, loopCategory, null, storedConfiguration, navTreeSettings ) )
|
|
|
|
- {
|
|
|
|
- navigationData.add( navTreeItemForCategory( loopCategory, locale, null ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- final List<String> profiles = StoredConfigurationUtil.profilesForCategory( pwmDomain.getDomainID(), loopCategory, storedConfiguration );
|
|
|
|
|
|
+ // regular category, so output a standard nav tree item
|
|
|
|
+ return List.of( navTreeItemForCategory( loopCategory, locale, null ) );
|
|
|
|
+ }
|
|
|
|
|
|
- if ( loopCategory.isTopLevelProfile() )
|
|
|
|
- {
|
|
|
|
- // edit profile option
|
|
|
|
- navigationData.add( navTreeItemForCategory( loopCategory, locale, null ) );
|
|
|
|
|
|
+ final List<String> profiles = StoredConfigurationUtil.profilesForCategory( domainId, loopCategory, storedConfiguration );
|
|
|
|
+ if ( loopCategory.isTopLevelProfile() )
|
|
|
|
+ {
|
|
|
|
+ final List<NavTreeItem> navigationData = new ArrayList<>();
|
|
|
|
|
|
- {
|
|
|
|
- final String editItemName = LocaleHelper.getLocalizedMessage( locale, Config.Label_ProfileListEditMenuItem, null );
|
|
|
|
- final PwmSetting profileSetting = loopCategory.getProfileSetting().orElseThrow( IllegalStateException::new );
|
|
|
|
-
|
|
|
|
- final NavTreeItem profileEditorInfo = NavTreeItem.builder()
|
|
|
|
- .id( loopCategory.getKey() + "-EDITOR" )
|
|
|
|
- .name( editItemName )
|
|
|
|
- .type( NavTreeItem.NavItemType.profileDefinition )
|
|
|
|
- .profileSetting( profileSetting.getKey() )
|
|
|
|
- .parent( loopCategory.getKey() )
|
|
|
|
- .build();
|
|
|
|
- navigationData.add( profileEditorInfo );
|
|
|
|
- }
|
|
|
|
|
|
+ // edit profile option
|
|
|
|
+ navigationData.add( navTreeItemForCategory( loopCategory, locale, null ) );
|
|
|
|
|
|
- for ( final String profileId : profiles )
|
|
|
|
- {
|
|
|
|
- final NavTreeItem.NavItemType type = !loopCategory.hasChildren()
|
|
|
|
- ? NavTreeItem.NavItemType.category
|
|
|
|
- : NavTreeItem.NavItemType.navigation;
|
|
|
|
-
|
|
|
|
- final NavTreeItem profileInfo = navTreeItemForCategory( loopCategory, locale, profileId ).toBuilder()
|
|
|
|
- .name( profileId.isEmpty() ? "Default" : profileId )
|
|
|
|
- .id( "profile-" + loopCategory.getKey() + "-" + profileId )
|
|
|
|
- .parent( loopCategory.getKey() )
|
|
|
|
- .type( type )
|
|
|
|
- .build();
|
|
|
|
|
|
+ {
|
|
|
|
+ final String editItemName = LocaleHelper.getLocalizedMessage( locale, Config.Label_ProfileListEditMenuItem, null );
|
|
|
|
+ final PwmSetting profileSetting = loopCategory.getProfileSetting().orElseThrow( IllegalStateException::new );
|
|
|
|
+
|
|
|
|
+ final NavTreeItem profileEditorInfo = NavTreeItem.builder()
|
|
|
|
+ .id( loopCategory.getKey() + "-EDITOR" )
|
|
|
|
+ .name( editItemName )
|
|
|
|
+ .type( NavTreeItem.NavItemType.profileDefinition )
|
|
|
|
+ .profileSetting( profileSetting.getKey() )
|
|
|
|
+ .parent( loopCategory.getKey() )
|
|
|
|
+ .build();
|
|
|
|
+ navigationData.add( profileEditorInfo );
|
|
|
|
+ }
|
|
|
|
|
|
- navigationData.add( profileInfo );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- for ( final String profileId : profiles )
|
|
|
|
- {
|
|
|
|
- if ( categoryMatcher( pwmDomain, loopCategory, profileId, storedConfiguration, navTreeSettings ) )
|
|
|
|
- {
|
|
|
|
- navigationData.add( navTreeItemForCategory( loopCategory, locale, profileId ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ for ( final String profileId : profiles )
|
|
|
|
+ {
|
|
|
|
+ final NavTreeItem.NavItemType type = !loopCategory.hasChildren()
|
|
|
|
+ ? NavTreeItem.NavItemType.category
|
|
|
|
+ : NavTreeItem.NavItemType.navigation;
|
|
|
|
+
|
|
|
|
+ final NavTreeItem profileInfo = navTreeItemForCategory( loopCategory, locale, profileId ).toBuilder()
|
|
|
|
+ .name( profileId.isEmpty() ? "Default" : profileId )
|
|
|
|
+ .id( "profile-" + loopCategory.getKey() + "-" + profileId )
|
|
|
|
+ .parent( loopCategory.getKey() )
|
|
|
|
+ .type( type )
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ navigationData.add( profileInfo );
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return Collections.unmodifiableList( navigationData );
|
|
}
|
|
}
|
|
|
|
|
|
- return navigationData;
|
|
|
|
|
|
+ final List<NavTreeItem> navigationData = new ArrayList<>();
|
|
|
|
+ for ( final String profileId : profiles )
|
|
|
|
+ {
|
|
|
|
+ if ( categoryMatcher( domainId, loopCategory, profileId, storedConfiguration, navTreeSettings ) )
|
|
|
|
+ {
|
|
|
|
+ navigationData.add( navTreeItemForCategory( loopCategory, locale, profileId ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Collections.unmodifiableList( navigationData );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private static NavTreeItem navTreeItemForCategory(
|
|
private static NavTreeItem navTreeItemForCategory(
|
|
final PwmSettingCategory category,
|
|
final PwmSettingCategory category,
|
|
final Locale locale,
|
|
final Locale locale,
|
|
@@ -304,7 +310,7 @@ public class NavTreeDataMaker
|
|
}
|
|
}
|
|
|
|
|
|
private static boolean categoryMatcher(
|
|
private static boolean categoryMatcher(
|
|
- final PwmDomain pwmDomain,
|
|
|
|
|
|
+ final DomainID domainID,
|
|
final PwmSettingCategory category,
|
|
final PwmSettingCategory category,
|
|
final String profile,
|
|
final String profile,
|
|
final StoredConfiguration storedConfiguration,
|
|
final StoredConfiguration storedConfiguration,
|
|
@@ -313,7 +319,7 @@ public class NavTreeDataMaker
|
|
{
|
|
{
|
|
if ( category == PwmSettingCategory.HTTPS_SERVER )
|
|
if ( category == PwmSettingCategory.HTTPS_SERVER )
|
|
{
|
|
{
|
|
- if ( !pwmDomain.getPwmApplication().getPwmEnvironment().getFlags().contains( PwmEnvironment.ApplicationFlag.ManageHttps ) )
|
|
|
|
|
|
+ if ( !navTreeSettings.isMangeHttps() )
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -321,7 +327,7 @@ public class NavTreeDataMaker
|
|
|
|
|
|
for ( final PwmSettingCategory childCategory : category.getChildren() )
|
|
for ( final PwmSettingCategory childCategory : category.getChildren() )
|
|
{
|
|
{
|
|
- if ( categoryMatcher( pwmDomain, childCategory, profile, storedConfiguration, navTreeSettings ) )
|
|
|
|
|
|
+ if ( categoryMatcher( domainID, childCategory, profile, storedConfiguration, navTreeSettings ) )
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -329,7 +335,7 @@ public class NavTreeDataMaker
|
|
|
|
|
|
for ( final PwmSetting setting : category.getSettings() )
|
|
for ( final PwmSetting setting : category.getSettings() )
|
|
{
|
|
{
|
|
- if ( settingMatcher( pwmDomain.getDomainID(), storedConfiguration, setting, profile, navTreeSettings ) )
|
|
|
|
|
|
+ if ( settingMatcher( domainID, storedConfiguration, setting, profile, navTreeSettings ) )
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -354,7 +360,7 @@ public class NavTreeDataMaker
|
|
}
|
|
}
|
|
|
|
|
|
final boolean valueIsDefault = StoredConfigurationUtil.isDefaultValue( storedConfiguration, storedConfigKey );
|
|
final boolean valueIsDefault = StoredConfigurationUtil.isDefaultValue( storedConfiguration, storedConfigKey );
|
|
- if ( setting.isHidden() && !valueIsDefault )
|
|
|
|
|
|
+ if ( setting.isHidden() && !valueIsDefault && setting.getSyntax() != PwmSettingSyntax.PROFILE )
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|