|
@@ -22,14 +22,13 @@
|
|
|
|
|
|
package password.pwm.config;
|
|
package password.pwm.config;
|
|
|
|
|
|
-import org.jdom2.Attribute;
|
|
|
|
-import org.jdom2.Element;
|
|
|
|
import password.pwm.config.value.PasswordValue;
|
|
import password.pwm.config.value.PasswordValue;
|
|
import password.pwm.config.value.ValueFactory;
|
|
import password.pwm.config.value.ValueFactory;
|
|
import password.pwm.i18n.Config;
|
|
import password.pwm.i18n.Config;
|
|
import password.pwm.util.LocaleHelper;
|
|
import password.pwm.util.LocaleHelper;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.StringUtil;
|
|
import password.pwm.util.java.StringUtil;
|
|
|
|
+import password.pwm.util.java.XmlElement;
|
|
import password.pwm.util.logging.PwmLogger;
|
|
import password.pwm.util.logging.PwmLogger;
|
|
import password.pwm.util.macro.MacroMachine;
|
|
import password.pwm.util.macro.MacroMachine;
|
|
|
|
|
|
@@ -1270,18 +1269,18 @@ public enum PwmSetting
|
|
if ( defaultValues == null )
|
|
if ( defaultValues == null )
|
|
{
|
|
{
|
|
final List<TemplateSetAssociation> returnObj = new ArrayList<>();
|
|
final List<TemplateSetAssociation> returnObj = new ArrayList<>();
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final List<Element> defaultElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_DEFAULT );
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final List<XmlElement> defaultElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_DEFAULT );
|
|
if ( this.getSyntax() == PwmSettingSyntax.PASSWORD )
|
|
if ( this.getSyntax() == PwmSettingSyntax.PASSWORD )
|
|
{
|
|
{
|
|
returnObj.add( new TemplateSetAssociation( new PasswordValue( null ), Collections.emptySet() ) );
|
|
returnObj.add( new TemplateSetAssociation( new PasswordValue( null ), Collections.emptySet() ) );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- for ( final Element defaultElement : defaultElements )
|
|
|
|
|
|
+ for ( final XmlElement defaultElement : defaultElements )
|
|
{
|
|
{
|
|
final Set<PwmSettingTemplate> definedTemplates = PwmSettingXml.parseTemplateAttribute( defaultElement );
|
|
final Set<PwmSettingTemplate> definedTemplates = PwmSettingXml.parseTemplateAttribute( defaultElement );
|
|
- final StoredValue storedValue = ValueFactory.fromXmlValues( this, defaultElement, null );
|
|
|
|
|
|
+ final StoredValue storedValue = ValueFactory.fromXmlValues( this, defaultElement.asJdomElement(), null );
|
|
returnObj.add( new TemplateSetAssociation( storedValue, definedTemplates ) );
|
|
returnObj.add( new TemplateSetAssociation( storedValue, definedTemplates ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1319,20 +1318,20 @@ public enum PwmSetting
|
|
if ( options == null )
|
|
if ( options == null )
|
|
{
|
|
{
|
|
final Map<String, String> returnList = new LinkedHashMap<>();
|
|
final Map<String, String> returnList = new LinkedHashMap<>();
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Element optionsElement = settingElement.getChild( "options" );
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final XmlElement optionsElement = settingElement.getChild( "options" );
|
|
if ( optionsElement != null )
|
|
if ( optionsElement != null )
|
|
{
|
|
{
|
|
- final List<Element> optionElements = optionsElement.getChildren( "option" );
|
|
|
|
|
|
+ final List<XmlElement> optionElements = optionsElement.getChildren( "option" );
|
|
if ( optionElements != null )
|
|
if ( optionElements != null )
|
|
{
|
|
{
|
|
- for ( final Element optionElement : optionElements )
|
|
|
|
|
|
+ for ( final XmlElement optionElement : optionElements )
|
|
{
|
|
{
|
|
- if ( optionElement.getAttribute( "value" ) == null )
|
|
|
|
|
|
+ if ( optionElement.getAttributeValue( "value" ) == null )
|
|
{
|
|
{
|
|
throw new IllegalStateException( "option element is missing 'value' attribute for key " + this.getKey() );
|
|
throw new IllegalStateException( "option element is missing 'value' attribute for key " + this.getKey() );
|
|
}
|
|
}
|
|
- returnList.put( optionElement.getAttribute( "value" ).getValue(), optionElement.getValue() );
|
|
|
|
|
|
+ returnList.put( optionElement.getAttributeValue( "value" ), optionElement.getText() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1348,14 +1347,14 @@ public enum PwmSetting
|
|
if ( properties == null )
|
|
if ( properties == null )
|
|
{
|
|
{
|
|
final Map<PwmSettingProperty, String> newProps = new LinkedHashMap<>();
|
|
final Map<PwmSettingProperty, String> newProps = new LinkedHashMap<>();
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Element propertiesElement = settingElement.getChild( "properties" );
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final XmlElement propertiesElement = settingElement.getChild( "properties" );
|
|
if ( propertiesElement != null )
|
|
if ( propertiesElement != null )
|
|
{
|
|
{
|
|
- final List<Element> propertyElements = propertiesElement.getChildren( "property" );
|
|
|
|
|
|
+ final List<XmlElement> propertyElements = propertiesElement.getChildren( "property" );
|
|
if ( propertyElements != null )
|
|
if ( propertyElements != null )
|
|
{
|
|
{
|
|
- for ( final Element propertyElement : propertyElements )
|
|
|
|
|
|
+ for ( final XmlElement propertyElement : propertyElements )
|
|
{
|
|
{
|
|
if ( propertyElement.getAttributeValue( "key" ) == null )
|
|
if ( propertyElement.getAttributeValue( "key" ) == null )
|
|
{
|
|
{
|
|
@@ -1366,7 +1365,7 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
throw new IllegalStateException( "property element has unknown 'key' attribute for value " + this.getKey() );
|
|
throw new IllegalStateException( "property element has unknown 'key' attribute for value " + this.getKey() );
|
|
}
|
|
}
|
|
- newProps.put( property, propertyElement.getValue() );
|
|
|
|
|
|
+ newProps.put( property, propertyElement.getText() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1382,9 +1381,9 @@ public enum PwmSetting
|
|
if ( flags == null )
|
|
if ( flags == null )
|
|
{
|
|
{
|
|
final Collection<PwmSettingFlag> returnObj = new ArrayList<>();
|
|
final Collection<PwmSettingFlag> returnObj = new ArrayList<>();
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final List<Element> flagElements = settingElement.getChildren( "flag" );
|
|
|
|
- for ( final Element flagElement : flagElements )
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final List<XmlElement> flagElements = settingElement.getChildren( "flag" );
|
|
|
|
+ for ( final XmlElement flagElement : flagElements )
|
|
{
|
|
{
|
|
final String value = flagElement.getTextTrim();
|
|
final String value = flagElement.getTextTrim();
|
|
|
|
|
|
@@ -1409,12 +1408,12 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
if ( ldapPermissionInfo == null )
|
|
if ( ldapPermissionInfo == null )
|
|
{
|
|
{
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final List<Element> permissionElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_LDAP_PERMISSION );
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final List<XmlElement> permissionElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_LDAP_PERMISSION );
|
|
final List<LDAPPermissionInfo> returnObj = new ArrayList<>();
|
|
final List<LDAPPermissionInfo> returnObj = new ArrayList<>();
|
|
if ( permissionElements != null )
|
|
if ( permissionElements != null )
|
|
{
|
|
{
|
|
- for ( final Element permissionElement : permissionElements )
|
|
|
|
|
|
+ for ( final XmlElement permissionElement : permissionElements )
|
|
{
|
|
{
|
|
final LDAPPermissionInfo.Actor actor = JavaHelper.readEnumFromString(
|
|
final LDAPPermissionInfo.Actor actor = JavaHelper.readEnumFromString(
|
|
LDAPPermissionInfo.Actor.class,
|
|
LDAPPermissionInfo.Actor.class,
|
|
@@ -1460,9 +1459,9 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
final List<TemplateSetAssociation> returnObj = new ArrayList<>();
|
|
final List<TemplateSetAssociation> returnObj = new ArrayList<>();
|
|
final MacroMachine macroMachine = MacroMachine.forStatic();
|
|
final MacroMachine macroMachine = MacroMachine.forStatic();
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final List<Element> exampleElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_EXAMPLE );
|
|
|
|
- for ( final Element exampleElement : exampleElements )
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final List<XmlElement> exampleElements = settingElement.getChildren( PwmSettingXml.XML_ELEMENT_EXAMPLE );
|
|
|
|
+ for ( final XmlElement exampleElement : exampleElements )
|
|
{
|
|
{
|
|
final Set<PwmSettingTemplate> definedTemplates = PwmSettingXml.parseTemplateAttribute( exampleElement );
|
|
final Set<PwmSettingTemplate> definedTemplates = PwmSettingXml.parseTemplateAttribute( exampleElement );
|
|
final String exampleString = macroMachine.expandMacros( exampleElement.getText() );
|
|
final String exampleString = macroMachine.expandMacros( exampleElement.getText() );
|
|
@@ -1483,9 +1482,9 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
if ( required == null )
|
|
if ( required == null )
|
|
{
|
|
{
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Attribute requiredAttribute = settingElement.getAttribute( "required" );
|
|
|
|
- final boolean requiredOutput = requiredAttribute != null && "true".equalsIgnoreCase( requiredAttribute.getValue() );
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final String requiredAttribute = settingElement.getAttributeValue( "required" );
|
|
|
|
+ final boolean requiredOutput = requiredAttribute != null && "true".equalsIgnoreCase( requiredAttribute );
|
|
required = ( ) -> requiredOutput;
|
|
required = ( ) -> requiredOutput;
|
|
}
|
|
}
|
|
return required.get();
|
|
return required.get();
|
|
@@ -1495,9 +1494,9 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
if ( hidden == null )
|
|
if ( hidden == null )
|
|
{
|
|
{
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Attribute requiredAttribute = settingElement.getAttribute( "hidden" );
|
|
|
|
- final boolean outputHidden = requiredAttribute != null && "true".equalsIgnoreCase( requiredAttribute.getValue() ) || this.getCategory().isHidden();
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final String requiredAttribute = settingElement.getAttributeValue( "hidden" );
|
|
|
|
+ final boolean outputHidden = requiredAttribute != null && "true".equalsIgnoreCase( requiredAttribute ) || this.getCategory().isHidden();
|
|
hidden = ( ) -> outputHidden;
|
|
hidden = ( ) -> outputHidden;
|
|
}
|
|
}
|
|
return hidden.get();
|
|
return hidden.get();
|
|
@@ -1507,9 +1506,9 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
if ( level == null )
|
|
if ( level == null )
|
|
{
|
|
{
|
|
- final Element settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Attribute levelAttribute = settingElement.getAttribute( "level" );
|
|
|
|
- final int outputLevel = levelAttribute != null ? Integer.parseInt( levelAttribute.getValue() ) : 0;
|
|
|
|
|
|
+ final XmlElement settingElement = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final String levelAttribute = settingElement.getAttributeValue( "level" );
|
|
|
|
+ final int outputLevel = levelAttribute != null ? Integer.parseInt( levelAttribute ) : 0;
|
|
level = ( ) -> outputLevel;
|
|
level = ( ) -> outputLevel;
|
|
}
|
|
}
|
|
return level.get();
|
|
return level.get();
|
|
@@ -1519,8 +1518,8 @@ public enum PwmSetting
|
|
{
|
|
{
|
|
if ( pattern == null )
|
|
if ( pattern == null )
|
|
{
|
|
{
|
|
- final Element settingNode = PwmSettingXml.readSettingXml( this );
|
|
|
|
- final Element regexNode = settingNode.getChild( "regex" );
|
|
|
|
|
|
+ final XmlElement settingNode = PwmSettingXml.readSettingXml( this );
|
|
|
|
+ final XmlElement regexNode = settingNode.getChild( "regex" );
|
|
if ( regexNode != null )
|
|
if ( regexNode != null )
|
|
{
|
|
{
|
|
try
|
|
try
|