| | |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.SevenBitCleanPluginCfg; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.LDIFPluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.api.plugin.PreParsePluginResult; |
| | | import org.opends.server.api.plugin.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * The result that should be returned if a pre-parse operation fails the 7-bit |
| | | * clean check. |
| | | */ |
| | | private static final PreParsePluginResult PRE_PARSE_FAILURE_RESULT = |
| | | new PreParsePluginResult(false, false, false, true); |
| | | |
| | | |
| | | |
| | | // The current configuration for this plugin. |
| | | private SevenBitCleanPluginCfg currentConfig; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final LDIFPluginResult doLDIFImport(LDIFImportConfig importConfig, |
| | | Entry entry) |
| | | public final PluginResult.ImportLDIF |
| | | doLDIFImport(LDIFImportConfig importConfig, Entry entry) |
| | | { |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | |
| | | if (! found) |
| | | { |
| | | // The entry is out of scope, so we won't process it. |
| | | return LDIFPluginResult.SUCCESS; |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | | } |
| | | |
| | |
| | | Message rejectMessage = |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get( |
| | | a.getNameWithOptions()); |
| | | return new LDIFPluginResult(false, false, rejectMessage); |
| | | return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return LDIFPluginResult.SUCCESS; |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final PreParsePluginResult |
| | | doPreParse(PreParseAddOperation addOperation) |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseAddOperation addOperation) |
| | | { |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | addOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing(de.getResultCode(), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | } |
| | | |
| | | if (isInScope(config, entryDN)) |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | addOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(le.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.valueOf(le.getResultCode()), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_ATTR.get( |
| | | rawAttr.getAttributeType(), le.getErrorMessage())); |
| | | } |
| | | |
| | | if (! config.getAttributeType().contains(a.getAttributeType())) |
| | |
| | | { |
| | | if (! is7BitClean(v.getValue())) |
| | | { |
| | | addOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_ADD_ATTR_NOT_CLEAN.get( |
| | | rawAttr.getAttributeType())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get( |
| | | rawAttr.getAttributeType())); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PreParsePluginResult.SUCCESS; |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final PreParsePluginResult |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseModifyOperation modifyOperation) |
| | | { |
| | | // Get the current configuration for this plugin. |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | modifyOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing(de.getResultCode(), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | } |
| | | |
| | | if (isInScope(config, entryDN)) |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | modifyOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(le.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.valueOf(le.getResultCode()), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_ATTR.get( |
| | | rawAttr.getAttributeType(), le.getErrorMessage())); |
| | | } |
| | | |
| | | if (! config.getAttributeType().contains(a.getAttributeType())) |
| | |
| | | { |
| | | if (! is7BitClean(v.getValue())) |
| | | { |
| | | modifyOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_MODIFY_ATTR_NOT_CLEAN.get( |
| | | rawAttr.getAttributeType())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get( |
| | | rawAttr.getAttributeType())); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PreParsePluginResult.SUCCESS; |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final PreParsePluginResult |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseModifyDNOperation modifyDNOperation) |
| | | { |
| | | // Get the current configuration for this plugin. |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | modifyDNOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing(de.getResultCode(), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_DN.get(de.getMessageObject())); |
| | | } |
| | | |
| | | if (isInScope(config, entryDN)) |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | modifyDNOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_NEW_RDN.get(de.getMessageObject())); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing(de.getResultCode(), |
| | | ERR_PLUGIN_7BIT_CANNOT_DECODE_NEW_RDN.get(de.getMessageObject())); |
| | | } |
| | | |
| | | int numValues = newRDN.getNumValues(); |
| | |
| | | |
| | | if (! is7BitClean(newRDN.getAttributeValue(i).getValue())) |
| | | { |
| | | modifyDNOperation.appendErrorMessage( |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get( |
| | | newRDN.getAttributeName(i))); |
| | | return PRE_PARSE_FAILURE_RESULT; |
| | | return PluginResult.PreParse.stopProcessing( |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN.get( |
| | | newRDN.getAttributeName(i))); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PreParsePluginResult.SUCCESS; |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |