repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/ObjectClassContentProposal.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/ObjectClassContentProposal.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets;
/**
* A content proposal for an object class.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ObjectClassContentProposal extends AttributesWidgetContentProposal
{
public ObjectClassContentProposal( String content )
{
super( content );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/KeywordContentProposal.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/KeywordContentProposal.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets;
/**
* A content proposal for a keyword.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class KeywordContentProposal extends AttributesWidgetContentProposal
{
public KeywordContentProposal( String content )
{
super( content );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclTabFolderComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclTabFolderComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets;
import java.text.ParseException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
/**
* This composite contains the tabs with visual and source editor.
* It also manages the synchronization between these two tabs.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenLdapAclTabFolderComposite extends Composite
{
/** The index of the visual tab */
public static final int VISUAL_TAB_INDEX = 0;
/** The index of the source tab */
public static final int SOURCE_TAB_INDEX = 1;
/** The tab folder */
private TabFolder tabFolder;
/** The visual tab */
private TabItem visualTab;
/** The inner container of the visual tab */
private Composite visualContainer;
/** The visual editor composite */
private OpenLdapAclVisualEditorComposite visualComposite;
/** Tehe source tab */
private TabItem sourceTab;
/** The inner container of the visual tab */
private Composite sourceContainer;
/** The source editor composite */
private OpenLdapAclSourceEditorComposite sourceComposite;
/** The ACL context */
private OpenLdapAclValueWithContext context;
/**
* Creates a new instance of TabFolderComposite.
*
* @param parent
* @param style
*/
public OpenLdapAclTabFolderComposite( Composite parent, OpenLdapAclValueWithContext context, int style )
{
super( parent, style );
this.context = context;
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
setLayout( layout );
createTabFolder();
createVisualTab();
createSourceTab();
initListeners();
}
/**
* Initializes the listeners.
*
*/
private void initListeners()
{
tabFolder.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
tabSelected();
}
} );
}
/**
* Creates the source tab and configures the source editor.
*
*/
private void createSourceTab()
{
// create inner container
sourceContainer = new Composite( tabFolder, SWT.BORDER );
sourceContainer.setLayout( new FillLayout() );
// create source editor
sourceComposite = new OpenLdapAclSourceEditorComposite( sourceContainer, context, SWT.NONE );
// create tab
sourceTab = new TabItem( tabFolder, SWT.NONE, SOURCE_TAB_INDEX );
sourceTab.setText( "Source" );
sourceTab.setControl( sourceContainer );
}
/**
* Creates the visual tab and the GUI editor.
*
*/
private void createVisualTab()
{
// create inner container
visualContainer = new Composite( tabFolder, SWT.NONE );
visualContainer.setLayout( new GridLayout() );
visualContainer.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
// create the visual ACIItem composite
visualComposite = new OpenLdapAclVisualEditorComposite( visualContainer, context, SWT.NONE );
visualComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
// create tab
visualTab = new TabItem( tabFolder, SWT.NONE, VISUAL_TAB_INDEX );
visualTab.setText( "Visual Editor" );
visualTab.setControl( visualContainer );
}
/**
* Creates the tab folder and the listeners.
*
*/
private void createTabFolder()
{
tabFolder = new TabFolder( this, SWT.TOP );
tabFolder.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
}
/**
* Called, when a tab is selected. This method manages the synchronization
* between visual and source editor.
*/
private void tabSelected()
{
int index = tabFolder.getSelectionIndex();
if ( index == SOURCE_TAB_INDEX )
{
sourceComposite.refresh();
}
else if ( index == VISUAL_TAB_INDEX )
{
visualComposite.refresh();
}
}
/**
* Returns the string representation of the ACI item.
* A syntax check is performed before returning the input, an
* invalid syntax causes a ParseException.
*
* @return the valid string representation of the ACI item
* @throws ParseException it the syntax check fails.
*/
public String getInput() throws ParseException
{
int index = tabFolder.getSelectionIndex();
if ( index == VISUAL_TAB_INDEX )
{
return visualComposite.getInput();
}
else
{
return sourceComposite.getInput();
}
}
/**
* Formats the content.
*/
public void format()
{
if ( tabFolder.getSelectionIndex() == SOURCE_TAB_INDEX )
{
sourceComposite.format();
}
}
/**
* Saves widget settings.
*/
public void saveWidgetSettings()
{
visualComposite.saveWidgetSettings();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/AttributesWidget.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/AttributesWidget.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.widgets.AbstractWidget;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.common.ui.widgets.TableWidget;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPlugin;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPluginConstants;
import org.apache.directory.studio.openldap.config.acl.model.AclAttribute;
import org.apache.directory.studio.openldap.config.acl.model.AclAttributeStyleEnum;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseAttributes;
import org.apache.directory.studio.openldap.config.acl.wrapper.AclAttributeDecorator;
import org.apache.directory.studio.openldap.config.acl.wrapper.AclAttributeWrapper;
/**
* A widget used to create an AclWhatClause Attribute :
*
* <pre>
* ...
* | .--------------------------------------------------------. |
* | | Attribute list : | |
* | | +-------------------------------------------+ | |
* | | | abc | (Add) | |
* | | | !def | (Edit) | |
* | | | entry | (Delete) | |
* | | +-------------------------------------------+ | |
* | | Val : [ ] MatchingRule : [ ] Style : [--------------] | |
* | | Value : [////////////////////////////////////////////] | |
* | `--------------------------------------------------------' |
* ...
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AttributesWidget extends AbstractWidget
{
/** The Attributes table */
private TableWidget<AclAttributeWrapper> attributeTable;
/** The WhatAttributes clause */
private AclWhatClauseAttributes aclWhatClauseAttributes;
/** The checkbox for the Val */
private Button valButton;
/** The checkbox for the matchingrule */
private Button matchingRuleButton;
/** The style combo */
private Combo styleCombo;
/** The Value Text */
private Text valueText;
/** The initial attributes. */
private String[] initialAttributes;
/** The proposal provider */
private AttributesWidgetContentProposalProvider proposalProvider;
/** The proposal adapter*/
private ContentProposalAdapter proposalAdapter;
/** The label provider for the proposal adapter */
private LabelProvider labelProvider = new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof IContentProposal )
{
IContentProposal proposal = ( IContentProposal ) element;
return proposal.getLabel() == null ? proposal.getContent() : proposal.getLabel();
}
return super.getText( element );
};
public Image getImage( Object element )
{
if ( element instanceof AttributeTypeContentProposal )
{
return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ATD );
}
else if ( element instanceof ObjectClassContentProposal )
{
return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_OCD );
}
else if ( element instanceof KeywordContentProposal )
{
return OpenLdapAclEditorPlugin.getDefault().getImage( OpenLdapAclEditorPluginConstants.IMG_KEYWORD );
}
return super.getImage( element );
}
};
/** The verify listener which doesn't allow white spaces*/
private VerifyListener verifyListener = new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
// Not allowing white spaces
if ( Character.isWhitespace( e.character ) )
{
e.doit = false;
}
}
};
/** The modify listener */
private ModifyListener modifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
notifyListeners();
}
};
/** The Val button listener */
private SelectionAdapter valButtonListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent event )
{
// If the Val Button is selected, then the MatchingRule Button,
// the Style Combo and the value Text must be enabled
boolean valSelected = valButton.getSelection();
matchingRuleButton.setEnabled( valSelected );
styleCombo.setEnabled( valSelected );
valueText.setEnabled( valSelected );
aclWhatClauseAttributes.setVal( valSelected );
// TODO : disable the OK button if Val is set and there is no value
}
};
/** The MatchingRule button listener */
private SelectionAdapter matchingRuleButtonListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent event )
{
aclWhatClauseAttributes.setMatchingRule( matchingRuleButton.getSelection() );
}
};
/** The style combo listener */
private SelectionAdapter styleComboListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent event )
{
aclWhatClauseAttributes.setStyle( AclAttributeStyleEnum.getStyle( styleCombo.getText() ) );
}
};
/**
* Creates the widget.
* <pre>
* Attribute list :
* +-------------------------------------------+
* | abc | (Add)
* | !def | (Edit)
* | entry | (Delete)
* +-------------------------------------------+
* Val : [ ] MatchingRule : [ ] Style : [--------------]
* Value : [////////////////////////////////////////////]
* </pre>
*
* @param parent the parent
*/
public void createWidget( Composite parent, IBrowserConnection connection, AclWhatClauseAttributes clause )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 4, 1 );
GridData gd = new GridData( GridData.FILL_HORIZONTAL );
gd.horizontalSpan = 1;
gd.widthHint = 30;
composite.setLayoutData( gd );
// The Attribute table
BaseWidgetUtils.createLabel( composite, "Attributes list :", 4 );
AclAttributeDecorator decorator = new AclAttributeDecorator( composite.getShell(), connection );
attributeTable = new TableWidget<AclAttributeWrapper>( decorator );
attributeTable.createWidgetWithEdit( composite, null );
attributeTable.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 3 ) );
//attributeTable.addWidgetModifyListener( attributeTableListener );
// The Val
valButton = BaseWidgetUtils.createCheckbox( composite, "Val", 1 );
valButton.addSelectionListener( valButtonListener );
// The MatchingRule
matchingRuleButton = BaseWidgetUtils.createCheckbox( composite, "MatchingRule", 1 );
matchingRuleButton.setEnabled( false );
matchingRuleButton.addSelectionListener( matchingRuleButtonListener );
// The style
BaseWidgetUtils.createLabel( composite, "Style :", 1 );
styleCombo = BaseWidgetUtils.createCombo( composite, AclAttributeStyleEnum.getNames(), 9, 1 );
styleCombo.setEnabled( false );
styleCombo.addSelectionListener( styleComboListener );
// The value
BaseWidgetUtils.createLabel( composite, "Value :", 1 );
valueText = BaseWidgetUtils.createText( composite, "", 3 );
valueText.setEnabled( false );
//valueText.addModifyListener( valueTextListener );
initWidget( clause );
}
/**
* Initialize the widget with the current value
*/
private void initWidget( AclWhatClauseAttributes clause )
{
aclWhatClauseAttributes = clause;
// Update the table
setAttributes( clause.getAttributes() );
// The Val button is always enabled
valButton.setEnabled( true );
if ( clause.hasVal() )
{
matchingRuleButton.setEnabled( clause.hasMatchingRule() );
styleCombo.setEnabled( false );
styleCombo.setText( clause.getStyle().getName() );
valueText.setEnabled( false );
valueText.setText( CommonUIUtils.getTextValue( clause.getValue() ) );
}
else
{
matchingRuleButton.setEnabled( false );
styleCombo.setEnabled( false );
valueText.setEnabled( false );
}
}
/**
* Sets the initial attributes.
*
* @param aclAttributes the initial attributes
*/
private void setAttributes( List<AclAttribute> aclAttributes )
{
List<AclAttributeWrapper> aclAttributeWrappers = new ArrayList<AclAttributeWrapper>( aclAttributes.size() );
for ( AclAttribute aclAttribute: aclAttributes )
{
AclAttributeWrapper aclAttributeWrapper = new AclAttributeWrapper( aclAttribute );
aclAttributeWrappers.add( aclAttributeWrapper );
}
attributeTable.setElements( aclAttributeWrappers );
}
/**
* Sets the enabled state of the widget.
*
* @param b true to enable the widget, false to disable the widget
*/
public void setEnabled( boolean b )
{
}
/**
* Gets the attributes.
*
* @return the attributes
*/
public List<AclAttribute> getAttributes()
{
List<AclAttributeWrapper> elementList = attributeTable.getElements();
List<AclAttribute> result = new ArrayList<AclAttribute>( elementList.size() );
for ( AclAttributeWrapper element : elementList )
{
result.add( element.getAclAttribute() );
}
return result;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/OpenLdapAclWhoClausesBuilderWidget.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClause;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseStar;
/**
* The WhoClause widget builder
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenLdapAclWhoClausesBuilderWidget
{
/** The ACL context */
private OpenLdapAclValueWithContext context;
/** The visual editor composite */
protected OpenLdapAclVisualEditorComposite visualEditorComposite;
/** The list of clause widgets */
private List<OpenLdapAclWhoClauseWidget> clauseWidgets = new ArrayList<OpenLdapAclWhoClauseWidget>();
/** The list of separators */
private List<Label> separatorWidgets = new ArrayList<Label>();
// UI widgets
private Group whoGroup;
/**
* A listener for the WhoClause widget
*/
private WidgetModifyListener whoClauseModifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
// Getting the source widget
OpenLdapAclWhoClauseWidget widget = ( OpenLdapAclWhoClauseWidget ) event.getSource();
List<AclWhoClause> whoClauses = context.getAclItem().getWhoClauses();
// Updating the clause
whoClauses.remove( widget.getIndex() );
whoClauses.add( widget.getIndex(), widget.getClause() );
// Adjusting the layout of the visual editor composite
visualEditorComposite.layout( true, true );
}
};
/**
* Creates a new instance of OpenLdapAclWhoClausesBuilderWidget.
*
* @param visualEditorComposite the visual editor composite
*/
public OpenLdapAclWhoClausesBuilderWidget( OpenLdapAclVisualEditorComposite visualEditorComposite, OpenLdapAclValueWithContext context )
{
this.visualEditorComposite = visualEditorComposite;
this.context = context;
}
/**
* Create the UI.
*
* @param parent the parent composite
*/
public void create( Composite parent )
{
// Creating the who group
whoGroup = BaseWidgetUtils.createGroup( parent, "Acces by \"Who\"", 1 );
whoGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
}
/**
* Disposes the clause widgets.
*/
private void disposeClausesWidgets()
{
// Disposing and removing clause widgets
for ( OpenLdapAclWhoClauseWidget clauseWidget : clauseWidgets.toArray( new OpenLdapAclWhoClauseWidget[0] ) )
{
clauseWidget.dispose();
clauseWidgets.remove( clauseWidget );
}
// Disposing and removing separators
for ( Label separator : separatorWidgets.toArray( new Label[0] ) )
{
separator.dispose();
separatorWidgets.remove( separator );
}
}
/**
* Creates the clause widgets.
*/
private void createClauseWidgets()
{
// Checking the clauses
List<AclWhoClause> whoClauses = context.getAclItem().getWhoClauses();
if ( whoClauses.size() == 0 )
{
// Adding at least one default clause
AclWhoClauseStar whoClause = new AclWhoClauseStar();
whoClauses.add( whoClause );
}
// Creating a widget for each clause
boolean isFirst = true;
int pos = 0;
for ( AclWhoClause whoClause : whoClauses )
{
// Creating a separator (except for the first row)
if ( isFirst )
{
isFirst = false;
}
else
{
Label separator = new Label( whoGroup, SWT.SEPARATOR | SWT.HORIZONTAL );
separator.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
separatorWidgets.add( separator );
}
// Creating the clause widget
OpenLdapAclWhoClauseWidget clauseWidget = new OpenLdapAclWhoClauseWidget( this, context, whoClause, pos );
clauseWidget.create( whoGroup );
clauseWidget.addWidgetModifyListener( whoClauseModifyListener );
clauseWidgets.add( clauseWidget );
pos++;
}
// Updating button states for specific rows (first, last and the case where there's only one row)
if ( clauseWidgets.size() == 1 )
{
// There's only one row
OpenLdapAclWhoClauseWidget widget = clauseWidgets.get( 0 );
widget.getDeleteButton().setEnabled( false );
widget.getMoveUpButton().setEnabled( false );
widget.getMoveDownButton().setEnabled( false );
}
else
{
// There are more than 1 row
OpenLdapAclWhoClauseWidget firstWidget = clauseWidgets.get( 0 );
firstWidget.getMoveUpButton().setEnabled( false );
OpenLdapAclWhoClauseWidget lastWidget = clauseWidgets.get( clauseWidgets.size() - 1 );
lastWidget.getMoveDownButton().setEnabled( false );
}
}
/**
* Refreshes the clause widgets.
*/
private void refreshWhoClauseWidgets()
{
// Disposing previous widgets and creating new ones
disposeClausesWidgets();
createClauseWidgets();
// Adjusting the layout of the visual editor composite
visualEditorComposite.layout( true, true );
}
/**
* This method is called by a OpenLdapAclWhoClauseWidget when a
* row needs to be added.
*
* @param widget the source widget
*/
protected void addNewClause( OpenLdapAclWhoClauseWidget widget )
{
// Adding a new clause underneath the selected widget
AclWhoClauseStar whoClause = new AclWhoClauseStar();
context.getAclItem().getWhoClauses().add( whoClause );
// Refreshing clauses widgets
refreshWhoClauseWidgets();
}
/**
* This method is called by a OpenLdapAclWhoClauseWidget when a
* row needs to be deleted.
*
* @param widget the source widget
*/
protected void deleteClause( OpenLdapAclWhoClauseWidget widget )
{
int deletedIndex = widget.getIndex();
// Deleting the selected widget
context.getAclItem().getWhoClauses().remove( deletedIndex );
// Refreshing clauses widgets
refreshWhoClauseWidgets();
}
/**
* This method is called by a OpenLdapAclWhoClauseWidget when a
* row needs to be moved up.
*
* @param widget the source widget
*/
protected void moveUpClause( OpenLdapAclWhoClauseWidget widget )
{
// Swapping clauses
int index = widget.getIndex();
swapClauseIndexes( index, index - 1 );
// Refreshing clauses widgets
refreshWhoClauseWidgets();
}
/**
* This method is called by a OpenLdapAclWhoClauseWidget when a
* row needs to be moved down.
*
* @param widget the source widget
*/
protected void moveDownClause( OpenLdapAclWhoClauseWidget widget )
{
// Swapping clauses
int index = widget.getIndex();
swapClauseIndexes( index, index + 1 );
// Refreshing clauses widgets
refreshWhoClauseWidgets();
}
/**
* Swaps (exchanges) the clauses at the given indexes.
*
* @param sourceIndex the source index
* @param destinationIndex the destination index
*/
private void swapClauseIndexes( int sourceIndex, int destinationIndex )
{
// Getting clauses
List<AclWhoClause> whoClauses = context.getAclItem().getWhoClauses();
AclWhoClause sourceClause = whoClauses.get( sourceIndex );
AclWhoClause destinationClause = whoClauses.get( destinationIndex );
// Swapping clauses
whoClauses.remove( sourceIndex );
whoClauses.add( sourceIndex, destinationClause );
whoClauses.remove( destinationIndex );
whoClauses.add( destinationIndex, sourceClause );
}
/**
* Sets the input.
*
* @param clauses the who clauses
*/
public void refresh()
{
refreshWhoClauseWidgets();
}
/**
* Disposes all UI widgets.
*/
public void dispose()
{
// Disposing the who group
if ( ( whoGroup != null ) && ( !whoGroup.isDisposed() ) )
{
whoGroup.dispose();
}
// Disposing the clause widgets
disposeClausesWidgets();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClause;
/**
* This interface defines a clause composite for who clauses.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface WhoClauseComposite<C extends AclWhoClause> extends ClauseComposite
{
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseGroupComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseGroupComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.api.ldap.model.schema.ObjectClass;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseGroup;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseGroupComposite extends AbstractWhoClauseComposite<AclWhoClauseGroup>
{
/** The expansion listener used on expandable composites */
private ExpansionAdapter expansionListener = new ExpansionAdapter()
{
public void expansionStateChanged( ExpansionEvent e )
{
// Refreshing the layout of the whole composite
visualEditorComposite.layout( true, true );
}
};
public WhoClauseGroupComposite( OpenLdapAclValueWithContext context, AclWhoClauseGroup clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseGroupComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseGroup(), visualEditorComposite );
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
// Group DN
BaseWidgetUtils.createLabel( composite, "Group DN:", 1 );
EntryWidget entryWidget = new EntryWidget();
entryWidget.createWidget( composite );
ExpandableComposite optionsExpandableComposite = new ExpandableComposite( composite, SWT.NONE,
ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT );
optionsExpandableComposite.setLayout( new GridLayout() );
optionsExpandableComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
optionsExpandableComposite.setText( "Options" );
Composite clientComposite = BaseWidgetUtils.createColumnContainer( optionsExpandableComposite, 1, 1 );
( ( GridLayout ) clientComposite.getLayout() ).marginRight = 15;
optionsExpandableComposite.setClient( clientComposite );
optionsExpandableComposite.addExpansionListener( expansionListener );
Group optionsGroup = BaseWidgetUtils.createGroup( clientComposite, "", 1 );
optionsGroup.setLayout( new GridLayout( 2, false ) );
optionsGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
// Group Object Class
BaseWidgetUtils.createLabel( optionsGroup, "Group Object Class", 1 );
ComboViewer groupObjectClassComboViewer = new ComboViewer( BaseWidgetUtils.createCombo( optionsGroup,
new String[0], -1, 1 ) );
groupObjectClassComboViewer.setContentProvider( new ArrayContentProvider() );
groupObjectClassComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof ObjectClass )
{
// TODO
}
return super.getText( element );
}
} );
// groupObjectClassComboViewer.setInput( dqsdq ); // TODO
groupObjectClassComboViewer.getCombo().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Group Attribute Class
BaseWidgetUtils.createLabel( optionsGroup, "Group Attribute Type", 1 );
ComboViewer groupAttributeTypeComboViewer = new ComboViewer( BaseWidgetUtils.createCombo( optionsGroup,
new String[0], -1, 1 ) );
groupAttributeTypeComboViewer.setContentProvider( new ArrayContentProvider() );
groupAttributeTypeComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof ObjectClass )
{
// TODO
}
return super.getText( element );
}
} );
// groupObjectClassComboViewer.setInput( dqsdq ); // TODO
groupAttributeTypeComboViewer.getCombo().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
return composite;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseDnComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseDnComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseDnTypeEnum;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseDn;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseDnTypeEnum;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseDnComposite extends AbstractWhoClauseComposite<AclWhoClauseDn>
{
/** The array of DN who clause types */
private static final AclWhoClauseDnTypeEnum[] aclWhoClauseDnTypes = new AclWhoClauseDnTypeEnum[]
{
AclWhoClauseDnTypeEnum.BASE,
AclWhoClauseDnTypeEnum.EXACT,
AclWhoClauseDnTypeEnum.ONE,
AclWhoClauseDnTypeEnum.SUBTREE,
AclWhoClauseDnTypeEnum.CHILDREN,
AclWhoClauseDnTypeEnum.REGEX
};
/** The entry widget */
private EntryWidget entryWidget;
/** The modify listener */
private WidgetModifyListener modifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
getClause().setPattern( entryWidget.getDn().toString() );
}
};
public WhoClauseDnComposite( OpenLdapAclValueWithContext context, AclWhoClauseDn clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseDnComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseDn(), visualEditorComposite );
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
// DN
BaseWidgetUtils.createLabel( composite, "DN:", 1 );
entryWidget = new EntryWidget();
entryWidget.createWidget( composite );
entryWidget.addWidgetModifyListener( modifyListener );
// Type
BaseWidgetUtils.createLabel( composite, "Type:", 1 );
ComboViewer whatClauseDnTypeComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo( composite,
new String[0], -1, 1 ) );
whatClauseDnTypeComboViewer.getCombo().setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) );
whatClauseDnTypeComboViewer.setContentProvider( new ArrayContentProvider() );
whatClauseDnTypeComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof AclWhatClauseDnTypeEnum )
{
AclWhatClauseDnTypeEnum value = ( AclWhatClauseDnTypeEnum ) element;
switch ( value )
{
case BASE:
return "Base";
case EXACT:
return "Exact";
case ONE:
return "One";
case SUBTREE:
return "Subtree";
case CHILDREN:
return "Children";
case REGEX:
return "Regex";
}
}
return super.getText( element );
}
} );
whatClauseDnTypeComboViewer.setInput( aclWhoClauseDnTypes );
return composite;
}
/**
* {@inheritDoc}
*/
public void setClause( AclWhoClauseDn clause )
{
super.setClause( clause );
setInput();
}
/**
* {@inheritDoc}
*/
public void setConnection( IBrowserConnection connection )
{
super.setConnection( connection );
setInput();
}
private void setInput()
{
if ( entryWidget != null )
{
if ( whoClause != null )
{
try
{
entryWidget.setInput( connection, new Dn( whoClause.getPattern() ) );
}
catch ( LdapInvalidDnException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
entryWidget.setInput( connection, null );
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseFilterComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.FilterWidget;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseFilter;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhatClauseFilterComposite extends AbstractClauseComposite
{
/** The filter widget */
private FilterWidget filterWidget;
private WidgetModifyListener modifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
context.getAclItem().getWhatClause().getFilterClause().setFilter( filterWidget.getFilter() );
}
};
public WhatClauseFilterComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, visualEditorComposite );
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
BaseWidgetUtils.createLabel( composite, "Filter:", 1 );
filterWidget = new FilterWidget();
filterWidget.createWidget( composite );
filterWidget.addWidgetModifyListener( modifyListener );
return composite;
}
/**
* {@inheritDoc}
*/
public void setConnection( IBrowserConnection connection )
{
super.setConnection( connection );
setInput();
}
private void setInput()
{
if ( filterWidget != null )
{
filterWidget.setBrowserConnection( connection );
AclWhatClauseFilter aclWhatClauseFilter = context.getAclItem().getWhatClause().getFilterClause();
if ( aclWhatClauseFilter != null )
{
String filter = aclWhatClauseFilter.getFilter();
filterWidget.setFilter( ( filter != null ) ? filter : "" );
}
else
{
filterWidget.setFilter( "" );
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractClauseComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.eclipse.swt.widgets.Composite;
/**
* A basic common abstract class implementing {@link ClauseComposite}.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractClauseComposite implements ClauseComposite
{
/** The visual editor composite */
protected Composite visualEditorComposite;
/** The connection */
protected IBrowserConnection connection;
/** The ACL context in use */
protected OpenLdapAclValueWithContext context;
/**
* Creates a new instance of AbstractClauseComposite.
*/
public AbstractClauseComposite()
{
}
/**
* Creates a new instance of AbstractClauseComposite.
*
* @param clause the clause
*/
public AbstractClauseComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
this.context = context;
this.visualEditorComposite = visualEditorComposite;
connection = context.getConnection();
}
/**
* {@inheritDoc}
*/
public Composite createComposite( Composite parent )
{
return null;
}
/**
* {@inheritDoc}
*/
public Composite getVisualEditorComposite()
{
return visualEditorComposite;
}
/**
* {@inheritDoc}
*/
public void setVisualEditorComposite( Composite visualEditorComposite )
{
this.visualEditorComposite = visualEditorComposite;
}
/**
* {@inheritDoc}
*/
public IBrowserConnection getConnection()
{
return connection;
}
/**
* {@inheritDoc}
*/
public void setConnection( IBrowserConnection connection )
{
this.connection = connection;
}
/**
* {@inheritDoc}
*/
public void saveWidgetSettings()
{
}
/**
* @return The ACL context in use
*/
public OpenLdapAclValueWithContext getContext()
{
return context;
}
/**
* @param context The ACL context in use
*/
public void setContext( OpenLdapAclValueWithContext context )
{
this.context = context;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseUsersComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseUsersComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseUsers;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseUsersComposite extends AbstractWhoClauseComposite<AclWhoClauseUsers>
{
public WhoClauseUsersComposite( OpenLdapAclValueWithContext context, AclWhoClauseUsers clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseUsersComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseUsers(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/ClauseComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.eclipse.swt.widgets.Composite;
/**
* This interface defines a clause composite.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface ClauseComposite
{
/**
* Creates the composite.
*
* @param parent the parent composite
*/
Composite createComposite( Composite parent );
/**
* Gets the visual editor composite.
*
* @return the visual editor composite
*/
Composite getVisualEditorComposite();
/**
* Sets the visual editor composite.
*
* @param visualEditorComposite the visual editor composite
*/
void setVisualEditorComposite( Composite visualEditorComposite );
/**
* Gets the connection.
*
* @return the connection
*/
IBrowserConnection getConnection();
/**
* Sets the connection.
*
* @param connection the connection
*/
void setConnection( IBrowserConnection connection );
/**
* Saves widget settings.
*/
void saveWidgetSettings();
/**
* @return The ACL context in use
*/
OpenLdapAclValueWithContext getContext();
/**
* @param context The ACL context in use
*/
void setContext( OpenLdapAclValueWithContext context );
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSaslSsfComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSaslSsfComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSaslSsf;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseSaslSsfComposite extends AbstractWhoClauseCryptoStrengthComposite<AclWhoClauseSaslSsf>
{
public WhoClauseSaslSsfComposite( OpenLdapAclValueWithContext context, AclWhoClauseSaslSsf clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseSaslSsfComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseSaslSsf(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseStarComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseStar;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhatClauseStarComposite extends AbstractClauseComposite
{
public WhatClauseStarComposite( OpenLdapAclValueWithContext context, AclWhatClauseStar clause, Composite visualEditorComposite )
{
super( context, visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.eclipse.swt.widgets.Composite;
/**
* A basic common abstract class implementing {@link ClauseComposite}.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractWhoClauseComposite<C> extends AbstractClauseComposite
{
/** The Who clause */
protected C whoClause;
/**
* Creates a new instance of AbstractClauseComposite.
*/
public AbstractWhoClauseComposite()
{
}
/**
* Creates a new instance of AbstractClauseComposite.
*
* @param whoClause the clause
*/
public AbstractWhoClauseComposite( OpenLdapAclValueWithContext context, C whoClause, Composite visualEditorComposite )
{
super( context, visualEditorComposite );
this.whoClause = whoClause;
}
/**
* {@inheritDoc}
*/
public C getClause()
{
return whoClause;
}
/**
* {@inheritDoc}
*/
public void setClause( C clause )
{
this.whoClause = clause;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSsfComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSsfComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSsf;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseSsfComposite extends AbstractWhoClauseCryptoStrengthComposite<AclWhoClauseSsf>
{
public WhoClauseSsfComposite( OpenLdapAclValueWithContext context, AclWhoClauseSsf clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseSsfComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseSsf(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseTransportSsfComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseTransportSsfComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseTransportSsf;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseTransportSsfComposite extends AbstractWhoClauseCryptoStrengthComposite<AclWhoClauseTransportSsf>
implements
WhoClauseComposite<AclWhoClauseTransportSsf>
{
public WhoClauseTransportSsfComposite( OpenLdapAclValueWithContext context, AclWhoClauseTransportSsf clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseTransportSsfComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseTransportSsf(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseDnAttributeComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseDnAttributeComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseDnAttr;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseDnAttributeComposite extends AbstractWhoClauseComposite<AclWhoClauseDnAttr>
{
private Combo dnAttributeCombo;
public WhoClauseDnAttributeComposite( OpenLdapAclValueWithContext context, AclWhoClauseDnAttr clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseDnAttributeComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseDnAttr(), visualEditorComposite );
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
// DN
BaseWidgetUtils.createLabel( composite, "DN Attribute:", 1 );
dnAttributeCombo = BaseWidgetUtils.createCombo( composite, new String[0], -1, 1 );
GridData gd = new GridData( GridData.FILL_HORIZONTAL );
gd.horizontalSpan = 1;
gd.widthHint = 200;
dnAttributeCombo.setLayoutData( gd );
return composite;
}
/**
* {@inheritDoc}
*/
public void setClause( AclWhoClauseDnAttr clause )
{
super.setClause( clause );
setInput();
}
/**
* {@inheritDoc}
*/
public void setConnection( IBrowserConnection connection )
{
super.setConnection( connection );
setInput();
}
private void setInput()
{
if ( dnAttributeCombo != null )
{
if ( whoClause != null )
{
dnAttributeCombo.setText( whoClause.getAttribute() );
}
else
{
dnAttributeCombo.setText( "" );
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/AbstractWhoClauseCryptoStrengthComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Spinner;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AbstractAclWhoClauseCryptoStrength;
import org.apache.directory.studio.openldap.config.acl.widgets.AclWhoClauseSsfValuesEnum;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*
* @param <C>
*/
public class AbstractWhoClauseCryptoStrengthComposite<C extends AbstractAclWhoClauseCryptoStrength> extends
AbstractWhoClauseComposite<C>
{
/** The array of SSF who clause values */
private static final AclWhoClauseSsfValuesEnum[] aclWhoClauseSsfValues = new AclWhoClauseSsfValuesEnum[]
{
AclWhoClauseSsfValuesEnum.ANY,
AclWhoClauseSsfValuesEnum.FORTY,
AclWhoClauseSsfValuesEnum.FIFTY_SIX,
AclWhoClauseSsfValuesEnum.SIXTY_FOUR,
AclWhoClauseSsfValuesEnum.ONE_TWENTY_HEIGHT,
AclWhoClauseSsfValuesEnum.ONE_SIXTY_FOUR,
AclWhoClauseSsfValuesEnum.TWO_FIFTY_SIX,
AclWhoClauseSsfValuesEnum.CUSTOM
};
/** The SSF values combo viewer */
private ComboViewer ssfValuesComboViewer;
/** The custom SSF value spinner */
private Spinner customSsfValueSpinner;
/** The current SSF value */
private AclWhoClauseSsfValuesEnum currentSsfValue;
/**
* Creates a new instance of AbstractWhoClauseCryptoStrengthComposite.
*
* @param clause the clause
* @param visualEditorComposite the visual editor composite
*/
public AbstractWhoClauseCryptoStrengthComposite( OpenLdapAclValueWithContext context, C clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
// SSF Value Label
BaseWidgetUtils.createLabel( composite, "SSF Value:", 1 );
// SSF Values Combo Viewer
ssfValuesComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo(
composite, new String[0], -1, 1 ) );
ssfValuesComboViewer.getCombo().setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false ) );
ssfValuesComboViewer.setContentProvider( new ArrayContentProvider() );
ssfValuesComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof AclWhoClauseSsfValuesEnum )
{
AclWhoClauseSsfValuesEnum value = ( AclWhoClauseSsfValuesEnum ) element;
switch ( value )
{
case ANY:
return "1 (Any)";
case FORTY:
return "40";
case FIFTY_SIX:
return "56";
case SIXTY_FOUR:
return "64";
case ONE_TWENTY_HEIGHT:
return "128";
case ONE_SIXTY_FOUR:
return "164";
case TWO_FIFTY_SIX:
return "256";
case CUSTOM:
return "Custom";
}
}
return super.getText( element );
}
} );
ssfValuesComboViewer.setInput( aclWhoClauseSsfValues );
ssfValuesComboViewer.setSelection( new StructuredSelection( aclWhoClauseSsfValues[0] ) );
ssfValuesComboViewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
// Getting the selected who clause
AclWhoClauseSsfValuesEnum ssfValue = ( AclWhoClauseSsfValuesEnum ) ( ( StructuredSelection ) ssfValuesComboViewer
.getSelection() ).getFirstElement();
// Only changing the UI when the clause is different
if ( currentSsfValue != ssfValue )
{
// Storing the current value
currentSsfValue = ssfValue;
// Making the spinner hidden/visible (depending on the choice
customSsfValueSpinner.setVisible( AclWhoClauseSsfValuesEnum.CUSTOM.equals( currentSsfValue ) );
// Refreshing the layout of the parent composite
visualEditorComposite.layout( true, true );
}
}
} );
// Custom SSF Value Spinner
customSsfValueSpinner = new Spinner( composite, SWT.BORDER );
customSsfValueSpinner.setMinimum( 1 );
customSsfValueSpinner.setTextLimit( 4 );
customSsfValueSpinner.setVisible( false );
customSsfValueSpinner.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
System.out.println( customSsfValueSpinner.getSelection() );
}
} );
return composite;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseTlsSsfComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseTlsSsfComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseTlsSsf;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseTlsSsfComposite extends AbstractWhoClauseCryptoStrengthComposite<AclWhoClauseTlsSsf>
{
public WhoClauseTlsSsfComposite( OpenLdapAclValueWithContext context, AclWhoClauseTlsSsf clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseTlsSsfComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseTlsSsf(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseAnonymousComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseAnonymous;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseAnonymousComposite extends AbstractWhoClauseComposite<AclWhoClauseAnonymous>
{
public WhoClauseAnonymousComposite( OpenLdapAclValueWithContext context, AclWhoClauseAnonymous clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseAnonymousComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseAnonymous(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseDnComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClause;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseDn;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseDnTypeEnum;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhatClauseDnComposite extends AbstractClauseComposite
{
/** The entry widget */
private EntryWidget entryWidget;
/** The modify listener */
private WidgetModifyListener modifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
((AclWhatClauseDn)context.getAclItem().getWhatClause()).setPattern( entryWidget.getDn().toString() );
}
};
public WhatClauseDnComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, visualEditorComposite );
AclWhatClause whatClause = context.getAclItem().getWhatClause();
if ( whatClause == null )
{
context.getAclItem().setWhatClause( new AclWhatClauseDn() );
}
}
public Composite createComposite( Composite parent )
{
Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
// DN
BaseWidgetUtils.createLabel( composite, "DN:", 1 );
entryWidget = new EntryWidget();
entryWidget.createWidget( composite );
entryWidget.addWidgetModifyListener( modifyListener );
// Type
BaseWidgetUtils.createLabel( composite, "Type:", 1 );
ComboViewer whatClauseDnTypeComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo( composite,
new String[0], -1, 1 ) );
whatClauseDnTypeComboViewer.getCombo().setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) );
whatClauseDnTypeComboViewer.setContentProvider( new ArrayContentProvider() );
whatClauseDnTypeComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof AclWhatClauseDnTypeEnum )
{
return (( AclWhatClauseDnTypeEnum ) element).getName();
}
return super.getText( element );
}
} );
whatClauseDnTypeComboViewer.setInput( AclWhatClauseDnTypeEnum.values() );
return composite;
}
/**
* {@inheritDoc}
*/
public void setConnection( IBrowserConnection connection )
{
super.setConnection( connection );
setInput();
}
private void setInput()
{
if ( entryWidget != null )
{
if ( context.getAclItem().getWhatClause() != null )
{
try
{
entryWidget.setInput( connection, new Dn( ((AclWhatClauseDn)context.getAclItem().getWhatClause()).getPattern() ) );
}
catch ( LdapInvalidDnException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
entryWidget.setInput( connection, null );
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhatClauseAttributesComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClause;
import org.apache.directory.studio.openldap.config.acl.model.AclWhatClauseAttributes;
import org.apache.directory.studio.openldap.config.acl.widgets.AttributesWidget;
/**
* The WhatClause Attribute form. It contains only the AttributeWidget :
*
* <pre>
* ...
* | .--------------------------------------------------------. |
* | | Attribute list : | |
* | | +-------------------------------------------+ | |
* | | | abc | (Add) | |
* | | | !def | (Edit) | |
* | | | entry | (Delete) | |
* | | +-------------------------------------------+ | |
* | | Val : [ ] MatchingRule : [ ] Style : [--------------] | |
* | | Value : [////////////////////////////////////////////] | |
* | `--------------------------------------------------------' |
* ...
* </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhatClauseAttributesComposite extends AbstractClauseComposite
{
/** The attributes widget */
private AttributesWidget attributesWidget;
/**
* Create a WhatClauseAttributesComposite instance
* <pre>
* ...
* | .--------------------------------------------------------. |
* | | Attribute list : | |
* | | +-------------------------------------------+ | |
* | | | abc | (Add) | |
* | | | !def | (Edit) | |
* | | | entry | (Delete) | |
* | | +-------------------------------------------+ | |
* | | Val : [ ] MatchingRule : [ ] Style : [--------------] | |
* | | Value : [////////////////////////////////////////////] | |
* | `--------------------------------------------------------' |
* ...
* </pre>
*
* @param visualEditorComposite The parent composite
* @param attributesSubComposite The Parent sub-composite
* @param context The OpenLdapAclValueWithContext instance
*/
public WhatClauseAttributesComposite( Composite visualEditorComposite, Composite attributesSubComposite, OpenLdapAclValueWithContext context )
{
super( context, visualEditorComposite );
Composite whatComposite = BaseWidgetUtils.createColumnContainer( attributesSubComposite, 2, 1 );
// Create the Attributes clause if it does not already exist
AclWhatClause aclWhatClause = context.getAclItem().getWhatClause();
if ( aclWhatClause.getAttributesClause() == null )
{
aclWhatClause.setAttributesClause( new AclWhatClauseAttributes() );
}
// The Attribute widget
BaseWidgetUtils.createLabel( whatComposite, "", 1 );
attributesWidget = new AttributesWidget();
attributesWidget.createWidget( whatComposite, connection, aclWhatClause.getAttributesClause() );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSelfComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseSelfComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseSelf;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseSelfComposite extends AbstractWhoClauseComposite<AclWhoClauseSelf>
{
public WhoClauseSelfComposite( OpenLdapAclValueWithContext context, AclWhoClauseSelf clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseSelfComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseSelf(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseStarComposite.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/widgets/composites/WhoClauseStarComposite.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.widgets.composites;
import org.eclipse.swt.widgets.Composite;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.model.AclWhoClauseStar;
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoClauseStarComposite extends AbstractWhoClauseComposite<AclWhoClauseStar>
{
public WhoClauseStarComposite( OpenLdapAclValueWithContext context, AclWhoClauseStar clause, Composite visualEditorComposite )
{
super( context, clause, visualEditorComposite );
}
public WhoClauseStarComposite( OpenLdapAclValueWithContext context, Composite visualEditorComposite )
{
super( context, new AclWhoClauseStar(), visualEditorComposite );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/wrapper/AclAttributeDecorator.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/wrapper/AclAttributeDecorator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.wrapper;
import org.apache.directory.studio.common.ui.TableDecorator;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.openldap.config.acl.dialogs.AclAttributeDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
/**
* The AclAttribute decorator class.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AclAttributeDecorator extends TableDecorator<AclAttributeWrapper>
{
/** The associated image, if any */
private Image image;
/**
* Create a new instance of AclAttributeDecorator
* @param parentShell The parent Shell
* @param connection The Connection to the LDAP server
*/
public AclAttributeDecorator( Shell parentShell, IBrowserConnection connection )
{
setDialog( new AclAttributeDialog( parentShell, connection ) );
}
/**
* Adds an Image to this decorator
* @param image The Image
*/
public void setImage( Image image )
{
this.image = image;
}
/**
* Construct the label for a AclAttribute.
*
* @param element the Element for which we want the value
* @return a String representation of the element
*/
public String getText( Object element )
{
if ( element instanceof AclAttributeWrapper )
{
return ( ( AclAttributeWrapper ) element ).getAclAttribute().toString();
}
return super.getText( element );
};
/**
* Get the image. Here, We have none
*
* @param element The element for which we want the image
* @return The associated Image, or Null
*/
public Image getImage( Object element )
{
return image;
};
/**
* {@inheritDoc}
*/
@Override
public int compare( AclAttributeWrapper e1, AclAttributeWrapper e2 )
{
if ( e1 != null )
{
if ( e2 == null )
{
return 1;
}
else
{
return e1.compareTo( e2 );
}
}
else
{
if ( e2 == null )
{
return 0;
}
else
{
return 1;
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/wrapper/AclAttributeWrapper.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/wrapper/AclAttributeWrapper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.wrapper;
import org.apache.directory.studio.openldap.config.acl.model.AclAttribute;
/**
* The wrapper around an AclAttribute class.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AclAttributeWrapper implements Cloneable, Comparable<AclAttributeWrapper>
{
/** The AclAttribute */
private AclAttribute aclAttribute;
/**
* Creates a new instance of AclAttributeWrapper.
*/
public AclAttributeWrapper()
{
// Default to ExtensibleObject
aclAttribute = new AclAttribute( "extensibleObject", null );
}
/**
* Creates a new instance of AclAttributeWrapper.
*
* @param aclAttribute the aclAttribute
*/
public AclAttributeWrapper( AclAttribute aclAttribute )
{
this.aclAttribute = aclAttribute;
}
/**
* @return the value
*/
public AclAttribute getAclAttribute()
{
return aclAttribute;
}
/**
* @param aclAttribute the aclAttribute to set
*/
public void setAclAttribute( AclAttribute aclAttribute )
{
this.aclAttribute = aclAttribute;
}
/**
* @param aclAttribute the aclAttribute to set
*/
public void setAclAttribute( String name )
{
this.aclAttribute = new AclAttribute( name, null );
}
/**
* Clone the current object
*/
public AclAttributeWrapper clone()
{
try
{
return (AclAttributeWrapper)super.clone();
}
catch ( CloneNotSupportedException e )
{
return null;
}
}
/**
* @see Object#equals(Object)
*/
public boolean equals( Object that )
{
// Quick test
if ( this == that )
{
return true;
}
if ( that instanceof AclAttributeWrapper )
{
AclAttributeWrapper thatInstance = (AclAttributeWrapper)that;
return aclAttribute.getName().equalsIgnoreCase( thatInstance.aclAttribute.getName() ) &&
( aclAttribute.isAttributeType() && thatInstance.aclAttribute.isAttributeType() ||
( ( aclAttribute.isObjectClass() || aclAttribute.isObjectClassNotAllowed() ) &&
( thatInstance.aclAttribute.isObjectClass() || thatInstance.aclAttribute.isObjectClassNotAllowed() ) ) );
}
else
{
return false;
}
}
/**
* @see Object#hashCode()
*/
public int hashCode()
{
int h = 37;
if ( aclAttribute != null )
{
h += h*17 + aclAttribute.getName().hashCode();
}
return h;
}
/**
* @see Comparable#compareTo()
*/
public int compareTo( AclAttributeWrapper that )
{
if ( that == null )
{
return 1;
}
// Check the AclAttribute
return aclAttribute.getName().compareToIgnoreCase( that.getAclAttribute().getName() );
}
/**
* @see Object#toString()
*/
public String toString()
{
return aclAttribute.toString();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/AclAttributeDialog.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/AclAttributeDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.dialogs;
import org.apache.directory.api.ldap.model.schema.SchemaUtils;
import org.apache.directory.api.util.Strings;
import org.apache.directory.studio.common.ui.AddEditDialog;
import org.apache.directory.studio.common.ui.CommonUIConstants;
import org.apache.directory.studio.common.ui.CommonUIPlugin;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.openldap.config.acl.model.AclAttribute;
import org.apache.directory.studio.openldap.config.acl.wrapper.AclAttributeWrapper;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* This Dialog is used to add a new AclAttribute.
*
* <pre>
* +---------------------------------------------+
* | ACL Attribute |
* | .-----------------------------------------. |
* | | (o) Attribute | |
* | | (o) Entry | |
* | | (o) Children | |
* | | (o) ObjectClass | |
* | | (o) ObjectClass exclusion | |
* | | | |
* | | Value : [/////////////////////////////] | |
* | '-----------------------------------------' |
* | |
* | (Cancel) (OK) |
* +---------------------------------------------+
* </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AclAttributeDialog extends AddEditDialog<AclAttributeWrapper>
{
/** The connection to the LDAP server */
private IBrowserConnection connection;
// The UI widgets
/** The Attribute checkbox */
private Button attributeCheckbox;
/** The entry checkbox */
private Button entryCheckbox;
/** The children checkbox */
private Button childrenCheckbox;
/** The OjectClass checkbox */
private Button objectClassCheckbox;
/** The OjectClass Exclusioncheckbox */
private Button objectClassExclusionCheckbox;
/** The Attribute Value text */
private Text attributevalueText;
/** A flag set when we clear the AttributeValue text */
private boolean clearText;
/** A listener for the AttributeCheckBox */
private SelectionListener attributeCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
Button selection = (Button)e.getSource();
if ( selection.getSelection() )
{
// Clear the AttributeValue Text and disable it
clearText = true;
attributevalueText.setText( "" );
attributevalueText.setEnabled( true );
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
}
};
/** A listener for the EntryCheckBox */
private SelectionListener entryCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
Button selection = (Button)e.getSource();
if ( selection.getSelection() )
{
// Clear the AttributeValue Text and disable it
clearText = true;
attributevalueText.setText( "" );
attributevalueText.setEnabled( false );
getEditedElement().getAclAttribute().setName( "entry" );
getButton( IDialogConstants.OK_ID ).setEnabled( true );
}
}
};
/** A listener for the ChildrenCheckBox */
private SelectionListener childrenCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
Button selection = (Button)e.getSource();
if ( selection.getSelection() )
{
// Clear the AttributeValue Text and disable it
clearText = true;
attributevalueText.setText( "" );
attributevalueText.setEnabled( false );
getEditedElement().getAclAttribute().setName( "children" );
getButton( IDialogConstants.OK_ID ).setEnabled( true );
}
}
};
/** A listener for the ObjectClassCheckBox */
private SelectionListener objectClassCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
Button selection = (Button)e.getSource();
if ( selection.getSelection() )
{
// Clear the AttributeValue Text and enable it
clearText = true;
attributevalueText.setText( "" );
attributevalueText.setEnabled( true );
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
}
};
/** A listener for the ObjectClassExclusionCheckBox */
private SelectionListener objectClassExclusionCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
Button selection = (Button)e.getSource();
if ( selection.getSelection() )
{
// Clear the AttributeValue Text and enable it
clearText = true;
attributevalueText.setText( "" );
attributevalueText.setEnabled( true );
getButton( IDialogConstants.OK_ID ).setEnabled( false );
}
}
};
/** A listener for the AttributeValuetext */
private ModifyListener attributeValueTextListener = new ModifyListener()
{
@Override
public void modifyText( ModifyEvent e )
{
// if the text has been clear by a button, don't do anything but switch the flag
if ( clearText )
{
clearText = false;
return;
}
Button okButton = getButton( IDialogConstants.OK_ID );
// This button might be null when the dialog is called.
if ( okButton == null )
{
return;
}
String attributeValue = attributevalueText.getText();
boolean isAttribute = attributeCheckbox.getSelection();
boolean isObjectClass = objectClassCheckbox.getSelection();
boolean isObjectExclusionClass = objectClassExclusionCheckbox.getSelection();
boolean isEntry = entryCheckbox.getSelection();
boolean isChildren = childrenCheckbox.getSelection();
// Check that is a valid name, if needed
if ( isAttribute || isObjectClass || isObjectExclusionClass )
{
if ( Strings.isEmpty( attributeValue ) )
{
okButton.setEnabled( false );
return;
}
if ( !SchemaUtils.isAttributeNameValid( attributeValue) )
{
okButton.setEnabled( false );
return;
}
}
// Handle the various use cases
String result;
if ( isAttribute )
{
// This is an attribute
result = attributeValue;
}
else if ( isEntry )
{
// This is the special attribute value Entry
result = AclAttribute.ENTRY;
}
else if ( isChildren )
{
// This is the special attribute value Children
result = AclAttribute.CHILDREN;
}
else if ( isObjectClass )
{
// This is an ObjectClass
StringBuilder buffer = new StringBuilder();
buffer.append( AclAttribute.OC ).append( attributeValue );
result = buffer.toString();
}
else
{
// This is an ObjectClass exclusion
StringBuilder buffer = new StringBuilder( AclAttribute.OC_EX );
buffer.append( AclAttribute.OC_EX ).append( attributeValue );
result = buffer.toString();
}
getEditedElement().setAclAttribute( result );
// Check that the element does not already exist
if ( getElements().contains( getEditedElement() ) )
{
attributevalueText.setForeground( CommonUIPlugin.getDefault().getColor( CommonUIConstants.ERROR_COLOR ) );
okButton.setEnabled( false );
}
else
{
attributevalueText.setForeground( CommonUIPlugin.getDefault().getColor( CommonUIConstants.DEFAULT_COLOR ) );
okButton.setEnabled( true );
}
}
};
/**
* Creates a new instance of AclAttributeDialog.
*
* @param shell the parent shell
*/
public AclAttributeDialog( Shell shell, IBrowserConnection connection )
{
super( shell );
//shell.setText( Messages.getString( "AclAttribute.Title" ) );
this.connection = connection;
}
/**
* Create the Dialog for AclAttribute :
* <pre>
* +---------------------------------------------+
* | ACL Attribute |
* | .-----------------------------------------. |
* | | (o) Attribute | |
* | | (o) entry | |
* | | (o) children | |
* | | (o) ObjectClass | |
* | | (o) ObjectClass exclusion | |
* | | | |
* | | Value : [/////////////////////////////] | |
* | '-----------------------------------------' |
* | |
* | (Cancel) (OK) |
* +---------------------------------------------+
* </pre>
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = ( Composite ) super.createDialogArea( parent );
GridData gd = new GridData( GridData.FILL_BOTH );
composite.setLayoutData( gd );
createAclAttributeEditGroup( composite );
initDialog();
applyDialogFont( composite );
return composite;
}
/**
* Creates the AclAttribute input group.
*
* <pre>
* ACL Attribute
* .-----------------------------------------.
* | (o) Attribute |
* | (o) entry |
* | (o) children |
* | (o) ObjectClass |
* | (o) ObjectClass exclusion |
* | |
* | Value : [/////////////////////////////] |
* '-----------------------------------------'
* </pre>
* @param parent the parent composite
*/
private void createAclAttributeEditGroup( Composite parent )
{
// Disallow Feature Group
Group aclAttributeGroup = BaseWidgetUtils.createGroup( parent, "", 1 );
GridLayout aclAttributeGridLayout = new GridLayout( 2, false );
aclAttributeGroup.setLayout( aclAttributeGridLayout );
aclAttributeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// The Attribute checkbox
attributeCheckbox = BaseWidgetUtils.createRadiobutton( aclAttributeGroup, "Attribute", 2 );
attributeCheckbox.addSelectionListener( attributeCheckboxListener );
// The entry checkbox
entryCheckbox = BaseWidgetUtils.createRadiobutton( aclAttributeGroup, "Entry", 2 );
entryCheckbox.addSelectionListener( entryCheckboxListener );
// The children checkbox
childrenCheckbox = BaseWidgetUtils.createRadiobutton( aclAttributeGroup, "Children", 2 );
childrenCheckbox.addSelectionListener( childrenCheckboxListener );
// The OjectClass checkbox
objectClassCheckbox = BaseWidgetUtils.createRadiobutton( aclAttributeGroup, "ObjectClass", 2 );
objectClassCheckbox.addSelectionListener( objectClassCheckboxListener );
// The OjectClass Exclusioncheckbox
objectClassExclusionCheckbox = BaseWidgetUtils.createRadiobutton( aclAttributeGroup, "ObjectClass Exclusion", 2 );
objectClassExclusionCheckbox.addSelectionListener( objectClassExclusionCheckboxListener );
// The Value Text
BaseWidgetUtils.createLabel( aclAttributeGroup, "Value : ", 1 );
attributevalueText = BaseWidgetUtils.createText( aclAttributeGroup, "", 1 );
attributevalueText.addModifyListener( attributeValueTextListener );
}
@Override
protected void initDialog()
{
AclAttributeWrapper editedElement = (AclAttributeWrapper)getEditedElement();
if ( editedElement != null )
{
AclAttribute aclAttribute = editedElement.getAclAttribute();
if ( aclAttribute.isEntry() )
{
entryCheckbox.setEnabled( true );
}
else if ( aclAttribute.isChildren() )
{
childrenCheckbox.setEnabled( true );
}
else if ( aclAttribute.isAttributeType() )
{
attributeCheckbox.setEnabled( true );
attributevalueText.setText( CommonUIUtils.getTextValue( aclAttribute.getName() ) );
}
else if ( aclAttribute.isObjectClass() )
{
objectClassCheckbox.setEnabled( true );
attributevalueText.setText( CommonUIUtils.getTextValue( aclAttribute.getName() ) );
}
else
{
objectClassExclusionCheckbox.setEnabled( true );
attributevalueText.setText( CommonUIUtils.getTextValue( aclAttribute.getName() ) );
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void addNewElement()
{
// Default to none
setEditedElement( new AclAttributeWrapper( new AclAttribute( "", connection ) ) );
}
/**
* Add an Element that will be edited
*
* @param editedElement The element to edit
*/
public void addNewElement( AclAttributeWrapper editedElement )
{
AclAttributeWrapper newElement = (AclAttributeWrapper)editedElement.clone();
setEditedElement( newElement );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.dialogs;
import java.text.ParseException;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPlugin;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPluginConstants;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
import org.apache.directory.studio.openldap.config.acl.widgets.OpenLdapAclTabFolderComposite;
/**
* The OpenLDAP ACL Dialog is used to edit ACL values on an OpenLDAP server connection.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenLdapAclDialog extends Dialog
{
/** The ID for the 'Format' button */
private static final int FORMAT_BUTTON = 999999;
/** The ID for the 'Check Syntax' button */
private static final int CHECK_SYNTAX_BUTTON = 999998;
/** The context containing the initial value, passed by the constructor */
private OpenLdapAclValueWithContext context;
/** The ACL value */
private String aclValue;
/** The precendence checkbox */
private Button precedenceCheckbox;
/** The precedence spinner */
private Spinner precedenceSpinner;
/** The precedence flag */
private int precedence;
/** The tab folder composite */
private OpenLdapAclTabFolderComposite tabFolderComposite;
/**
* A listener on the Precedence Checkbox. It will enable or disable the precedence spinner.
*/
private SelectionAdapter precedenceCheckBoxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
precedenceSpinner.setEnabled( precedenceCheckbox.getSelection() );
}
};
/**
* The precedence spinner modify listener
*/
private ModifyListener precedenceSpinnerModifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
precedence = precedenceSpinner.getSelection();
}
};
/**
* Creates a new instance of OpenLdapAclDialog.
*
* @param parentShell the parent shell
* @param context the ACL context
*/
public OpenLdapAclDialog( Shell parentShell, OpenLdapAclValueWithContext context )
{
super( parentShell );
super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
this.context = context;
context.setAclDialog( this );
}
/**
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell( Shell shell )
{
super.configureShell( shell );
shell.setText( "OpenLDAP ACL Editor" );
shell.setImage( OpenLdapAclEditorPlugin.getDefault().getImage( OpenLdapAclEditorPluginConstants.IMG_EDITOR ) );
}
/**
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
protected void createButtonsForButtonBar( Composite parent )
{
createButton( parent, FORMAT_BUTTON, "Format", false );
createButton( parent, CHECK_SYNTAX_BUTTON, "Check Syntax", false );
createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
}
/**
* {@inheritDoc}
*
* This implementation checks if the Format button was pressed.
*/
protected void buttonPressed( int buttonId )
{
if ( buttonId == FORMAT_BUTTON )
{
tabFolderComposite.format();
}
if ( buttonId == CHECK_SYNTAX_BUTTON )
{
try
{
tabFolderComposite.getInput();
MessageDialog.openInformation( getShell(), "Correct Syntax", "Correct Syntax" );
}
catch ( ParseException pe )
{
IStatus status = new Status( IStatus.ERROR, OpenLdapAclEditorPluginConstants.PLUGIN_ID, 1,
"Invalid syntax.", pe );
ErrorDialog.openError( getShell(), "Syntax Error", null, status );
}
}
// call super implementation
super.buttonPressed( buttonId );
}
/**
* {@inheritDoc}
*/
protected void okPressed()
{
try
{
aclValue = tabFolderComposite.getInput();
tabFolderComposite.saveWidgetSettings();
super.okPressed();
}
catch ( ParseException pe )
{
IStatus status = new Status( IStatus.ERROR, OpenLdapAclEditorPluginConstants.PLUGIN_ID, 1,
"Invalid syntax.", pe );
ErrorDialog.openError( getShell(), "Syntax Error", null, status );
}
}
/**
* Return the OK button instance
*/
public Button getOKButton()
{
return getButton( IDialogConstants.OK_ID );
}
/**
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = ( Composite ) super.createDialogArea( parent );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 4 / 3;
gd.heightHint = convertVerticalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 4 / 3;
composite.setLayoutData( gd );
// Creating UI : first the precedence
createPrecedenceGroup( composite );
// the tab for the source/visual editor
createTabFolderComposite( composite );
// Setting default focus on the composite
composite.setFocus();
applyDialogFont( composite );
return composite;
}
/**
* Creates the precedence group. We handle the checkbox and the value for precedence.
*
* <pre>
* +-----------------------------------------+
* | [ ] Precedence : [---] 8 |
* +-----------------------------------------+
* </pre>
* @param parent the parent composite
*/
private void createPrecedenceGroup( Composite parent )
{
// Precendence group
Group precendenceGroup = BaseWidgetUtils.createGroup( parent, "", 1 );
GridLayout precedenceGroupLayout = new GridLayout( 2, false );
precedenceGroupLayout.horizontalSpacing = precedenceGroupLayout.verticalSpacing = 10;
precendenceGroup.setLayout( precedenceGroupLayout );
GridData gd2 = new GridData( SWT.FILL, SWT.NONE, true, false );
precendenceGroup.setLayoutData( gd2 );
// Precendence values
precedence = context.getPrecedence();
// Precedence checkbox
precedenceCheckbox = BaseWidgetUtils.createCheckbox( precendenceGroup, "Precedence:", 1 );
precedenceCheckbox.setSelection( context.hasPrecedence() );
precedenceCheckbox.addSelectionListener( precedenceCheckBoxSelectionListener );
// Precedence spinner
precedenceSpinner = new Spinner( precendenceGroup, SWT.BORDER );
precedenceSpinner.setEnabled( context.hasPrecedence() );
precedenceSpinner.setSelection( precedence );
precedenceSpinner.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, true, false ) );
precedenceSpinner.addModifyListener( precedenceSpinnerModifyListener );
}
/**
* Creates the tab folder composite.
*
* @param parent the parent composite
*/
private void createTabFolderComposite( Composite parent )
{
// Creating the tab folder composite
tabFolderComposite = new OpenLdapAclTabFolderComposite( parent, context, SWT.NONE );
tabFolderComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
}
/**
* Gets the ACL value.
*
* @return the ACL value
*/
public String getAclValue()
{
return aclValue;
}
/**
* @return the precedence value
*/
public int getPrecedence()
{
return precedence;
}
/**
* @return whether precedence is used or not
*/
public boolean hasPrecedence()
{
return precedence != -1;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java | plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.openldap.config.acl.dialogs;
import java.util.List;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPlugin;
import org.apache.directory.studio.openldap.config.acl.OpenLdapAclEditorPluginConstants;
import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevel;
import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevelLevelEnum;
import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevelPrivModifierEnum;
import org.apache.directory.studio.openldap.config.acl.model.AclAccessLevelPrivilegeEnum;
/**
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenLdapAccessLevelDialog extends Dialog
{
/** The array of access levels */
private Object[] levels = new Object[]
{
new AccessLevelComboViewerName(),
AclAccessLevelLevelEnum.MANAGE,
AclAccessLevelLevelEnum.WRITE,
AclAccessLevelLevelEnum.READ,
AclAccessLevelLevelEnum.SEARCH,
AclAccessLevelLevelEnum.COMPARE,
AclAccessLevelLevelEnum.AUTH,
AclAccessLevelLevelEnum.DISCLOSE,
AclAccessLevelLevelEnum.NONE,
};
/** The access level */
private AclAccessLevel accessLevel;
// UI widgets
private Button okButton;
private Button selfCheckbox;
private Button levelRadioButton;
private ComboViewer levelComboViewer;
private Button customPrivilegesRadioButton;
private Button privilegeModifierEqualRadioButton;
private Button privilegeModifierPlusRadioButton;
private Button privilegeModifierMinusRadioButton;
private Button privilegeAuthCheckbox;
private Button privilegeCompareCheckbox;
private Button privilegeSearchCheckbox;
private Button privilegeReadCheckbox;
private Button privilegeWriteCheckbox;
/**
* Creates a new instance of OpenLdapAccessLevelDialog.
*
* @param accessLevel the access level
*/
public OpenLdapAccessLevelDialog( AclAccessLevel accessLevel )
{
super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
this.accessLevel = accessLevel;
}
/**
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell( Shell shell )
{
super.configureShell( shell );
shell.setText( "Access Level Editor" );
shell.setImage( OpenLdapAclEditorPlugin.getDefault().getImage( OpenLdapAclEditorPluginConstants.IMG_EDITOR ) );
}
/**
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
protected void createButtonsForButtonBar( Composite parent )
{
okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
}
protected Control createContents( Composite parent )
{
Control control = super.createContents( parent );
// Validating the dialog
validate();
return control;
}
/**
* {@inheritDoc}
*/
protected void okPressed()
{
// Self
accessLevel.setSelf( selfCheckbox.getSelection() );
// Level
if ( levelRadioButton.getSelection() )
{
Object levelSelection = ( ( StructuredSelection ) levelComboViewer.getSelection() ).getFirstElement();
if ( levelSelection instanceof AclAccessLevelLevelEnum )
{
accessLevel.setLevel( ( AclAccessLevelLevelEnum ) levelSelection );
}
else
{
accessLevel.setLevel( null );
}
}
else
{
accessLevel.setLevel( null );
}
// Custom privileges
if ( customPrivilegesRadioButton.getSelection() )
{
// Privilege modifier
accessLevel.setPrivilegeModifier( getPrivilegeModifier() );
// Privileges
accessLevel.clearPrivileges();
addPrivileges();
}
else
{
accessLevel.setPrivilegeModifier( null );
accessLevel.clearPrivileges();
}
super.okPressed();
}
/**
* Gets the privilege modifier.
*
* @return the privilege modifier
*/
private AclAccessLevelPrivModifierEnum getPrivilegeModifier()
{
if ( privilegeModifierEqualRadioButton.getSelection() )
{
return AclAccessLevelPrivModifierEnum.EQUAL;
}
else if ( privilegeModifierPlusRadioButton.getSelection() )
{
return AclAccessLevelPrivModifierEnum.PLUS;
}
else if ( privilegeModifierMinusRadioButton.getSelection() )
{
return AclAccessLevelPrivModifierEnum.MINUS;
}
return null;
}
/**
* Adds privileges.
*/
private void addPrivileges()
{
// Auth checkbox
if ( privilegeAuthCheckbox.getSelection() )
{
accessLevel.addPrivilege( AclAccessLevelPrivilegeEnum.AUTHENTICATION );
}
// Compare checkbox
if ( privilegeCompareCheckbox.getSelection() )
{
accessLevel.addPrivilege( AclAccessLevelPrivilegeEnum.COMPARE );
}
// Read checkbox
if ( privilegeReadCheckbox.getSelection() )
{
accessLevel.addPrivilege( AclAccessLevelPrivilegeEnum.READ );
}
// Search checkbox
if ( privilegeSearchCheckbox.getSelection() )
{
accessLevel.addPrivilege( AclAccessLevelPrivilegeEnum.SEARCH );
}
// Write checkbox
if ( privilegeWriteCheckbox.getSelection() )
{
accessLevel.addPrivilege( AclAccessLevelPrivilegeEnum.WRITE );
}
}
/**
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = ( Composite ) super.createDialogArea( parent );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
// gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 4 / 3;
// gd.heightHint = convertVerticalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 4 / 3;
composite.setLayoutData( gd );
// Creating UI
createSelfGroup( composite );
createLevelAndPrivilegesGroup( composite );
// Initializing the UI with the access level
initWithAccessLevel();
// Adding listeners
addListeners();
// Setting default focus on the composite
composite.setFocus();
applyDialogFont( composite );
return composite;
}
/**
* Validates the dialog.
*/
private void validate()
{
if ( levelRadioButton.getSelection() )
{
// Getting the selection of the level combo viewer
Object levelSelection = ( ( StructuredSelection ) levelComboViewer.getSelection() ).getFirstElement();
// Enabling the OK button only when the selection is a 'real' level
okButton.setEnabled( levelSelection instanceof AclAccessLevelLevelEnum );
return;
}
else if ( customPrivilegesRadioButton.getSelection() )
{
// Enabling the OK button only when at least one of privileges is checked
okButton.setEnabled( privilegeAuthCheckbox.getSelection() || privilegeCompareCheckbox.getSelection()
|| privilegeSearchCheckbox.getSelection() || privilegeReadCheckbox.getSelection()
|| privilegeWriteCheckbox.getSelection() );
return;
}
// Default case
okButton.setEnabled( true );
}
/**
* Creates the self group.
*
* @param parent the parent composite
*/
private void createSelfGroup( Composite parent )
{
Group selfGroup = BaseWidgetUtils.createGroup( parent, "", 1 );
selfGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Self Checkbox
selfCheckbox = new Button( selfGroup, SWT.CHECK );
selfCheckbox.setText( "Self" ); //$NON-NLS-1$
}
/**
* Creates the level and privileges group.
*
* @param parent the parent composite
*/
private void createLevelAndPrivilegesGroup( Composite parent )
{
// Access level and privileges group
Group levelAndPrivilegesGroup = BaseWidgetUtils.createGroup( parent, "Access Level and Privilege(s)", 1 );
levelAndPrivilegesGroup.setLayout( new GridLayout( 2, false ) );
levelAndPrivilegesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Level label and radio button
levelRadioButton = BaseWidgetUtils.createRadiobutton( levelAndPrivilegesGroup, "Level:", 1 );
levelComboViewer = new ComboViewer( BaseWidgetUtils.createReadonlyCombo( levelAndPrivilegesGroup,
new String[0], -1, 1 ) );
levelComboViewer.setContentProvider( new ArrayContentProvider() );
levelComboViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof AccessLevelComboViewerName )
{
return "< Access Level >";
}
else if ( element instanceof AclAccessLevelLevelEnum )
{
AclAccessLevelLevelEnum value = ( AclAccessLevelLevelEnum ) element;
switch ( value )
{
case MANAGE:
return "Manage";
case WRITE:
return "Write";
case READ:
return "Read";
case SEARCH:
return "Search";
case COMPARE:
return "Compare";
case AUTH:
return "Auth";
case DISCLOSE:
return "Disclose";
case NONE:
return "None";
}
}
return super.getText( element );
}
} );
levelComboViewer.setInput( levels );
// levelComboViewer.setSelection( new StructuredSelection( currentClauseSelection ) ); TODO
// Custom privileges radio button
customPrivilegesRadioButton = BaseWidgetUtils.createRadiobutton( levelAndPrivilegesGroup,
"Custom Privilege(s):", 2 );
// Custom privileges composite
Composite privilegesTabComposite = BaseWidgetUtils.createColumnContainer( levelAndPrivilegesGroup, 2, 2 );
// Custom privileges modifier group
createRadioIndent( privilegesTabComposite );
Group modifierGroup = BaseWidgetUtils.createGroup( privilegesTabComposite, "Modifier", 1 );
modifierGroup.setLayout( new GridLayout( 3, true ) );
modifierGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Custom privileges modifier radio buttons
privilegeModifierEqualRadioButton = BaseWidgetUtils.createRadiobutton( modifierGroup, "Equal (=)", 1 );
privilegeModifierEqualRadioButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeModifierPlusRadioButton = BaseWidgetUtils.createRadiobutton( modifierGroup, "Add (+)", 1 );
privilegeModifierPlusRadioButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeModifierMinusRadioButton = BaseWidgetUtils.createRadiobutton( modifierGroup, "Delete (-)", 1 );
privilegeModifierMinusRadioButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Custom privileges group
createRadioIndent( privilegesTabComposite );
Group privilegesGroup = BaseWidgetUtils.createGroup( privilegesTabComposite, "Privileges", 1 );
privilegesGroup.setLayout( new GridLayout( 3, true ) );
privilegesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Custom privileges checkboxes
privilegeAuthCheckbox = BaseWidgetUtils.createCheckbox( privilegesGroup, "Auth", 1 );
privilegeAuthCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeCompareCheckbox = BaseWidgetUtils.createCheckbox( privilegesGroup, "Compare", 1 );
privilegeCompareCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeSearchCheckbox = BaseWidgetUtils.createCheckbox( privilegesGroup, "Search", 1 );
privilegeSearchCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeReadCheckbox = BaseWidgetUtils.createCheckbox( privilegesGroup, "Read", 1 );
privilegeReadCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
privilegeWriteCheckbox = BaseWidgetUtils.createCheckbox( privilegesGroup, "Write", 1 );
privilegeWriteCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
}
/**
* Adds some space to indent radio buttons.
*
* @param parent the parent
* @param span the horizontal span
*/
public static void createRadioIndent( Composite parent )
{
Label l = new Label( parent, SWT.NONE );
GridData gd = new GridData();
gd.horizontalIndent = 10;
l.setLayoutData( gd );
}
private void initWithAccessLevel()
{
// Creating a boolean to indicate if the level is used (rather than the privileges)
boolean isLevelUsed = true;
if ( accessLevel == null )
{
// Access level can't be null, creating a new one
accessLevel = new AclAccessLevel();
}
// Self
selfCheckbox.setSelection( accessLevel.isSelf() );
// Level
AclAccessLevelLevelEnum level = accessLevel.getLevel();
if ( level != null )
{
levelComboViewer.setSelection( new StructuredSelection( level ) );
}
else
{
// Default
levelComboViewer.setSelection( new StructuredSelection( levels[0] ) );
}
// Privilege Modifier
AclAccessLevelPrivModifierEnum privilegeModifier = accessLevel.getPrivilegeModifier();
if ( privilegeModifier != null )
{
// Level is not used in that case
isLevelUsed = false;
privilegeModifierEqualRadioButton.setSelection( AclAccessLevelPrivModifierEnum.EQUAL
.equals( privilegeModifier ) );
privilegeModifierPlusRadioButton.setSelection( AclAccessLevelPrivModifierEnum.PLUS
.equals( privilegeModifier ) );
privilegeModifierMinusRadioButton.setSelection( AclAccessLevelPrivModifierEnum.MINUS
.equals( privilegeModifier ) );
}
else
{
// Default
privilegeModifierEqualRadioButton.setSelection( true );
privilegeModifierPlusRadioButton.setSelection( false );
privilegeModifierMinusRadioButton.setSelection( false );
}
// Privileges
List<AclAccessLevelPrivilegeEnum> privileges = accessLevel.getPrivileges();
privilegeAuthCheckbox.setSelection( privileges.contains( AclAccessLevelPrivilegeEnum.AUTHENTICATION ) );
privilegeCompareCheckbox.setSelection( privileges.contains( AclAccessLevelPrivilegeEnum.COMPARE ) );
privilegeSearchCheckbox.setSelection( privileges.contains( AclAccessLevelPrivilegeEnum.SEARCH ) );
privilegeReadCheckbox.setSelection( privileges.contains( AclAccessLevelPrivilegeEnum.READ ) );
privilegeWriteCheckbox.setSelection( privileges.contains( AclAccessLevelPrivilegeEnum.WRITE ) );
// Setting choice buttons
levelRadioButton.setSelection( isLevelUsed );
customPrivilegesRadioButton.setSelection( !isLevelUsed );
// Setting the enable/disable state for buttons
setButtonsEnableDisableState();
}
/**
* Sets the enable/disable state for buttons
*/
private void setButtonsEnableDisableState()
{
boolean isLevelUsed = levelRadioButton.getSelection();
levelComboViewer.getCombo().setEnabled( isLevelUsed );
privilegeModifierEqualRadioButton.setEnabled( !isLevelUsed );
privilegeModifierPlusRadioButton.setEnabled( !isLevelUsed );
privilegeModifierMinusRadioButton.setEnabled( !isLevelUsed );
privilegeAuthCheckbox.setEnabled( !isLevelUsed );
privilegeCompareCheckbox.setEnabled( !isLevelUsed );
privilegeSearchCheckbox.setEnabled( !isLevelUsed );
privilegeReadCheckbox.setEnabled( !isLevelUsed );
privilegeWriteCheckbox.setEnabled( !isLevelUsed );
}
/**
* Adds listeners to the UI widgets.
*/
private void addListeners()
{
// Level and custom privileges radio buttons
SelectionAdapter enableDisableStateAndValidateSelectionAdapter = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
setButtonsEnableDisableState();
validate();
}
};
levelRadioButton.addSelectionListener( enableDisableStateAndValidateSelectionAdapter );
customPrivilegesRadioButton.addSelectionListener( enableDisableStateAndValidateSelectionAdapter );
// Level combo viewer
levelComboViewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
validate();
}
} );
// Privilege modifier and privileges radio buttons
SelectionAdapter validateSelectionAdapter = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
validate();
}
};
privilegeModifierEqualRadioButton.addSelectionListener( validateSelectionAdapter );
privilegeModifierPlusRadioButton.addSelectionListener( validateSelectionAdapter );
privilegeModifierMinusRadioButton.addSelectionListener( validateSelectionAdapter );
privilegeAuthCheckbox.addSelectionListener( validateSelectionAdapter );
privilegeCompareCheckbox.addSelectionListener( validateSelectionAdapter );
privilegeSearchCheckbox.addSelectionListener( validateSelectionAdapter );
privilegeReadCheckbox.addSelectionListener( validateSelectionAdapter );
privilegeWriteCheckbox.addSelectionListener( validateSelectionAdapter );
}
/**
* Gets the ACL Access Level value.
*
* @return the ACL Access Level value
*/
public AclAccessLevel getAccessLevel()
{
return accessLevel;
}
/**
* A private object for the first row of the access level combo viewer.
*/
private class AccessLevelComboViewerName
{
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationContentDescriber.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationContentDescriber.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.ldif.LdifReader;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.constants.ServerDNConstants;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.ITextContentDescriber;
/**
* This class implements a ContentDescriber for ApacheDS Configuration file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApacheDS2ConfigurationContentDescriber implements ITextContentDescriber
{
/** The maximum number of entries to search before determining the file as invalid */
private static final int MAX_NUMBER_ENTRIES_SEARCH = 10;
/** The Dn of the config entry ('ou=config')*/
private Dn configEntryDn;
/** The Dn of the directory service entry ('ads-directoryServiceId=default,ou=config') */
private Dn directoryServiceDn;
/**
* Creates a new instance of ApacheDS2ConfigurationContentDescriber.
*/
public ApacheDS2ConfigurationContentDescriber()
{
// Initializing DNs
try
{
configEntryDn = new Dn( ServerDNConstants.CONFIG_DN ); //$NON-NLS-1$
directoryServiceDn = new Dn( "ads-directoryServiceId=default,ou=config" ); //$NON-NLS-1$
}
catch ( LdapInvalidDnException e )
{
// Will never occur.
}
}
/**
* {@inheritDoc}
*/
public int describe( Reader contents, IContentDescription description ) throws IOException
{
LdifReader reader = null;
try
{
reader = new LdifReader( contents );
return isValid( reader );
}
catch ( LdapException e )
{
return ITextContentDescriber.INVALID;
}
finally
{
if ( reader != null )
{
reader.close();
}
}
}
/**
* {@inheritDoc}
*/
public int describe( InputStream contents, IContentDescription description ) throws IOException
{
LdifReader reader = null;
try
{
reader = new LdifReader( contents );
return isValid( reader );
}
catch ( LdapException e )
{
return ITextContentDescriber.INVALID;
}
finally
{
if ( reader != null )
{
reader.close();
}
}
}
/**
* {@inheritDoc}
*/
public QualifiedName[] getSupportedOptions()
{
return new QualifiedName[0];
}
/**
* Indicates if the given {@link Reader} is a valid server configuration. It can either
* contain the "ou=config" entry or the "ads-directoryServiceId=default,ou=config" entry
*
* @param reader the LDIF reader
* @return
* <code>ITextContentDescriber.VALID</code> if the given LDIF reader is a valid server
* configuration, <code>ITextContentDescriber.INVALID</code> if not
*/
private int isValid( LdifReader reader )
{
int checkedEntries = 0;
boolean configEntryFound = false;
boolean directoryServiceEntryFound = false;
while ( reader.hasNext() && ( checkedEntries < MAX_NUMBER_ENTRIES_SEARCH ) )
{
if ( configEntryFound && directoryServiceEntryFound )
{
// Getting out of the loop if we found both entries
break;
}
LdifEntry entry = reader.next();
checkedEntries++;
// Checking if this is the config entry
if ( ( !configEntryFound ) &&
( configEntryDn.getName().equalsIgnoreCase( entry.getDn().getNormName() ) ) )
{
configEntryFound = true;
continue;
}
// Checking if this is the directory service entry
if ( ( !directoryServiceEntryFound ) &&
( directoryServiceDn.getName().equalsIgnoreCase( entry.getDn().getNormName() ) ) )
{
directoryServiceEntryFound = true;
continue;
}
}
// Checking if we found both entries
if ( configEntryFound && directoryServiceEntryFound )
{
return ITextContentDescriber.VALID;
}
else
{
return ITextContentDescriber.INVALID;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationPlugin.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationPlugin.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration;
import java.io.IOException;
import java.net.URL;
import java.util.PropertyResourceBundle;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader;
import org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApacheDS2ConfigurationPlugin extends AbstractUIPlugin
{
/** The shared instance */
private static ApacheDS2ConfigurationPlugin plugin;
/** The plugin properties */
private PropertyResourceBundle properties;
/** The schema manager */
private SchemaManager schemaManager;
/**
* Creates a new instance of ApacheDS2ConfigurationPlugin.
*/
public ApacheDS2ConfigurationPlugin()
{
plugin = this;
}
/**
* {@inheritDoc}
*/
public void start( BundleContext context ) throws Exception
{
super.start( context );
}
/**
* {@inheritDoc}
*/
public void stop( BundleContext context ) throws Exception
{
super.stop( context );
}
/**
* Gets the schema manager.
*
* @return the schema manager
* @throws Exception if an error occurs when initializing the schema manager
*/
public SchemaManager getSchemaManager() throws Exception
{
// Is the schema manager initialized?
if ( schemaManager == null )
{
// Initializing the schema loader and schema manager
SchemaLoader loader = new JarLdifSchemaLoader();
schemaManager = new DefaultSchemaManager( loader );
// Loading only the 'adsconfig' schema with its dependencies
schemaManager.loadWithDeps( "adsconfig" ); //$NON-NLS-1$
// Checking if no error occurred when loading the schemas
if ( schemaManager.getErrors().size() != 0 )
{
throw new Exception( Messages.getString( "ApacheDS2ConfigurationPlugin.CouldNotLoadSchemaCorrectly" ) ); //$NON-NLS-1$
}
}
return schemaManager;
}
/**
* Returns the shared instance.
*
* @return the shared instance
*/
public static ApacheDS2ConfigurationPlugin getDefault()
{
return plugin;
}
/**
* Use this method to get SWT images. Use the IMG_ constants from
* PluginConstants for the key.
*
* @param key The key (relative path to the image in filesystem)
* @return The image descriptor or null
*/
public ImageDescriptor getImageDescriptor( String key )
{
if ( key != null )
{
URL url = FileLocator.find( getBundle(), new Path( key ), null );
if ( url != null )
{
return ImageDescriptor.createFromURL( url );
}
else
{
return null;
}
}
else
{
return null;
}
}
/**
* Use this method to get SWT images. Use the IMG_ constants from
* PluginConstants for the key. A ImageRegistry is used to manage the
* the key->Image mapping.
* <p>
* Note: Don't dispose the returned SWT Image. It is disposed
* automatically when the plugin is stopped.
*
* @param keynThe key (relative path to the image in filesystem)
* @return The SWT Image or null
*/
public Image getImage( String key )
{
Image image = getImageRegistry().get( key );
if ( image == null )
{
ImageDescriptor id = getImageDescriptor( key );
if ( id != null )
{
image = id.createImage();
getImageRegistry().put( key, image );
}
}
return image;
}
/**
* Gets the plugin properties.
*
* @return the plugin properties
*/
public PropertyResourceBundle getPluginProperties()
{
if ( properties == null )
{
try
{
properties = new PropertyResourceBundle( FileLocator.openStream( this.getBundle(), new Path(
"plugin.properties" ), false ) ); //$NON-NLS-1$
}
catch ( IOException e )
{
// We can't use the PLUGIN_ID constant since loading the plugin.properties file has failed,
// So we're using a default plugin id.
getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration", Status.OK, //$NON-NLS-1$
Messages.getString( "ApacheDS2ConfigurationPlugin.UnableGetProperties" ), e ) ); //$NON-NLS-1$
}
}
return properties;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Messages.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* The class that returns messages based on a given key.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationPluginConstants.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDS2ConfigurationPluginConstants.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration;
/**
* This interface contains all the Constants used in the Plugin.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface ApacheDS2ConfigurationPluginConstants
{
/** The plug-in ID */
String PLUGIN_ID = ApacheDS2ConfigurationPluginConstants.class.getPackage().getName();
// ------
// IMAGES
// ------
String IMG_EDITOR = "resources/icons/editor.gif"; //$NON-NLS-1$
String IMG_EXPORT = "resources/icons/export.gif"; //$NON-NLS-1$
String IMG_INDEX = "resources/icons/index.png"; //$NON-NLS-1$
String IMG_IMPORT = "resources/icons/import.gif"; //$NON-NLS-1$
String IMG_EXTENDED_OPERATION = "resources/icons/extended_operation.gif"; //$NON-NLS-1$
String IMG_HORIZONTAL_ORIENTATION = "resources/icons/horizontal_orientation.gif"; //$NON-NLS-1$
String IMG_INTERCEPTOR = "resources/icons/interceptor.gif"; //$NON-NLS-1$
String IMG_NEW_SERVER_CONFIGURATION_FILE_WIZARD = "resources/icons/new_server_configuration_file_wizard.gif"; //$NON-NLS-1$
String IMG_PARTITION = "resources/icons/partition.gif"; //$NON-NLS-1$
String IMG_PARTITION_SYSTEM = "resources/icons/partition_system.gif"; //$NON-NLS-1$
String IMG_PASSWORD_POLICY = "resources/icons/password_policy.gif"; //$NON-NLS-1$
String IMG_PASSWORD_POLICY_DEFAULT = "resources/icons/password_policy_default.gif"; //$NON-NLS-1$
String IMG_REPLICATION_CONSUMER = "resources/icons/replication_consumer.gif"; //$NON-NLS-1$
String IMG_VERTICAL_ORIENTATION = "resources/icons/vertical_orientation.gif"; //$NON-NLS-1$
String CONFIG_LDIF = "config.ldif"; //$NON-NLS-1$
String OU_CONFIG = "ou=config"; //$NON-NLS-1$
String OU_CONFIG_LDIF = "ou=config.ldif"; //$NON-NLS-1$
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/PartitionsDiffComputer.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/PartitionsDiffComputer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.directory.api.ldap.model.constants.LdapConstants;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.DefaultAttribute;
import org.apache.directory.api.ldap.model.entry.DefaultModification;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Modification;
import org.apache.directory.api.ldap.model.entry.ModificationOperation;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.filter.FilterParser;
import org.apache.directory.api.ldap.model.ldif.ChangeType;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.UsageEnum;
import org.apache.directory.server.core.api.entry.ClonedServerEntry;
import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.api.partition.Partition;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* A class used to computer a difference between two partitions.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionsDiffComputer
{
/** The original partition */
private Partition originalPartition;
/** The destination partition */
private Partition destinationPartition;
/**
* Creates an instance of the PartitionsDiffComputer class
*/
public PartitionsDiffComputer()
{
}
/**
* Creates an instance of the PartitionsDiffComputer class, with an original partition
* and a distination partition
* @param originalPartition The original partition
* @param destinationPartition The destination partition
*/
public PartitionsDiffComputer( Partition originalPartition, Partition destinationPartition )
{
this.originalPartition = originalPartition;
this.destinationPartition = destinationPartition;
}
/**
* Compute the difference between two partitions
* @return The list of modified entries
* @throws Exception If the comparison has filed
*/
public List<LdifEntry> computeModifications() throws Exception
{
// Using the original partition suffix as base
// '*' for all user attributes, '+' for all operational attributes
return computeModifications( originalPartition.getSuffixDn(), new String[]
{ SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES } );
}
/**
* Compute the difference between two partitions
* @param attributeIds The list of attributes to compare
* @return The list of modified entries
* @throws Exception If the comparison has filed
*/
public List<LdifEntry> computeModifications( String[] attributeIds ) throws Exception
{
return computeModifications( originalPartition.getSuffixDn(), attributeIds );
}
/**
* Compare two partitions, checking a list of attributes
*
* @param baseDn The base DN for the partitions
* @param attributeIds The list of attributes to check
* @return The list of modifications
* @throws Exception If the comparison has filed
*/
public List<LdifEntry> computeModifications( Dn baseDn, String[] attributeIds ) throws Exception
{
// Checking partitions
checkPartitions();
return comparePartitions( baseDn, attributeIds );
}
/**
* Checks the partitions.
*
* @throws PartitionsDiffException
*/
private void checkPartitions() throws PartitionsDiffException
{
// Checking the original partition
if ( originalPartition == null )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.OriginalPartitionIsNull" ) );
}
else
{
if ( !originalPartition.isInitialized() )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.OriginalPartitionNotInitialized" ) );
}
else if ( originalPartition.getSuffixDn() == null )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.OriginalSuffixIsNull" ) );
}
}
// Checking the destination partition
if ( destinationPartition == null )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.DestinationPartitionIsNull" ) );
}
else
{
if ( !destinationPartition.isInitialized() )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.DestinationPartitionNotInitialized" ) );
}
else if ( destinationPartition.getSuffixDn() == null )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.DestinationPartitionIsNull" ) );
}
}
}
/**
* Compare the two partitions.
*
* @param baseDn the base Dn
* @param attributeIds the IDs of the attributes
* @return a list containing LDIF entries with all modifications
* @throws Exception If the operation failed
*/
public List<LdifEntry> comparePartitions( Dn baseDn, String[] attributeIds ) throws PartitionsDiffException
{
// Creating the list containing all modifications
List<LdifEntry> modifications = new ArrayList<>();
try
{
// Looking up the original base entry
Entry originalBaseEntry = originalPartition.lookup( new LookupOperationContext( null, baseDn, attributeIds ) );
if ( originalBaseEntry == null )
{
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.PartitionNotFound" ) );
}
// Creating the list containing all the original entries to be processed
// and adding it the original base entry
List<Entry> originalEntries = new ArrayList<>();
originalEntries.add( originalBaseEntry );
// Looping until all original entries are being processed
while ( !originalEntries.isEmpty() )
{
// Getting the first original entry from the list
Entry originalEntry = originalEntries.remove( 0 );
// Creating a modification entry to hold all modifications
LdifEntry modificationEntry = new LdifEntry();
modificationEntry.setDn( originalEntry.getDn() );
// Looking for the equivalent entry in the destination partition
Entry destinationEntry = destinationPartition.lookup( new LookupOperationContext( null, originalEntry
.getDn(), attributeIds ) );
if ( destinationEntry != null )
{
// Setting the changetype to delete
modificationEntry.setChangeType( ChangeType.Modify );
// Comparing both entries
compareEntries( originalEntry, destinationEntry, modificationEntry );
}
else
{
// The original entry is no longer present in the destination partition
// Setting the changetype to delete
modificationEntry.setChangeType( ChangeType.Delete );
}
// Checking if modifications occurred on the original entry
ChangeType modificationEntryChangeType = modificationEntry.getChangeType();
if ( modificationEntryChangeType != ChangeType.None )
{
if ( modificationEntryChangeType == ChangeType.Delete
|| ( modificationEntryChangeType == ChangeType.Modify && !modificationEntry
.getModifications().isEmpty() ) )
{
// Adding the modification entry to the list
modifications.add( modificationEntry );
}
}
// Creating a search operation context to get the children of the current entry
SearchOperationContext soc = new SearchOperationContext( null, originalEntry.getDn(),
SearchScope.ONELEVEL,
FilterParser.parse( originalPartition.getSchemaManager(), LdapConstants.OBJECT_CLASS_STAR ), attributeIds ); //$NON-NLS-1$
soc.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
// Looking for the children of the current entry
EntryFilteringCursor cursor = originalPartition.search( soc );
while ( cursor.next() )
{
originalEntries.add( ( ( ClonedServerEntry ) cursor.get() ).getClonedEntry() );
}
}
// Reversing the list to allow deletion of leafs first (otherwise we would be deleting
// higher nodes with children first).
// Order for modified entries does not matter.
Collections.reverse( modifications );
// Looking up the destination base entry
Entry destinationBaseEntry = destinationPartition
.lookup( new LookupOperationContext( null, baseDn, attributeIds ) );
if ( destinationBaseEntry == null )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
Messages.getString( "PartitionDiffComputer.PartitionNotFound" ) ) );
throw new PartitionsDiffException( Messages.getString( "PartitionDiffComputer.PartitionNotFound" ) );
}
// Creating the list containing all the destination entries to be processed
// and adding it the destination base entry
List<Entry> destinationEntries = new ArrayList<>();
destinationEntries.add( originalBaseEntry );
// Looping until all destination entries are being processed
while ( !destinationEntries.isEmpty() )
{
// Getting the first destination entry from the list
Entry destinationEntry = destinationEntries.remove( 0 );
// Looking for the equivalent entry in the destination partition
Entry originalEntry = originalPartition.lookup( new LookupOperationContext( null, destinationEntry
.getDn(), attributeIds ) );
// We're only looking for new entries, modified or removed
// entries have already been computed
if ( originalEntry == null )
{
// Creating a modification entry to hold all modifications
LdifEntry modificationEntry = new LdifEntry();
modificationEntry.setDn( destinationEntry.getDn() );
// Setting the changetype to addition
modificationEntry.setChangeType( ChangeType.Add );
// Copying attributes
for ( Attribute attribute : destinationEntry )
{
modificationEntry.addAttribute( attribute );
}
// Adding the modification entry to the list
modifications.add( modificationEntry );
}
// Creating a search operation context to get the children of the current entry
SearchOperationContext soc = new SearchOperationContext( null, destinationEntry.getDn(),
SearchScope.ONELEVEL,
FilterParser.parse( originalPartition.getSchemaManager(), LdapConstants.OBJECT_CLASS_STAR ), attributeIds ); //$NON-NLS-1$
soc.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
// Looking for the children of the current entry
EntryFilteringCursor cursor = destinationPartition.search( soc );
while ( cursor.next() )
{
destinationEntries.add( ( ( ClonedServerEntry ) cursor.get() ).getClonedEntry() );
}
}
}
catch ( Exception e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
Messages.getString( "PartitionDiffComputer.ComparePartitions" ) ) );
throw new PartitionsDiffException( e );
}
return modifications;
}
/**
* Compares the two given entries.
*
* @param originalEntry the original entry
* @param destinationEnt the destination entry
* @param modificationEntry the modification LDIF entry holding the modifications
* between both entries
*/
private void compareEntries( Entry originalEntry, Entry destinationEntry, LdifEntry modificationEntry )
{
// Creating a list to store the already evaluated attribute type
List<AttributeType> evaluatedATs = new ArrayList<>();
// Checking attributes of the original entry
for ( Attribute originalAttribute : originalEntry )
{
AttributeType originalAttributeType = originalAttribute.getAttributeType();
// We're only working on 'userApplications' attributes
if ( originalAttributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
{
Attribute destinationAttribute = destinationEntry.get( originalAttributeType );
if ( destinationAttribute == null )
{
// Creating a modification for the removed AT
Modification modification = new DefaultModification();
modification.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
modification.setAttribute( new DefaultAttribute( originalAttribute.getAttributeType() ) );
modificationEntry.addModification( modification );
}
else
{
// Comparing both attributes
compareAttributes( originalAttribute, destinationAttribute, modificationEntry );
}
evaluatedATs.add( originalAttributeType );
}
}
// Checking attributes of the destination entry
for ( Attribute destinationAttribute : destinationEntry )
{
AttributeType destinationAttributeType = destinationAttribute.getAttributeType();
// We're only working on 'userApplications' attributes
if ( destinationAttributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
{
// Checking if the current AT has already been evaluated
if ( !evaluatedATs.contains( destinationAttributeType ) )
{
// Creating a modification for the added AT
Modification modification = new DefaultModification();
modification.setOperation( ModificationOperation.ADD_ATTRIBUTE );
Attribute attribute = new DefaultAttribute( destinationAttributeType );
modification.setAttribute( attribute );
for ( Value value : destinationAttribute )
{
try
{
attribute.add( value );
}
catch ( LdapInvalidAttributeValueException liave )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
Messages.getString( "PartitionDiffComputer.InvalidAttributeException" ) ) );
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
liave.getLocalizedMessage() ) );
}
}
modificationEntry.addModification( modification );
}
}
}
}
/**
* Compares the two given attributes.
*
* @param originalAttribute the original attribute
* @param destinationAttribute the destination attribute
* @param modificationEntry the modification LDIF entry holding the modifications
* between both attributes
*/
private void compareAttributes( Attribute originalAttribute, Attribute destinationAttribute,
LdifEntry modificationEntry )
{
// Creating a list to store the already evaluated values
List<Value> evaluatedValues = new ArrayList<>();
// Checking values of the original attribute
for ( Value originalValue : originalAttribute )
{
if ( !destinationAttribute.contains( originalValue ) )
{
// Creating a modification for the removed AT value
Modification modification = new DefaultModification();
modification.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
Attribute attribute = new DefaultAttribute( originalAttribute.getAttributeType() );
modification.setAttribute( attribute );
try
{
attribute.add( originalValue );
}
catch ( LdapInvalidAttributeValueException liave )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
Messages.getString( "PartitionDiffComputer.InvalidAttributeException" ) ) );
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
liave.getLocalizedMessage() ) );
}
modificationEntry.addModification( modification );
}
evaluatedValues.add( originalValue );
}
// Checking values of the destination attribute
for ( Value destinationValue : destinationAttribute )
{
if ( !evaluatedValues.contains( destinationValue ) )
{
// Creating a modification for the added AT value
Modification modification = new DefaultModification();
modification.setOperation( ModificationOperation.ADD_ATTRIBUTE );
Attribute attribute = new DefaultAttribute( originalAttribute.getAttributeType() );
modification.setAttribute( attribute );
try
{
attribute.add( destinationValue );
}
catch ( LdapInvalidAttributeValueException liave )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
Messages.getString( "PartitionDiffComputer.InvalidAttributeException" ) ) );
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
liave.getLocalizedMessage() ) );
}
modificationEntry.addModification( modification );
}
}
}
/**
* Gets the original partition.
*
* @return the original partition
*/
public Partition getOriginalPartition()
{
return originalPartition;
}
/**
* Sets the original partition.
*
* @param originalPartition the original partition
*/
public void setOriginalPartition( Partition originalPartition )
{
this.originalPartition = originalPartition;
}
/**
* Gets the destination partition.
*
* @return the destination partition
*/
public Partition getDestinationPartition()
{
return destinationPartition;
}
/**
* Sets the destination partition.
*
* @param destinationPartition the destination partition
*/
public void setDestinationPartition( Partition destinationPartition )
{
this.destinationPartition = destinationPartition;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/SaveConfigurationRunnable.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/SaveConfigurationRunnable.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
import java.io.File;
import org.apache.directory.studio.apacheds.configuration.editor.ConnectionServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.NewServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditorUtils;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPathEditorInput;
/**
* This class implements a {@link Job} that is used to save a server configuration.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class SaveConfigurationRunnable implements StudioRunnableWithProgress
{
/** The associated editor */
private ServerConfigurationEditor editor;
/**
* Creates a new instance of SaveConfigurationRunnable.
*
* @param editor the editor
*/
public SaveConfigurationRunnable( ServerConfigurationEditor editor )
{
super();
this.editor = editor;
}
/**
* {@inheritDoc}
*/
public String getErrorMessage()
{
return Messages.getString( "SaveConfigurationRunnable.UnableToSaveConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public Object[] getLockedObjects()
{
return new Object[0];
}
/**
* {@inheritDoc}
*/
public String getName()
{
return Messages.getString( "SaveConfigurationRunnable.SaveConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public void run( StudioProgressMonitor monitor )
{
try
{
if ( editor.isDirty() )
{
monitor.beginTask( Messages.getString( "SaveConfigurationRunnable.SavingServerConfiguration" ), //$NON-NLS-1$
IProgressMonitor.UNKNOWN );
IEditorInput input = editor.getEditorInput();
String inputClassName = input.getClass().getName();
boolean success = false;
// If the input is a ConnectionServerConfigurationInput, then we
// read the server configuration from the selected connection
if ( input instanceof ConnectionServerConfigurationInput )
{
// Saving the ServerConfiguration to the connection
ServerConfigurationEditorUtils.saveConfiguration( ( ConnectionServerConfigurationInput ) input,
editor.getConfigWriter(), monitor );
success = true;
}
else if ( input instanceof IPathEditorInput )
{
// Saving the ServerConfiguration to disk
File file = ( ( IPathEditorInput ) input ).getPath().toFile();
ServerConfigurationEditorUtils.saveConfiguration( file, editor.getConfigWriter(),
editor.getConfiguration() );
success = true;
}
else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" ) //$NON-NLS-1$
|| inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) ) //$NON-NLS-1$
// The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
// is used when opening a file from the menu File > Open... in Eclipse 3.2.x
// The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
// opening a file from the menu File > Open... in Eclipse 3.3.x
{
// Saving the ServerConfiguration to disk
File file = new File( input.getToolTipText() );
ServerConfigurationEditorUtils.saveConfiguration( file, editor.getConfigWriter(),
editor.getConfiguration() );
success = true;
}
else if ( input instanceof NewServerConfigurationInput )
{
// The 'ServerConfigurationEditorInput' class is used when a
// new Server Configuration File is created.
// We are saving this as if it is a "Save as..." action.
success = editor.doSaveAs( monitor );
}
editor.setDirty( !success );
}
}
catch ( Exception e )
{
// Reporting the error to the monitor
monitor.reportError( e );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/Messages.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.osgi.util.NLS;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages extends NLS
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/PartitionsDiffException.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/PartitionsDiffException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
/**
* This exception can be raised when an error occurs when computing the diff
* between two partitions.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionsDiffException extends Exception
{
private static final long serialVersionUID = 1L;
/**
* Constructs a new PartitionsDiffException with <code>null</code> as its detail message.
*/
public PartitionsDiffException()
{
super();
}
/**
* Constructs a new PartitionsDiffException with the specified detail message and cause.
*
* @param message the message
* @param cause the cause
*/
public PartitionsDiffException( String message, Throwable cause )
{
super( message, cause );
}
/**
* Constructs a new PartitionsDiffException with the specified detail message.
*
* @param message the message
*/
public PartitionsDiffException( String message )
{
super( message );
}
/**
* Constructs a new exception with the specified cause and a detail message
* of <code>(cause==null ? null : cause.toString())</code>
*
* @param cause the cause
*/
public PartitionsDiffException( Throwable cause )
{
super( cause );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/LoadConfigurationRunnable.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/LoadConfigurationRunnable.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.constants.LdapConstants;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.server.config.ConfigPartitionInitializer;
import org.apache.directory.server.config.ConfigPartitionReader;
import org.apache.directory.server.config.ReadOnlyConfigurationPartition;
import org.apache.directory.server.config.beans.ConfigBean;
import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.api.DnFactory;
import org.apache.directory.server.core.api.InstanceLayout;
import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
import org.apache.directory.server.core.partition.ldif.LdifPartition;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.editor.Configuration;
import org.apache.directory.studio.apacheds.configuration.editor.ConnectionServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.NewServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.IConnectionListener;
import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.connection.core.io.api.StudioSearchResult;
import org.apache.directory.studio.connection.core.io.api.StudioSearchResultEnumeration;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.osgi.framework.Bundle;
/**
* This class implements a {@link Job} that is used to load a server configuration.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LoadConfigurationRunnable implements StudioRunnableWithProgress
{
/** The associated editor */
private ServerConfigurationEditor editor;
/**
* Creates a new instance of LoadConfigurationRunnable.
*
* @param editor the editor
*/
public LoadConfigurationRunnable( ServerConfigurationEditor editor )
{
super();
this.editor = editor;
}
/**
* {@inheritDoc}
*/
public String getErrorMessage()
{
return Messages.getString( "LoadConfigurationRunnable.UnableToLoadConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public Object[] getLockedObjects()
{
return new Object[0];
}
/**
* {@inheritDoc}
*/
public String getName()
{
return Messages.getString( "LoadConfigurationRunnable.LoadConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public void run( StudioProgressMonitor monitor )
{
IEditorInput input = editor.getEditorInput();
try
{
final Configuration configuration = getConfiguration( input, monitor );
if ( configuration != null )
{
Display.getDefault().asyncExec( new Runnable()
{
public void run()
{
editor.configurationLoaded( configuration );
}
} );
}
}
catch ( Exception e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
e.getMessage() ) );
// Reporting the error to the monitor
monitor.reportError( e );
// Reporting the error to the editor
final Exception exception = e;
Display.getDefault().asyncExec( new Runnable()
{
public void run()
{
editor.configurationLoadFailed( exception );
}
} );
}
}
/**
* Gets the configuration from the input.
*
* @param input the editor input
* @param monitor the studio progress monitor
* @return the configuration
* @throws Exception If the configuration wasn't correctly read
*/
public Configuration getConfiguration( IEditorInput input, StudioProgressMonitor monitor ) throws Exception
{
String inputClassName = input.getClass().getName();
// If the input is a NewServerConfigurationInput, then we only
// need to get the server configuration and return
if ( input instanceof NewServerConfigurationInput )
{
Bundle bundle = Platform.getBundle( "org.apache.directory.server.config" );
URL resource = bundle.getResource( "config.ldif" );
InputStream is = resource.openStream();
return readSingleFileConfiguration( is );
}
// If the input is a ConnectionServerConfigurationInput, then we
// read the server configuration from the selected connection
if ( input instanceof ConnectionServerConfigurationInput )
{
return readConfiguration( ( ConnectionServerConfigurationInput ) input, monitor );
}
else if ( input instanceof FileEditorInput )
// The 'FileEditorInput' class is used when the file is opened
// from a project in the workspace.
{
File file = ( ( FileEditorInput ) input ).getFile().getLocation().toFile();
return readConfiguration( file );
}
else if ( input instanceof IPathEditorInput )
{
File file = ( ( IPathEditorInput ) input ).getPath().toFile();
return readConfiguration( file );
}
else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" ) //$NON-NLS-1$
|| inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) ) //$NON-NLS-1$
// The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
// is used when opening a file from the menu File > Open... in Eclipse 3.2.x
// The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
// opening a file from the menu File > Open... in Eclipse 3.3.x
{
// We use the tooltip to get the full path of the file
File file = new File( input.getToolTipText() );
return readConfiguration( file );
}
return null;
}
/**
* Reads the configuration from the given input stream.
*
* @param is the input stream
* @return the associated configuration bean
* @throws Exception if we weren't able to load the configuration
*/
public static Configuration readConfiguration( File file ) throws Exception
{
if ( file != null )
{
if(file.getName().equals( ApacheDS2ConfigurationPluginConstants.CONFIG_LDIF )) {
return readSingleFileConfiguration( file );
}
else if(file.getName().equals( ApacheDS2ConfigurationPluginConstants.OU_CONFIG_LDIF )) {
return readMultiFileConfigureation( file.getParentFile() );
}
}
return null;
}
private static Configuration readSingleFileConfiguration( File configLdifFile ) throws Exception
{
InputStream is = new FileInputStream( configLdifFile );
// Reading the configuration partition
return readSingleFileConfiguration( is );
}
private static Configuration readSingleFileConfiguration( InputStream is ) throws Exception
{
// Creating a partition associated from the input stream
ReadOnlyConfigurationPartition configurationPartition = new ReadOnlyConfigurationPartition( is,
ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager() );
configurationPartition.initialize();
// Reading the configuration partition
return readConfiguration( configurationPartition );
}
private static synchronized Configuration readMultiFileConfigureation( File confDirectory ) throws Exception
{
InstanceLayout instanceLayout = new InstanceLayout( confDirectory.getParentFile() );
SchemaManager schemaManager = ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager();
DnFactory dnFactory = null;
ConfigPartitionInitializer init = new ConfigPartitionInitializer( instanceLayout, dnFactory, schemaManager );
LdifPartition configurationPartition = init.initConfigPartition();
return readConfiguration( configurationPartition );
}
/**
* Reads the configuration from the given partition.
*
* @param partition the configuration partition
* @return the associated configuration bean
* @throws LdapException if we weren't able to load the configuration
*/
private static Configuration readConfiguration( AbstractBTreePartition partition ) throws LdapException
{
if ( partition != null )
{
ConfigPartitionReader cpReader = new ConfigPartitionReader( partition );
ConfigBean configBean = cpReader.readConfig();
return new Configuration( configBean, partition );
}
return null;
}
/**
* Reads the configuration from the given connection.
*
* @param input the editor input
* @param monitor the studio progress monitor
* @return the associated configuration bean
* @throws Exception if we weren't able to load the configuration
*/
private Configuration readConfiguration( ConnectionServerConfigurationInput input, StudioProgressMonitor monitor ) throws Exception
{
if ( input != null )
{
SchemaManager schemaManager = ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager();
// Getting the browser connection associated with the connection in the input
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( input.getConnection() );
// Creating and initializing the configuration partition
EntryBasedConfigurationPartition configurationPartition = new EntryBasedConfigurationPartition(
schemaManager );
configurationPartition.initialize();
// Opening the connection
openConnection( input, monitor );
// Creating the search parameter
SearchParameter configSearchParameter = new SearchParameter();
configSearchParameter.setSearchBase( new Dn( ServerDNConstants.CONFIG_DN ) ); //$NON-NLS-1$
//configSearchParameter.setSearchBase( new Dn( "ou=config" ) ); //$NON-NLS-1$
configSearchParameter.setFilter( LdapConstants.OBJECT_CLASS_STAR ); //$NON-NLS-1$
configSearchParameter.setScope( SearchScope.OBJECT );
configSearchParameter.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
// Looking for the 'ou=config' base entry
Entry configEntry = null;
StudioSearchResultEnumeration enumeration = SearchRunnable.search( browserConnection, configSearchParameter,
monitor );
// Checking if an error occurred
if ( monitor.errorsReported() )
{
throw monitor.getException();
}
// Getting the entry
if ( enumeration.hasMore() )
{
// Creating the 'ou=config' base entry
StudioSearchResult searchResult = enumeration.next();
configEntry = new DefaultEntry( schemaManager, searchResult.getEntry() );
}
enumeration.close();
// Verifying we found the 'ou=config' base entry
if ( configEntry == null )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
Messages.getString( "LoadConfigurationRunnable.UnableToFindConfigBaseEntry" ) ) );
throw new LdapNoSuchObjectException(
Messages.getString( "LoadConfigurationRunnable.UnableToFindConfigBaseEntry" ) ); //$NON-NLS-1$
}
// Creating a list to hold the entries that need to be checked
// for children and added to the partition
List<Entry> entries = new ArrayList<Entry>();
entries.add( configEntry );
// Looping on the entries list until it's empty
while ( !entries.isEmpty() )
{
// Removing the first entry from the list
Entry entry = entries.remove( 0 );
// Adding the entry to the partition
configurationPartition.addEntry( entry );
SearchParameter searchParameter = new SearchParameter();
searchParameter.setSearchBase( entry.getDn() );
searchParameter.setFilter( LdapConstants.OBJECT_CLASS_STAR ); //$NON-NLS-1$
searchParameter.setScope( SearchScope.ONELEVEL );
searchParameter.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
// Looking for the children of the entry
StudioSearchResultEnumeration childrenEnumeration = SearchRunnable.search( browserConnection,
searchParameter, monitor );
// Checking if an error occurred
if ( monitor.errorsReported() )
{
throw monitor.getException();
}
while ( childrenEnumeration.hasMore() )
{
// Adding the children to the list of entries
StudioSearchResult searchResult = childrenEnumeration.next();
entries.add( new DefaultEntry( schemaManager, searchResult.getEntry() ) );
}
childrenEnumeration.close();
}
// Setting the created partition to the input
input.setOriginalPartition( configurationPartition );
return readConfiguration( configurationPartition );
}
return null;
}
/**
* Opens the connection.
*
* @param input the input
* @param monitor the monitor
*/
private void openConnection( ConnectionServerConfigurationInput input, StudioProgressMonitor monitor )
{
Connection connection = input.getConnection();
if ( connection != null && !connection.getConnectionWrapper().isConnected() )
{
connection.getConnectionWrapper().connect( monitor );
if ( connection.getConnectionWrapper().isConnected() )
{
connection.getConnectionWrapper().bind( monitor );
}
if ( connection.getConnectionWrapper().isConnected() )
{
for ( IConnectionListener listener : ConnectionCorePlugin.getDefault()
.getConnectionListeners() )
{
listener.connectionOpened( connection, monitor );
}
ConnectionEventRegistry.fireConnectionOpened( connection, input );
}
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/EntryBasedConfigurationPartition.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/jobs/EntryBasedConfigurationPartition.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.jobs;
import java.util.UUID;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.partition.ldif.AbstractLdifPartition;
/**
* This class implements a read-only configuration partition.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EntryBasedConfigurationPartition extends AbstractLdifPartition
{
/**
* Creates a new instance of ReadOnlyConfigurationPartition.
*
* @param inputStream the input stream
* @param schemaManager the schema manager
*/
public EntryBasedConfigurationPartition( SchemaManager schemaManager )
{
super( schemaManager );
}
/**
* {@inheritDoc}
*/
protected void doInit() throws LdapException
{
setId( "config" ); //$NON-NLS-1$
setSuffixDn( new Dn( ServerDNConstants.CONFIG_DN ) ); //$NON-NLS-1$
super.doInit();
}
/**
* Adds the given entry.
*
* @param entry the entry
* @throws Exception
*/
public void addEntry( Entry entry ) throws Exception
{
// Adding mandatory operational attributes
addMandatoryOpAt( entry );
// Storing the entry
add( new AddOperationContext( null, entry ) );
}
/**
* Adds the CSN and UUID attributes to the entry if they are not present.
*/
private void addMandatoryOpAt( Entry entry ) throws LdapException
{
// entryCSN
if ( entry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
{
entry.add( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
}
// entryUUID
if ( entry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
{
String uuid = UUID.randomUUID().toString();
entry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ReplicationPage extends ServerConfigurationEditorPage
{
/** The Page ID */
public static final String ID = ReplicationPage.class.getName();
/** The Page Title */
private static final String TITLE = Messages.getString( "ReplicationPage.Replication" ); //$NON-NLS-1$
/** The Master Details Block */
private ReplicationMasterDetailsBlock masterDetailsBlock;
/**
* Creates a new instance of ReplicationPage.
*
* @param editor
* the associated editor
*/
public ReplicationPage( ServerConfigurationEditor editor )
{
super( editor, ID, TITLE );
}
/**
* {@inheritDoc}
*/
protected void createFormContent( Composite parent, FormToolkit toolkit )
{
masterDetailsBlock = new ReplicationMasterDetailsBlock( this );
masterDetailsBlock.createContent( getManagedForm() );
}
/**
* {@inheritDoc}
*/
protected void refreshUI()
{
if ( isInitialized() )
{
masterDetailsBlock.refreshUI();
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/JdbmPartitionSpecificDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/JdbmPartitionSpecificDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This class implements a specific details block for the JDBM partition.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class JdbmPartitionSpecificDetailsBlock extends AbstractPartitionSpecificDetailsBlock<JdbmPartitionBean>
{
// UI widgets
private Text cacheSizeText;
private Button enableOptimizerCheckbox;
/**
* Creates a new instance of JdbmPartitionSpecificDetailsBlock.
*
* @param detailsPage the details page
* @param partition the partition
*/
public JdbmPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, JdbmPartitionBean partition )
{
super( detailsPage, partition );
}
/**
* {@inheritDoc}
*/
public Composite createBlockContent( Composite parent, FormToolkit toolkit )
{
// Composite
Composite composite = toolkit.createComposite( parent );
composite.setLayout( new GridLayout( 2, false ) );
composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Cache Size
toolkit.createLabel( composite, Messages.getString( "PartitionDetailsPage.CacheSize" ) ); //$NON-NLS-1$
cacheSizeText = toolkit.createText( composite, "" ); //$NON-NLS-1$
cacheSizeText.addVerifyListener( new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
e.doit = false;
}
}
} );
cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Enable Optimizer
enableOptimizerCheckbox = toolkit.createButton( composite,
Messages.getString( "PartitionDetailsPage.EnableOptimzer" ), SWT.CHECK ); //$NON-NLS-1$
enableOptimizerCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
return composite;
}
/**
* Adds the listeners.
*/
private void addListeners()
{
cacheSizeText.addModifyListener( dirtyModifyListener );
enableOptimizerCheckbox.addSelectionListener( dirtySelectionListener );
}
/**
* Removes the listeners
*/
private void removeListeners()
{
cacheSizeText.removeModifyListener( dirtyModifyListener );
enableOptimizerCheckbox.removeSelectionListener( dirtySelectionListener );
}
/**
* {@inheritDoc}
*/
public void refresh()
{
removeListeners();
if ( partition != null )
{
// Cache Size
cacheSizeText.setText( "" + partition.getPartitionCacheSize() ); //$NON-NLS-1$
// Enable Optimizer
enableOptimizerCheckbox.setSelection( partition.isJdbmPartitionOptimizerEnabled() );
}
addListeners();
}
/**
* {@inheritDoc}
*/
public void commit( boolean onSave )
{
if ( partition != null )
{
// Cache Size
try
{
partition.setPartitionCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
}
catch ( NumberFormatException nfe )
{
// Nothing to do
}
// Enable Optimizer
partition.setJdbmPartitionOptimizerEnabled( enableOptimizerCheckbox.getSelection() );
}
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/MavibotPartitionSpecificDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/MavibotPartitionSpecificDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.MavibotPartitionBean;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This class implements a specific details block for the Mavibot partition.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class MavibotPartitionSpecificDetailsBlock extends AbstractPartitionSpecificDetailsBlock<MavibotPartitionBean>
{
/**
* Creates a new instance of MavibotPartitionSpecificDetailsBlock.
*
* @param detailsPage the details page
* @param partition the partition
*/
public MavibotPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, MavibotPartitionBean partition )
{
super( detailsPage, partition );
}
/**
* {@inheritDoc}
*/
public Composite createBlockContent( Composite parent, FormToolkit toolkit )
{
// Composite
Composite composite = toolkit.createComposite( parent );
composite.setLayout( new GridLayout() );
composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Information Label
toolkit.createLabel( composite, "No specific settings for a Mavibot partition." );
return composite;
}
/**
* {@inheritDoc}
*/
public void refresh()
{
// Nothing to do
}
/**
* {@inheritDoc}
*/
public void commit( boolean onSave )
{
// Nothing to do
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.IndexBean;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
import org.apache.directory.server.config.beans.PartitionBean;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.forms.DetailsPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.MasterDetailsBlock;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
/**
* This class represents the Partitions Master/Details Block used in the Partitions Page.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionsMasterDetailsBlock extends MasterDetailsBlock
{
private static final String NEW_ID = Messages.getString( "PartitionsMasterDetailsBlock.PartitionNewId" ); //$NON-NLS-1$
/** The associated page */
private PartitionsPage page;
/** The Details Page */
private PartitionDetailsPage detailsPage;
/** The partition wrappers */
private List<PartitionWrapper> partitionWrappers = new ArrayList<PartitionWrapper>();
// UI Fields
private TableViewer viewer;
private Button addButton;
private Button deleteButton;
/**
* Creates a new instance of PartitionsMasterDetailsBlock.
*
* @param page
* the associated page
*/
public PartitionsMasterDetailsBlock( PartitionsPage page )
{
this.page = page;
}
/**
* {@inheritDoc}
*/
protected void createMasterPart( final IManagedForm managedForm, Composite parent )
{
FormToolkit toolkit = managedForm.getToolkit();
// Creating the Section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( Messages.getString( "PartitionsMasterDetailsBlock.AllPartitions" ) ); //$NON-NLS-1$
section.marginWidth = 10;
section.marginHeight = 5;
Composite client = toolkit.createComposite( section, SWT.WRAP );
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout( layout );
toolkit.paintBordersFor( client );
section.setClient( client );
// Creating the Table and Table Viewer
Table table = toolkit.createTable( client, SWT.NULL );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
gd.heightHint = 20;
gd.widthHint = 100;
table.setLayoutData( gd );
final SectionPart spart = new SectionPart( section );
managedForm.addPart( spart );
viewer = new TableViewer( table );
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
managedForm.fireSelectionChanged( spart, event.getSelection() );
}
} );
viewer.setContentProvider( new ArrayContentProvider() );
viewer.setLabelProvider( PartitionsPage.PARTITIONS_LABEL_PROVIDER );
viewer.setComparator( PartitionsPage.PARTITIONS_COMPARATOR );
// Creating the button(s)
addButton = toolkit.createButton( client, Messages.getString( "PartitionsMasterDetailsBlock.Add" ), SWT.PUSH ); //$NON-NLS-1$
addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
deleteButton = toolkit.createButton( client,
Messages.getString( "PartitionsMasterDetailsBlock.Delete" ), SWT.PUSH ); //$NON-NLS-1$
deleteButton.setEnabled( false );
deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
initFromInput();
addListeners();
}
/**
* Initializes the page with the Editor input.
*/
private void initFromInput()
{
partitionWrappers.clear();
for ( PartitionBean partition : page.getConfigBean().getDirectoryServiceBean().getPartitions() )
{
partitionWrappers.add( new PartitionWrapper( partition ) );
}
viewer.setInput( partitionWrappers );
}
/**
* Refreshes the UI.
*/
public void refreshUI()
{
initFromInput();
viewer.refresh();
}
/**
* Add listeners to UI fields.
*/
private void addListeners()
{
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
viewer.refresh();
// Getting the selection of the table viewer
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
// Delete button is enabled when something is selected
deleteButton.setEnabled( !selection.isEmpty() );
// Delete button is not enabled in the case of the system partition
if ( !selection.isEmpty() )
{
PartitionWrapper partitionWrapper = ( PartitionWrapper ) selection.getFirstElement();
if ( PartitionsPage.isSystemPartition( partitionWrapper.getPartition() ) )
{
deleteButton.setEnabled( false );
}
}
}
} );
addButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
addNewPartition();
}
} );
deleteButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
deleteSelectedPartition();
}
} );
}
/**
* This method is called when the 'Add' button is clicked.
*/
private void addNewPartition()
{
String newId = getNewId();
JdbmPartitionBean newPartitionBean = new JdbmPartitionBean();
newPartitionBean.setPartitionId( newId );
try
{
newPartitionBean.setPartitionSuffix( new Dn( "dc=" + newId + ",dc=com" ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
catch ( LdapInvalidDnException e1 )
{
// Will never happen
}
// Default values
newPartitionBean.setPartitionCacheSize( 100 );
newPartitionBean.setJdbmPartitionOptimizerEnabled( true );
newPartitionBean.setPartitionSyncOnWrite( true );
newPartitionBean.setContextEntry( getContextEntryLdif( newPartitionBean.getPartitionSuffix() ) );
List<IndexBean> indexes = new ArrayList<IndexBean>();
indexes.add( createJdbmIndex( "apacheAlias", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheOneAlias", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheOneLevel", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apachePresence", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheRdn", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheSubAlias", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheSubLevel", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "dc", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "entryCSN", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "entryUUID", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "krb5PrincipalName", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "objectClass", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "ou", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "uid", 100 ) ); //$NON-NLS-1$
newPartitionBean.setIndexes( indexes );
PartitionWrapper newPartitionWrapper = new PartitionWrapper( newPartitionBean );
partitionWrappers.add( newPartitionWrapper );
viewer.refresh();
viewer.setSelection( new StructuredSelection( newPartitionWrapper ) );
setEditorDirty();
}
/**
* Gets a new ID for a new Partition.
*
* @return
* a new ID for a new Partition
*/
private String getNewId()
{
int counter = 1;
String name = NEW_ID;
boolean ok = false;
while ( !ok )
{
ok = true;
name = NEW_ID + counter;
for ( PartitionBean partition : page.getConfigBean().getDirectoryServiceBean().getPartitions() )
{
if ( partition.getPartitionId().equalsIgnoreCase( name ) )
{
ok = false;
}
}
counter++;
}
return name;
}
/**
* Creates the context entry for the partition.
*
* @param dn the dn
* @return the LDIF representation of the context entry
*/
public static String getContextEntryLdif( Dn dn )
{
try
{
Entry entry = new DefaultEntry( dn );
entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.DOMAIN_OC );
entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
// Getting the RDN from the DN
Rdn rdn = dn.getRdn();
if ( !SchemaConstants.DC_AT.equalsIgnoreCase( rdn.getType() ) )
{
entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.EXTENSIBLE_OBJECT_OC );
entry.add( SchemaConstants.DC_AT, rdn.getValue() );
}
entry.add( rdn.getType(), rdn.getValue() );
LdifEntry ldifEntry = new LdifEntry( entry );
return ldifEntry.toString();
}
catch ( Exception e )
{
return null;
}
}
/**
* This method is called when the 'Delete' button is clicked.
*/
private void deleteSelectedPartition()
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
PartitionWrapper partitionWrapper = ( PartitionWrapper ) selection.getFirstElement();
PartitionBean partition = partitionWrapper.getPartition();
if ( !PartitionsPage.isSystemPartition( partition ) )
{
if ( MessageDialog
.openConfirm(
page.getManagedForm().getForm().getShell(),
Messages.getString( "PartitionsMasterDetailsBlock.ConfirmDelete" ), //$NON-NLS-1$
NLS.bind(
Messages.getString( "PartitionsMasterDetailsBlock.AreYouSureDeletePartition" ), partition.getPartitionId(), //$NON-NLS-1$
partition.getPartitionSuffix() ) ) )
{
partitionWrappers.remove( partitionWrapper );
setEditorDirty();
}
}
}
}
/**
* Create a JDBM Index with the given index attribute id and cache size.
*
* @param indexAttributeId the attribute id
* @param indexCacheSize the cache size
*/
private JdbmIndexBean createJdbmIndex( String indexAttributeId, int indexCacheSize )
{
JdbmIndexBean index = new JdbmIndexBean();
index.setIndexAttributeId( indexAttributeId );
index.setIndexCacheSize( indexCacheSize );
return index;
}
/**
* Sets the Editor as dirty.
*/
public void setEditorDirty()
{
( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
detailsPage.commit( false );
viewer.refresh();
}
/**
* {@inheritDoc}
*/
protected void registerPages( DetailsPart detailsPart )
{
detailsPage = new PartitionDetailsPage( this );
detailsPart.registerPage( PartitionWrapper.class, detailsPage );
}
/**
* {@inheritDoc}
*/
protected void createToolBarActions( IManagedForm managedForm )
{
// TODO Auto-generated method stub
}
/**
* Gets the associated editor page.
*
* @return the associated editor page
*/
public PartitionsPage getPage()
{
return page;
}
/**
* Saves the necessary elements to the input model.
*/
public void doSave( IProgressMonitor monitor )
{
// Committing information on the details page
detailsPage.commit( true );
// Getting the directory service bean
DirectoryServiceBean directoryServiceBean = page.getConfigBean().getDirectoryServiceBean();
// Creating a new list of partitions
List<PartitionBean> newPartitions = new ArrayList<PartitionBean>();
// Saving the partitions
for ( PartitionWrapper partitionWrapper : partitionWrappers )
{
newPartitions.add( partitionWrapper.getPartition() );
}
directoryServiceBean.setPartitions( newPartitions );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionWrapper.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionWrapper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.PartitionBean;
/**
* This class defines a simple wrapper for a partition.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionWrapper
{
/** The wrapped partition */
private PartitionBean partition;
/**
* Creates a new instance of PartitionWrapper.
*
* @param partition the partition
*/
public PartitionWrapper( PartitionBean partition )
{
this.partition = partition;
}
/**
* Gets the partition.
*
* @return the partition
*/
public PartitionBean getPartition()
{
return partition;
}
/**
* Sets the partition.
*
* @param partition the partition
*/
public void setPartition( PartitionBean partition )
{
this.partition = partition;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/LoadingPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/LoadingPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
/**
* This class represents the Loading Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LoadingPage extends FormPage
{
/** The Page ID*/
public static final String ID = LoadingPage.class.getName(); //$NON-NLS-1$
/** The Page Title */
private static final String TITLE = Messages.getString( "LoadingPage.LoadingConfiguration" ); //$NON-NLS-1$
/**
* Creates a new instance of LoadingPage.
*
* @param editor
* the associated editor
*/
public LoadingPage( FormEditor editor )
{
super( editor, ID, TITLE );
}
/**
* {@inheritDoc}
*/
protected void createFormContent( IManagedForm managedForm )
{
ScrolledForm form = managedForm.getForm();
form.setText( Messages.getString( "LoadingPage.LoadingConfigurationEllipsis" ) ); //$NON-NLS-1$
Composite parent = form.getBody();
parent.setLayout( new GridLayout() );
FormToolkit toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading( form.getForm() );
Composite composite = toolkit.createComposite( parent );
composite.setLayout( new GridLayout() );
composite.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, true ) );
ProgressBar progressBar = new ProgressBar( composite, SWT.INDETERMINATE );
progressBar.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) );
Label label = toolkit.createLabel( composite,
Messages.getString( "LoadingPage.LoadingTheConfigurationPleaseWait" ) ); //$NON-NLS-1$
label.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/Configuration.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/Configuration.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.ConfigBean;
import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
import org.apache.directory.server.core.partition.ldif.AbstractLdifPartition;
/**
* Configuration of the server.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Configuration
{
private ConfigBean configBean;
private AbstractBTreePartition configPartition;
public Configuration( ConfigBean configBean, AbstractBTreePartition configPartition )
{
this.configBean = configBean;
this.configPartition = configPartition;
}
public ConfigBean getConfigBean()
{
return configBean;
}
public void setConfigBean( ConfigBean configBean )
{
this.configBean = configBean;
}
public AbstractBTreePartition getConfigPartition()
{
return configPartition;
}
public void setConfigPartition( AbstractLdifPartition configPartition )
{
this.configPartition = configPartition;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditor.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.lang.reflect.InvocationTargetException;
import org.apache.directory.server.config.ConfigWriter;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.jobs.LoadConfigurationRunnable;
import org.apache.directory.studio.apacheds.configuration.jobs.SaveConfigurationRunnable;
import org.apache.directory.studio.common.core.jobs.StudioJob;
import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
/**
* This class implements the Server Configuration Editor. This editor expose
* 6 pages into a form with 6 tags :
* <ul>
* <li>Overview : the basic configuration</li>
* <li>LDAP/LDAPS : the configuration for the LDAP/S server</li>
* <li>Kerberos : the configuration for the Kerberos server</li>
* <li>Partitions : The partitions configuration</li>
* <li>PasswordPolicy : The password policy configuration</li>
* <li>Replication : The replicationconfiguration</li>
* </ul>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ServerConfigurationEditor extends FormEditor implements IPageChangedListener
{
/** The Editor ID */
public static final String ID = ServerConfigurationEditor.class.getName();
/** The flag indicating if the editor is dirty */
private boolean dirty = false;
/** The configuration including bean and underlying parttiton */
private Configuration configuration;
/** The pages */
private LoadingPage loadingPage;
private OverviewPage overviewPage;
private LdapLdapsServersPage ldapLdapsServersPage;
private KerberosServerPage kerberosServerPage;
private PartitionsPage partitionsPage;
private PasswordPoliciesPage passwordPolicyPage;
private ReplicationPage replicationPage;
/**
* {@inheritDoc}
*/
public void init( IEditorSite site, IEditorInput input ) throws PartInitException
{
super.init( site, input );
setPartName( input.getName() );
// Checking if the input is a new server configuration file
if ( input instanceof NewServerConfigurationInput )
{
// New server configuration file have a dirty state
// set to true since they are not saved yet
setDirty( true );
}
addPageChangedListener( this );
readConfiguration();
}
/**
* Reads the configuration
*/
private void readConfiguration()
{
// Creating and scheduling the job to load the configuration
StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
new LoadConfigurationRunnable( this ) );
job.schedule();
}
/**
* {@inheritDoc}
*/
public void pageChanged( PageChangedEvent event )
{
Object selectedPage = event.getSelectedPage();
if ( selectedPage instanceof ServerConfigurationEditorPage )
{
( ( ServerConfigurationEditorPage ) selectedPage ).refreshUI();
}
}
/**
* {@inheritDoc}
*/
protected void addPages()
{
try
{
loadingPage = new LoadingPage( this );
addPage( loadingPage );
}
catch ( PartInitException e )
{
}
showOrHideTabFolder();
}
/**
* Shows or hides the tab folder depending on
* the number of pages.
*/
private void showOrHideTabFolder()
{
Composite container = getContainer();
if ( container instanceof CTabFolder )
{
CTabFolder folder = ( CTabFolder ) container;
if ( getPageCount() == 1 )
{
folder.setTabHeight( 0 );
}
else
{
folder.setTabHeight( -1 );
}
folder.layout( true, true );
}
}
/**
* {@inheritDoc}
*/
public void doSave( IProgressMonitor monitor )
{
// Saving pages
doSavePages( monitor );
// Saving the configuration using a job
StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
new SaveConfigurationRunnable( this ) );
job.schedule();
}
/**
* {@inheritDoc}
*/
public void doSaveAs()
{
try
{
getSite().getWorkbenchWindow().run( false, false, new IRunnableWithProgress()
{
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
{
try
{
monitor.beginTask(
Messages.getString( "ServerConfigurationEditor.SavingServerConfiguration" ), IProgressMonitor.UNKNOWN ); //$NON-NLS-1$
doSaveAs( monitor );
monitor.done();
}
catch ( Exception e )
{
// TODO handle the exception
}
}
} );
}
catch ( Exception e )
{
// TODO handle the exception
e.printStackTrace();
}
}
/**
* Performs the "Save as..." action.
*
* @param monitor the monitor to use
* @throws Exception
*/
public boolean doSaveAs( IProgressMonitor monitor ) throws Exception
{
// Saving pages
doSavePages( monitor );
// Saving the configuration as a new file and getting the associated new editor input
IEditorInput newInput = ServerConfigurationEditorUtils.saveAs( monitor, getSite().getShell(),
getEditorInput(), getConfigWriter(), getConfiguration(), true );
// Checking if the 'save as' is successful
boolean success = newInput != null;
if ( success )
{
// Setting the new input to the editor
setInput( newInput );
// Resetting the dirty state of the editor
setDirty( false );
// Updating the title and tooltip texts
Display.getDefault().syncExec( new Runnable()
{
public void run()
{
setPartName( getEditorInput().getName() );
}
} );
}
return success;
}
/**
* Saves the pages.
*
* @param monitor the monitor
*/
private void doSavePages( final IProgressMonitor monitor )
{
if ( partitionsPage != null )
{
Display.getDefault().syncExec( new Runnable()
{
public void run()
{
partitionsPage.doSave( monitor );
}
} );
}
}
/**
* {@inheritDoc}
*/
public boolean isSaveAsAllowed()
{
return true;
}
/**
* {@inheritDoc}
*/
public boolean isDirty()
{
return dirty;
}
/**
* Sets the 'dirty' flag.
*
* @param dirty the 'dirty' flag
*/
public void setDirty( boolean dirty )
{
this.dirty = dirty;
Display.getDefault().asyncExec( new Runnable()
{
public void run()
{
firePropertyChange( PROP_DIRTY );
}
} );
}
/**
* Gets the configuration.
*
* @return the configuration
*/
public Configuration getConfiguration()
{
return configuration;
}
/**
* Sets the configuration.
*
* @param configuration the configuration
*/
public void setConfiguration( Configuration configuration )
{
this.configuration = configuration;
}
/**
* Resets the configuration and refresh the UI.
*
* @param configuration the configuration
*/
public void resetConfiguration( Configuration configuration )
{
setConfiguration( configuration );
setDirty( true );
overviewPage.refreshUI();
ldapLdapsServersPage.refreshUI();
kerberosServerPage.refreshUI();
partitionsPage.refreshUI();
passwordPolicyPage.refreshUI();
replicationPage.refreshUI();
}
/**
* This method is called by the job responsible for loading the
* configuration when it has been fully and correctly loaded.
*
* @param configuration the configuration
*/
public void configurationLoaded( Configuration configuration )
{
setConfiguration( configuration );
hideLoadingPageAndDisplayConfigPages();
}
/**
* This method is called by the job responsible for loading the
* configuration when it failed to load it.
*
* @param exception the exception
*/
public void configurationLoadFailed( Exception exception )
{
// Overriding the default dirty setting
// (especially in the case of a new configuration file)
setDirty( false );
hideLoadingPageAndDisplayErrorPage( exception );
}
/**
* Hides the loading page and displays the standard configuration pages.
*/
private void hideLoadingPageAndDisplayConfigPages()
{
// Removing the loading page
removePage( 0 );
// Adding the configuration pages
try
{
overviewPage = new OverviewPage( this );
addPage( overviewPage );
ldapLdapsServersPage = new LdapLdapsServersPage( this );
addPage( ldapLdapsServersPage );
kerberosServerPage = new KerberosServerPage( this );
addPage( kerberosServerPage );
partitionsPage = new PartitionsPage( this );
addPage( partitionsPage );
passwordPolicyPage = new PasswordPoliciesPage( this );
addPage( passwordPolicyPage );
replicationPage = new ReplicationPage( this );
addPage( replicationPage );
}
catch ( PartInitException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// Activating the first page
setActivePage( 0 );
showOrHideTabFolder();
}
/**
* Hides the loading page and displays the error page.
*
* @param exception
* the exception
*/
private void hideLoadingPageAndDisplayErrorPage( Exception exception )
{
// Removing the loading page
removePage( 0 );
// Adding the error page
try
{
addPage( new ErrorPage( this, exception ) );
}
catch ( PartInitException e )
{
}
// Activating the first page
setActivePage( 0 );
showOrHideTabFolder();
}
/**
* Set a particular page as active if it is found in the pages vector.
*
* @param pageClass the class of the page
*/
public void showPage( Class<?> pageClass )
{
if ( pageClass != null )
{
for ( Object page : pages )
{
if ( pageClass.isInstance( page ) )
{
setActivePage( pages.indexOf( page ) );
return;
}
}
}
}
/**
* Gets the configuration writer.
*
* @return the configuration writer
* @throws Exception
*/
public ConfigWriter getConfigWriter() throws Exception
{
return new ConfigWriter( ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager(),
configuration.getConfigBean() );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/OverviewPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/OverviewPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.List;
import org.apache.directory.server.config.beans.ChangePasswordServerBean;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.KdcServerBean;
import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.server.config.beans.TransportBean;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* The Overview tab exposes 4 panels, in 2 columns :
*
* <pre>
* +-------------------------------------------------------------------------------+
* | +------------------------------------+ +------------------------------------+ |
* | | .--------------------------------. | | +--------------------------------+ | |
* | | | LDAP/LDAPS Transport | | | | Kerberos Server | | |
* | | +--------------------------------| | | +--------------------------------+ | |
* | | | [X] Enabled LDAP server | | | | [X] Enable Kerberos Server | | |
* | | | Port : [/////////] | | | | Port : [/////] | | |
* | | | [X] Enabled LDAPS server | | | | [X] Enable Kerberos ChangePwd | | |
* | | | Port : [/////////] | | | | Port : [/////] | | |
* | | | <advanced LDAP/LDAPS config> | | | | <advanced Kerberos config> | | |
* | | +--------------------------------| | | +--------------------------------+ | |
* | | .--------------------------------. | | +--------------------------------+ | |
* | | | Partitions | | | | Options | | |
* | | +--------------------------------| | | +--------------------------------+ | |
* | | | +----------------------------+ | | | | [X] Allow anonymous access | | |
* | | | | Partition 1 | | | | | [X] Enable Access Control | | |
* | | | | Partition 2 | | | | | [X] Password Hidden | | |
* | | | | ... | | | | | | | |
* | | | +----------------------------+ | | | | | | |
* | | | <advanced partitionsS config> | | | | | | |
* | | +--------------------------------+ | | +--------------------------------+ | |
* | +------------------------------------+ +------------------------------------+ |
* </pre>
*
* We just expose the more frequent parameters in this page.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OverviewPage extends ServerConfigurationEditorPage
{
/** The Page ID*/
public static final String ID = OverviewPage.class.getName(); //$NON-NLS-1$
/** The Page Title */
private static final String TITLE = Messages.getString( "OverviewPage.Overview" ); //$NON-NLS-1$
// UI Controls
/** LDAP Server controls */
private Button enableLdapCheckbox;
private Text ldapPortText;
private Button enableLdapsCheckbox;
private Text ldapsPortText;
// This link opens the advanced LDAP/LDAPS configuration tab
private Hyperlink openLdapConfigurationLink;
/** Kerberos Server controls */
private Button enableKerberosCheckbox;
private Text kerberosPortText;
private Button enableChangePasswordCheckbox;
private Text changePasswordPortText;
// This link opens the advanced kerberos configuration tab
private Hyperlink openKerberosConfigurationLink;
/** The Partitions controls */
private Label partitionsLabel;
private TableViewer partitionsTableViewer;
// This link open the advanced partitions configuration Tab */
private Hyperlink openPartitionsConfigurationLink;
/** The LDAP Options controls */
private Button allowAnonymousAccessCheckbox;
private Button enableAccessControlCheckbox;
private Button enableHiddenPasswordCheckbox;
// UI Control Listeners
/**
* The LDAP transport checkbox selection adapter.
*/
private SelectionAdapter enableLdapCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
boolean enableLdap = enableLdapCheckbox.getSelection();
LdapLdapsServersPage.getLdapServerTransportBean( getDirectoryServiceBean() ).setEnabled(
enableLdap );
setEnabled( ldapPortText, enableLdap );
}
};
/**
* The Ldap port modify listener
*/
private ModifyListener ldapPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
try
{
int port = Integer.parseInt( ldapPortText.getText() );
LdapLdapsServersPage.getLdapServerTransportBean( getDirectoryServiceBean() ).setSystemPort( port );
}
catch ( NumberFormatException nfe )
{
System.out.println( "Wrong LDAP TCP Port : it must be an integer" );
}
}
};
/**
* The LDAPS transport checkbox selection adapter
*/
private SelectionAdapter enableLdapsCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
boolean enableLdaps = enableLdapsCheckbox.getSelection();
LdapLdapsServersPage.getLdapTransportBean( getDirectoryServiceBean(), LdapLdapsServersPage.TRANSPORT_ID_LDAPS ).setEnabled(
enableLdaps );
setEnabled( ldapsPortText, enableLdaps );
}
};
/**
* The Ldaps port modify listener
*/
private ModifyListener ldapsPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
try
{
int port = Integer.parseInt( ldapsPortText.getText() );
LdapLdapsServersPage.getLdapsServerTransportBean( getDirectoryServiceBean() ).setSystemPort( port );
}
catch ( NumberFormatException nfe )
{
System.out.println( "Wrong LDAPS TCP Port : it must be an integer" );
}
}
};
/**
* The advanced LDAP/LDAPS configuration hyper link adapter
*/
private HyperlinkAdapter openLdapConfigurationLinkListener = new HyperlinkAdapter()
{
public void linkActivated( HyperlinkEvent e )
{
getServerConfigurationEditor().showPage( LdapLdapsServersPage.class );
}
};
/**
* The Kerberos server selection adpater
*/
private SelectionAdapter enableKerberosCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
boolean enableKerberos = enableKerberosCheckbox.getSelection();
KerberosServerPage.enableKerberosServer( getDirectoryServiceBean(), enableKerberos );
setEnabled( kerberosPortText, enableKerberos );
}
};
/**
* The Kerberos port listener
*/
private ModifyListener kerberosPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
KerberosServerPage.setKerberosPort( getDirectoryServiceBean(), kerberosPortText.getText() );
}
};
/**
* The ChangePassword server selection adapter
*/
private SelectionAdapter enableChangePasswordCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
ChangePasswordServerBean changePasswordServerBean = getDirectoryServiceBean().getChangePasswordServerBean();
boolean enableChangePassword = enableChangePasswordCheckbox.getSelection();
changePasswordServerBean.setEnabled( enableChangePassword );
setEnabled( changePasswordPortText, enableChangePassword );
}
};
/**
* The ChangePassword server port listener
*/
private ModifyListener changePasswordPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
KerberosServerPage.setChangePasswordPort( getDirectoryServiceBean(), changePasswordPortText.getText() );
}
};
/**
* The advanced Kerberos configuration hyperlink
*/
private HyperlinkAdapter openKerberosConfigurationLinkListener = new HyperlinkAdapter()
{
public void linkActivated( HyperlinkEvent e )
{
getServerConfigurationEditor().showPage( KerberosServerPage.class );
}
};
/**
* The advanced Partition configuration hyperlink
*/
private HyperlinkAdapter openPartitionsConfigurationLinkListener = new HyperlinkAdapter()
{
public void linkActivated( HyperlinkEvent e )
{
getServerConfigurationEditor().showPage( PartitionsPage.class );
}
};
/**
* The AllowAnonymousAccess checkbox listener
*/
private SelectionAdapter allowAnonymousAccessCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getDirectoryServiceBean().setDsAllowAnonymousAccess( allowAnonymousAccessCheckbox.getSelection() );
}
};
/**
* The AccessControl checkbox listener
*/
private SelectionAdapter enableAccessControlCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getDirectoryServiceBean().setDsAccessControlEnabled( enableAccessControlCheckbox.getSelection() );
}
};
/**
* The HiddenPassword checkbox listener
*/
private SelectionAdapter enableHiddenPasswordCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getDirectoryServiceBean().setDsPasswordHidden( enableHiddenPasswordCheckbox.getSelection() );
}
};
/**
* Creates a new instance of GeneralPage.
*
* @param editor the associated editor
*/
public OverviewPage( ServerConfigurationEditor editor )
{
super( editor, ID, TITLE );
}
/**
* Creates the global Overview Tab. It contains 2 columns, each one of
* them having two sections :
*
* <pre>
* +-----------------------------------+---------------------------------+
* | | |
* | LDAP/LDAPS configuration section | Kerberos/ChangePassword section |
* | | |
* +-----------------------------------+---------------------------------+
* | | |
* | Partition section | Options configuration section |
* | | |
* +-----------------------------------+---------------------------------+
* </pre>
*
* @param parent the parent element
* @param toolkit the form toolkit
*/
protected void createFormContent( Composite parent, FormToolkit toolkit )
{
TableWrapLayout twl = new TableWrapLayout();
twl.numColumns = 2;
parent.setLayout( twl );
// Left Composite
Composite leftComposite = toolkit.createComposite( parent );
leftComposite.setLayout( new GridLayout() );
TableWrapData leftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
leftCompositeTableWrapData.grabHorizontal = true;
leftComposite.setLayoutData( leftCompositeTableWrapData );
// Right Composite
Composite rightComposite = toolkit.createComposite( parent );
rightComposite.setLayout( new GridLayout() );
TableWrapData rightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
rightCompositeTableWrapData.grabHorizontal = true;
rightComposite.setLayoutData( rightCompositeTableWrapData );
// Creating the sections
createLdapLdapsServersSection( toolkit, leftComposite );
createPartitionsSection( toolkit, leftComposite );
createKerberosChangePasswordServersSection( toolkit, rightComposite );
createOptionsSection( toolkit, rightComposite );
// Refreshing the UI
refreshUI();
}
/**
* Creates the LDAP and LDAPS Servers section. This section is a grid with 4 columns,
* where we configure LDAPa and LDAPS servers.
* We can enable or disable those servers, and if they are enabled, we can configure
* the port.
*
* <pre>
* .--------------------------------.
* | LDAP/LDAPS Transport |
* +--------------------------------|
* | [X] Enabled LDAP server |
* | Port : [/////////] |
* | [X] Enabled LDAPS server |
* | Port : [/////////] |
* | <advanced LDAP/LDAPS config> |
* +--------------------------------|
* </pre>
*
* @param toolkit the toolkit
* @param parent the parent composite
*/
private void createLdapLdapsServersSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
int nbColumns = 4;
Composite composite = createSection( toolkit, parent, "OverviewPage.LdapLdapsServers", nbColumns, Section.TITLE_BAR );
// Enable LDAP Server Checkbox
enableLdapCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableLdapServer" ), SWT.CHECK ); //$NON-NLS-1$
enableLdapCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, nbColumns, 1 ) );
// LDAP Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "OverviewPage.Port" ) ); //$NON-NLS-1$
ldapPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, Integer.toString( DEFAULT_PORT_LDAP ) ); //$NON-NLS-1$
// Enable LDAPS Server Checkbox
enableLdapsCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableLdapsServer" ), SWT.CHECK ); //$NON-NLS-1$
enableLdapsCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, nbColumns, 1 ) );
// LDAPS Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "OverviewPage.Port" ) ); //$NON-NLS-1$
ldapsPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, Integer.toString( DEFAULT_PORT_LDAPS ) ); //$NON-NLS-1$
// LDAP Configuration Link
openLdapConfigurationLink = toolkit.createHyperlink( composite,
Messages.getString( "OverviewPage.AdvancedLdapLdapsConfiguration" ), SWT.NONE ); //$NON-NLS-1$
openLdapConfigurationLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, nbColumns, 1 ) );
openLdapConfigurationLink.addHyperlinkListener( openLdapConfigurationLinkListener );
}
/**
* Creates the Kerberos and Change Password Servers section. As for the LDAP/LDAPS
* server, we can configure the Kerberos and ChangePassword ports if they are enabled.
* <pre>
* +--------------------------------+
* | Kerberos Server |
* +--------------------------------+
* | [X] Enable Kerberos Server |
* | Port : [/////] |
* | [X] Enable Kerberos ChangePwd |
* | Port : [/////] |
* | <advanced Kerberos config> |
* +--------------------------------+
* </pre>
*
* @param toolkit the toolkit
* @param parent the parent composite
*/
private void createKerberosChangePasswordServersSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
int nbColumns = 4;
Composite composite = createSection( toolkit, parent, "OverviewPage.KerberosServer", nbColumns, Section.TITLE_BAR );
// Enable Kerberos Server Checkbox
enableKerberosCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableKerberosServer" ), SWT.CHECK ); //$NON-NLS-1$
enableKerberosCheckbox
.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, nbColumns, 1 ) );
// Kerberos Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "OverviewPage.Port" ) ); //$NON-NLS-1$
kerberosPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, Integer.toString( DEFAULT_PORT_KERBEROS ) ); //$NON-NLS-1$
// Enable Change Password Server Checkbox
enableChangePasswordCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableKerberosChangePasswordServer" ), //$NON-NLS-1$
SWT.CHECK );
enableChangePasswordCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false,
nbColumns, 1 ) );
// Change Password Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "OverviewPage.Port" ) ); //$NON-NLS-1$
changePasswordPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, Integer.toString( DEFAULT_PORT_CHANGE_PASSWORD ) ); //$NON-NLS-1$
// Kerberos Configuration Link
openKerberosConfigurationLink = toolkit.createHyperlink( composite,
Messages.getString( "OverviewPage.AdvancedKerberosConfiguration" ), SWT.NONE ); //$NON-NLS-1$
openKerberosConfigurationLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false,
nbColumns, 1 ) );
openKerberosConfigurationLink.addHyperlinkListener( openKerberosConfigurationLinkListener );
}
/**
* Creates the Partitions section. This is just an informative section,
* where we list the existing partitions.
*
* <pre>
* .--------------------------------.
* | Partitions |
* +--------------------------------|
* | +----------------------------+ |
* | | Partition 1 | |
* | | Partition 2 | |
* | | ... | |
* | +----------------------------+ |
* | <advanced partitionsS config> |
* +--------------------------------+
* </pre>
*
* @param toolkit the toolkit
* @param parent the parent composite
*/
private void createPartitionsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
int nbColumns = 1;
Composite composite = createSection( toolkit, parent, "OverviewPage.Partitions", nbColumns, Section.TITLE_BAR );
// Partitions Label
partitionsLabel = toolkit.createLabel( composite, "" ); //$NON-NLS-1$
partitionsLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Partitions Table Viewer
Table partitionsTable = toolkit.createTable( composite, SWT.NULL );
GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
gd.heightHint = 45;
partitionsTable.setLayoutData( gd );
partitionsTableViewer = new TableViewer( partitionsTable );
partitionsTableViewer.setContentProvider( new ArrayContentProvider() );
partitionsTableViewer.setLabelProvider( PartitionsPage.PARTITIONS_LABEL_PROVIDER );
partitionsTableViewer.setComparator( PartitionsPage.PARTITIONS_COMPARATOR );
// Partitions Configuration Link
openPartitionsConfigurationLink = toolkit.createHyperlink( composite,
Messages.getString( "OverviewPage.AdvancedPartitionsConfiguration" ), SWT.NONE ); //$NON-NLS-1$
openPartitionsConfigurationLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, nbColumns, 1 ) );
openPartitionsConfigurationLink.addHyperlinkListener( openPartitionsConfigurationLinkListener );
}
/**
* Creates the Options section. This section expose a few critical options that are
* generally useful (allow anonymous, or enable control access atm).
*
* <pre>
* +--------------------------------+
* | Options |
* +--------------------------------+
* | [X] Allow anonymous access |
* | [X] Enable Access Control |
* | |
* +--------------------------------+
* </pre>
*
* @param toolkit the toolkit
* @param parent the parent composite
*/
private void createOptionsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
int nbColumns = 1;
Composite composite = createSection( toolkit, parent, "OverviewPage.Options", nbColumns, Section.TITLE_BAR );
// Allow Anonymous Access Checkbox
allowAnonymousAccessCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.AllowAnonymousAccess" ), SWT.CHECK ); //$NON-NLS-1$
allowAnonymousAccessCheckbox.setLayoutData( new GridData( SWT.NONE, SWT.NONE, true, false ) );
// Enable Access Control Checkbox
enableAccessControlCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableAccessControl" ), SWT.CHECK ); //$NON-NLS-1$
enableAccessControlCheckbox.setLayoutData( new GridData( SWT.NONE, SWT.NONE, true, false ) );
// Enable Hidden Password Checkbox
enableHiddenPasswordCheckbox = toolkit.createButton( composite,
Messages.getString( "OverviewPage.EnableHiddenPassword" ), SWT.CHECK ); //$NON-NLS-1$
enableHiddenPasswordCheckbox.setLayoutData( new GridData( SWT.NONE, SWT.NONE, true, false ) );
}
/**
* Adds listeners to UI Controls.
*/
private void addListeners()
{
// Enable LDAP Checkbox
addDirtyListener( enableLdapCheckbox );
addSelectionListener( enableLdapCheckbox, enableLdapCheckboxListener );
// LDAP Port Text
addDirtyListener( ldapPortText );
addModifyListener( ldapPortText, ldapPortTextListener );
// Enable LDAPS Checkbox
addDirtyListener( enableLdapsCheckbox );
addSelectionListener( enableLdapsCheckbox, enableLdapsCheckboxListener );
// LDAPS Port Text
addDirtyListener( ldapsPortText );
addModifyListener( ldapsPortText, ldapsPortTextListener );
// Enable Kerberos Checkbox
addDirtyListener( enableKerberosCheckbox );
addSelectionListener( enableKerberosCheckbox, enableKerberosCheckboxListener );
// Kerberos Port Text
addDirtyListener( kerberosPortText );
addModifyListener( kerberosPortText, kerberosPortTextListener );
// Enable Change Password Checkbox
addDirtyListener( enableChangePasswordCheckbox );
addSelectionListener( enableChangePasswordCheckbox, enableChangePasswordCheckboxListener );
// Change Password Port Text
addDirtyListener( changePasswordPortText );
addModifyListener( changePasswordPortText, changePasswordPortTextListener );
// Allow Anonymous Access Checkbox
addDirtyListener( allowAnonymousAccessCheckbox );
addSelectionListener( allowAnonymousAccessCheckbox, allowAnonymousAccessCheckboxListener );
// Enable Access Control Checkbox
addDirtyListener( enableAccessControlCheckbox );
addSelectionListener( enableAccessControlCheckbox, enableAccessControlCheckboxListener );
// Enable Hidden Password Checkbox
addDirtyListener( enableHiddenPasswordCheckbox );
addSelectionListener( enableHiddenPasswordCheckbox, enableHiddenPasswordCheckboxListener );
}
/**
* Removes listeners to UI Controls.
*/
private void removeListeners()
{
// Enable LDAP Checkbox
removeDirtyListener( enableLdapCheckbox );
removeSelectionListener( enableLdapCheckbox, enableLdapCheckboxListener );
// LDAP Port Text
removeDirtyListener( ldapPortText );
removeModifyListener( ldapPortText, ldapPortTextListener );
// Enable LDAPS Checkbox
removeDirtyListener( enableLdapsCheckbox );
removeSelectionListener( enableLdapsCheckbox, enableLdapsCheckboxListener );
// LDAPS Port Text
removeDirtyListener( ldapsPortText );
removeModifyListener( ldapsPortText, ldapsPortTextListener );
// Enable Kerberos Checkbox
removeDirtyListener( enableKerberosCheckbox );
removeSelectionListener( enableKerberosCheckbox, enableKerberosCheckboxListener );
// Kerberos Port Text
removeDirtyListener( kerberosPortText );
removeModifyListener( kerberosPortText, kerberosPortTextListener );
// Enable Change Password Checkbox
removeDirtyListener( enableChangePasswordCheckbox );
removeSelectionListener( enableChangePasswordCheckbox, enableChangePasswordCheckboxListener );
// Change Password Port Text
removeDirtyListener( changePasswordPortText );
removeModifyListener( changePasswordPortText, changePasswordPortTextListener );
// Allow Anonymous Access Checkbox
removeDirtyListener( allowAnonymousAccessCheckbox );
removeSelectionListener( allowAnonymousAccessCheckbox, allowAnonymousAccessCheckboxListener );
// Enable Access Control Checkbox
removeDirtyListener( enableAccessControlCheckbox );
removeSelectionListener( enableAccessControlCheckbox, enableAccessControlCheckboxListener );
// Enable Hidden Password Checkbox
removeDirtyListener( enableHiddenPasswordCheckbox );
removeSelectionListener( enableHiddenPasswordCheckbox, enableHiddenPasswordCheckboxListener );
}
/**
* {@inheritDoc}
*/
protected void refreshUI()
{
if ( isInitialized() )
{
removeListeners();
DirectoryServiceBean directoryServiceBean = getDirectoryServiceBean();
// LDAP Server
TransportBean ldapServerTransportBean = LdapLdapsServersPage
.getLdapServerTransportBean( directoryServiceBean );
setSelection( enableLdapCheckbox, ldapServerTransportBean.isEnabled() );
setEnabled( ldapPortText, enableLdapCheckbox.getSelection() );
setText( ldapPortText, Integer.toString( ldapServerTransportBean.getSystemPort() ) );
// LDAPS Server
TransportBean ldapsServerTransportBean = LdapLdapsServersPage
.getLdapsServerTransportBean( directoryServiceBean );
setSelection( enableLdapsCheckbox, ldapsServerTransportBean.isEnabled() );
setEnabled( ldapsPortText, enableLdapsCheckbox.getSelection() );
setText( ldapsPortText, Integer.toString( ldapsServerTransportBean.getSystemPort() ) );
// Kerberos Server
KdcServerBean kdcServerBean = KerberosServerPage.getKdcServerBean( directoryServiceBean );
setSelection( enableKerberosCheckbox, kdcServerBean.isEnabled() );
setEnabled( kerberosPortText, enableKerberosCheckbox.getSelection() );
setText( kerberosPortText, Integer.toString( kdcServerBean.getTransports()[0].getSystemPort() ) );
// Change Password Server
ChangePasswordServerBean changePasswordServerBean = KerberosServerPage
.getChangePasswordServerBean( directoryServiceBean );
setSelection( enableChangePasswordCheckbox, changePasswordServerBean.isEnabled() );
setEnabled( changePasswordPortText, enableChangePasswordCheckbox.getSelection() );
setText( changePasswordPortText,
Integer.toString( changePasswordServerBean.getTransports()[0].getSystemPort() ) );
// Partitions
List<PartitionBean> partitions = directoryServiceBean.getPartitions();
if ( partitions.size() == 1 )
{
partitionsLabel.setText( Messages.getString( "OverviewPage.ThereIsOnePartitionDefined" ) ); //$NON-NLS-1$
}
else
{
partitionsLabel.setText( NLS.bind(
Messages.getString( "OverviewPage.ThereAreXPartitionsDefined" ), partitions.size() ) ); //$NON-NLS-1$
}
partitionsTableViewer.setInput( partitions.toArray() );
// Options
allowAnonymousAccessCheckbox.setSelection( directoryServiceBean.isDsAllowAnonymousAccess() );
enableAccessControlCheckbox.setSelection( directoryServiceBean.isDsAccessControlEnabled() );
enableHiddenPasswordCheckbox.setSelection( directoryServiceBean.isDsPasswordHidden() );
addListeners();
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ErrorPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ErrorPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
/**
* This class represents the Error Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ErrorPage extends FormPage
{
/** The Page ID*/
public static final String ID = ErrorPage.class.getName();
/** The Page Title */
private static final String TITLE = Messages.getString( "ErrorPage.ErrorOpeningEditor" ); //$NON-NLS-1$
private static final String DETAILS_CLOSED = NLS.bind( "{0} >>", Messages.getString( "ErrorPage.Details" ) ); //$NON-NLS-1$ //$NON-NLS-2$
private static final String DETAILS_OPEN = NLS.bind( "<< {0}", Messages.getString( "ErrorPage.Details" ) ); //$NON-NLS-1$ //$NON-NLS-2$
/** The exception */
private Exception exception;
/** The flag indicating that the details are shown */
private boolean detailsShown = false;
// UI Controls
private FormToolkit toolkit;
private Composite parent;
private Button detailsButton;
private Text detailsText;
/**
* Creates a new instance of ErrorPage.
*
* @param editor
* the associated editor
*/
public ErrorPage( FormEditor editor, Exception exception )
{
super( editor, ID, TITLE );
this.exception = exception;
}
/**
* {@inheritDoc}
*/
protected void createFormContent( IManagedForm managedForm )
{
ScrolledForm form = managedForm.getForm();
form.setText( Messages.getString( "ErrorPage.ErrorOpeningEditor" ) ); //$NON-NLS-1$
form.setImage( Display.getCurrent().getSystemImage( SWT.ICON_ERROR ) );
parent = form.getBody();
GridLayout gl = new GridLayout( 2, false );
gl.marginHeight = 10;
gl.marginWidth = 10;
parent.setLayout( gl );
parent.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading( form.getForm() );
// Error Label
Label errorLabel = toolkit.createLabel( parent, "" ); //$NON-NLS-1$
errorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Details Button
detailsButton = new Button( parent, SWT.PUSH );
detailsButton.setText( DETAILS_CLOSED );
detailsButton.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) );
detailsButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
showOrHideDetailsView();
}
} );
// Initializing with the exception
if ( exception == null )
{
errorLabel.setText( Messages.getString( "ErrorPage.CouldNotOpenEditor" ) ); //$NON-NLS-1$
detailsButton.setVisible( false );
}
else
{
errorLabel.setText( NLS.bind( "Could not open the editor: {0}", exception.getMessage() ) ); //$NON-NLS-1$
}
}
/**
* Shows or hides the details view.
*/
private void showOrHideDetailsView()
{
if ( detailsShown )
{
detailsButton.setText( DETAILS_CLOSED );
detailsText.dispose();
}
else
{
detailsButton.setText( DETAILS_OPEN );
detailsText = toolkit.createText( parent, getStackTrace( exception ), SWT.H_SCROLL | SWT.V_SCROLL );
detailsText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
}
parent.layout( true, true );
detailsShown = !detailsShown;
}
/**
* Gets the stackTrace of the given exception as a string.
*
* @param e
* the exception
* @return
* the stackTrace of the given exception as a string
*/
private String getStackTrace( Exception e )
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter( sw, true );
e.printStackTrace( pw );
pw.flush();
sw.flush();
return sw.toString();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionType.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionType.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
import org.apache.directory.server.config.beans.MavibotPartitionBean;
import org.apache.directory.server.config.beans.PartitionBean;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum PartitionType
{
/** The JDBM partition type */
JDBM,
/** The Mavibot partition type */
MAVIBOT;
/**
* Gets the partition type.
*
* @param partition the partition
* @return the type corresponding to the partition (or <code>null</code>)
*/
public static PartitionType fromPartition( PartitionBean partition )
{
if ( partition instanceof JdbmPartitionBean )
{
return JDBM;
}
else if ( partition instanceof MavibotPartitionBean )
{
return MAVIBOT;
}
return null;
}
/* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
public String toString()
{
switch ( this )
{
case JDBM:
return "JDBM";
case MAVIBOT:
return "Mavibot";
}
return super.toString();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPolicyDetailsPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPolicyDetailsPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.PasswordPolicyBean;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* This class represents the Details Page of the Server Configuration Editor for the Password Policy type
*
* <pre>
* .-------------------------------------------.
* | Password Policy Details |
* +-------------------------------------------+
* | Set the properties of the password Policy |
* | [X] Enabled |
* | ID : [//////////] |
* | Description : [////////////////////////] |
* | Attribute : [////////////////////////] |
* .-------------------------------------------.
* | Quality |
* +-------------------------------------------+
* | Check quality : [=======================] |
* | Validator : [///////////////////////] |
* | [X] Enable Minimum Length |
* | Number of chars : [NNN] |
* | [X] Enable Maximum Length |
* | Number of chars : [NNN] |
* .-------------------------------------------.
* | Expiration |
* +-------------------------------------------+
* | Minimum age (seconds): [NNN] |
* | Maximum age (seconds): [NNN] |
* | [X] Enable Expire Warning |
* | Number of seconds : [NNN] |
* | [X] Enable Grace Authentication Limit |
* | Number of times : [NNN] |
* | [X] Enable Grace Expire |
* | Interval (seconds) : [NNN] |
* .-------------------------------------------.
* | Options |
* +-------------------------------------------+
* | [X] Enable Must Change |
* | [X] Enable Allow User Change |
* | [X] Enable Safe Modify |
* .-------------------------------------------.
* | Lockout |
* +-------------------------------------------+
* | [X] Enable Lockout |
* | Lockout duration (seconds) : [NNN] |
* | Maximum Consecutive Failures : [NNN] |
* | Failure Count Interval : [NNN] |
* | [X] Enable Maximum Idle |
* | Intervals : [NNN] |
* | [X] Enable In History |
* | Used passwords stored in Hist: [NNN] |
* | [X] Delay |
* | Minimum delay (seconds) : [NNN] |
* | Maximum delay (seconds) : [NNN] |
* +-------------------------------------------+
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PasswordPolicyDetailsPage implements IDetailsPage
{
/** The associated Master Details Block */
private PasswordPoliciesMasterDetailsBlock masterDetailsBlock;
/** The Managed Form */
private IManagedForm mform;
/** The input password policy */
private PasswordPolicyBean passwordPolicy;
// UI Widgets
private Button enabledCheckbox;
private Text idText;
private Text descriptionText;
private ComboViewer checkQualityComboViewer;
private Text validatorText;
private Button minimumLengthCheckbox;
private Text minimumLengthText;
private Button maximumLengthCheckbox;
private Text maximumLengthText;
private Text minimumAgeText;
private Text maximumAgeText;
private Button expireWarningCheckbox;
private Text expireWarningText;
private Button graceAuthenticationLimitCheckbox;
private Text graceAuthenticationLimitText;
private Button graceExpireCheckbox;
private Text graceExpireText;
private Button mustChangeCheckbox;
private Button allowUserChangeCheckbox;
private Button safeModifyCheckbox;
private Button lockoutCheckbox;
private Text lockoutDurationText;
private Text maxFailureText;
private Text failureCountIntervalText;
private Button inHistoryCheckbox;
private Text inHistoryText;
private Button maxIdleCheckbox;
private Text maxIdleText;
private Text minimumDelayText;
private Text maximumDelayText;
// Listeners
/** The Text Modify Listener */
private ModifyListener textModifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
/** The button Selection Listener */
private SelectionListener buttonSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
/** The viewer Selection Changed Listener */
private ISelectionChangedListener viewerSelectionChangedListener = new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
private VerifyListener integerVerifyListener = new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
e.doit = false;
}
}
};
private ISelectionChangedListener checkQualityComboViewerSelectionChangedListener = new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
StructuredSelection selection = ( StructuredSelection ) checkQualityComboViewer.getSelection();
if ( !selection.isEmpty() )
{
CheckQuality checkQuality = ( CheckQuality ) selection.getFirstElement();
if ( checkQuality == CheckQuality.DISABLED )
{
minimumLengthCheckbox.setEnabled( false );
minimumLengthText.setEnabled( false );
maximumLengthCheckbox.setEnabled( false );
maximumLengthText.setEnabled( false );
}
else
{
int minimumLength = 0;
int maximumLength = 0;
try
{
minimumLength = Integer.parseInt( minimumLengthText.getText() );
}
catch ( NumberFormatException e )
{
// Nothing to do.
}
try
{
maximumLength = Integer.parseInt( maximumLengthText.getText() );
}
catch ( NumberFormatException e )
{
// Nothing to do.
}
minimumLengthCheckbox.setEnabled( true );
minimumLengthText.setEnabled( minimumLength != 0 );
maximumLengthCheckbox.setEnabled( true );
maximumLengthText.setEnabled( maximumLength != 0 );
}
}
}
};
private SelectionListener minimumLengthCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
minimumLengthText.setEnabled( minimumLengthCheckbox.getSelection() );
}
};
private SelectionListener maximumLengthCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
maximumLengthText.setEnabled( maximumLengthCheckbox.getSelection() );
}
};
private SelectionListener expireWarningCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
expireWarningText.setEnabled( expireWarningCheckbox.getSelection() );
}
};
private SelectionListener graceAuthenticationLimitCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
graceAuthenticationLimitText.setEnabled( graceAuthenticationLimitCheckbox.getSelection() );
}
};
private SelectionListener graceExpireCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
graceExpireText.setEnabled( graceExpireCheckbox.getSelection() );
}
};
private SelectionListener maxIdleCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
maxIdleText.setEnabled( maxIdleCheckbox.getSelection() );
}
};
private SelectionListener inHistoryCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
inHistoryText.setEnabled( inHistoryCheckbox.getSelection() );
}
};
/**
* Creates a new instance of PartitionDetailsPage.
*
* @param pmdb
* the associated Master Details Block
*/
public PasswordPolicyDetailsPage( PasswordPoliciesMasterDetailsBlock pmdb )
{
masterDetailsBlock = pmdb;
}
/**
* {@inheritDoc}
*/
public void createContents( Composite parent )
{
FormToolkit toolkit = mform.getToolkit();
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = 5;
layout.leftMargin = 5;
layout.rightMargin = 2;
layout.bottomMargin = 2;
parent.setLayout( layout );
// Depending on if the PP is enabled or disabled, we will
// expose the configuration
createDetailsSection( toolkit, parent );
createQualitySection( toolkit, parent );
createExpirationSection( toolkit, parent );
createOptionsSection( toolkit, parent );
createLockoutSection( toolkit, parent );
}
/**
* Creates the Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createDetailsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Password Policy Details" );
section.setDescription( "Set the properties of the password policy." );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
GridLayout glayout = new GridLayout( 2, false );
client.setLayout( glayout );
section.setClient( client );
// Enabled Checkbox
enabledCheckbox = toolkit.createButton( client, "Enabled", SWT.CHECK );
enabledCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
// ID Text
toolkit.createLabel( client, "ID:" );
idText = toolkit.createText( client, "" );
idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Description Text
toolkit.createLabel( client, "Description:" );
descriptionText = toolkit.createText( client, "" );
descriptionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
}
/**
* Creates the Quality section.
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createQualitySection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Quality" );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( 2, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
// Check Quality (pwdCheckQuality)
toolkit.createLabel( composite, "Check Quality:" );
checkQualityComboViewer = new ComboViewer( composite );
checkQualityComboViewer.setContentProvider( new ArrayContentProvider() );
checkQualityComboViewer.setInput( new CheckQuality[]
{ CheckQuality.DISABLED, CheckQuality.RELAXED, CheckQuality.STRICT } );
checkQualityComboViewer.getControl().setLayoutData(
new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Validator
toolkit.createLabel( composite, "Validator:" );
validatorText = toolkit.createText( composite, "" );
validatorText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Minimum Length (pwdMinLength)
minimumLengthCheckbox = toolkit.createButton( composite, "Enable Minimum Length", SWT.CHECK );
minimumLengthCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
Composite minimumLengthRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Number of characters:" );
minimumLengthText = toolkit.createText( minimumLengthRadioIndentComposite, "" );
minimumLengthText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Maximum Length (pwdMaxLength)
maximumLengthCheckbox = toolkit.createButton( composite, "Enable Maximum Length", SWT.CHECK );
maximumLengthCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
Composite maximumLengthRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Number of characters:" );
maximumLengthText = toolkit.createText( maximumLengthRadioIndentComposite, "" );
maximumLengthText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
}
/**
* Creates the Expiration section.
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createExpirationSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Expiration" );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( 2, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
// Minimum Age (pwdMinAge)
toolkit.createLabel( composite, "Minimum Age (seconds):" );
minimumAgeText = toolkit.createText( composite, "" );
minimumAgeText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Maximum Age (pwdMaxAge)
toolkit.createLabel( composite, "Maximum Age (seconds):" );
maximumAgeText = toolkit.createText( composite, "" );
maximumAgeText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Expire Warning (pwdExpireWarning)
expireWarningCheckbox = toolkit.createButton( composite, "Enable Expire Warning", SWT.CHECK );
expireWarningCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 3, 1 ) );
Composite expireWarningRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Number of seconds:" );
expireWarningText = toolkit.createText( expireWarningRadioIndentComposite, "" );
expireWarningText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Grace Authentication Limit (pwdGraceAuthNLimit)
graceAuthenticationLimitCheckbox = toolkit.createButton( composite, "Enable Grace Authentication Limit",
SWT.CHECK );
graceAuthenticationLimitCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 3, 1 ) );
Composite graceAuthenticationLimitRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Number of times:" );
graceAuthenticationLimitText = toolkit.createText( graceAuthenticationLimitRadioIndentComposite, "" );
graceAuthenticationLimitText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Grace Expire (pwdGraceExpire)
graceExpireCheckbox = toolkit.createButton( composite, "Enable Grace Expire", SWT.CHECK );
graceExpireCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 3, 1 ) );
Composite graceExpireRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Interval (seconds):" );
graceExpireText = toolkit.createText( graceExpireRadioIndentComposite, "" );
graceExpireText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
}
/**
* Creates the Options section.
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createOptionsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Options" );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( 2, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
// Must Change (pwdMustChange)
mustChangeCheckbox = toolkit.createButton( composite, "Enable Must Change", SWT.CHECK );
mustChangeCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
// Allow User Change (pwdAllowUserChange)
allowUserChangeCheckbox = toolkit.createButton( composite, "Enable Allow User Change", SWT.CHECK );
allowUserChangeCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
// Safe Modify (pwdSafeModify)
safeModifyCheckbox = toolkit.createButton( composite, "Enable Safe Modify", SWT.CHECK );
safeModifyCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
}
/**
* Creates the Lockout section.
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createLockoutSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Lockout" );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( 2, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
// Lockout (pwdLockout)
lockoutCheckbox = toolkit.createButton( composite, "Enable Lockout", SWT.CHECK );
lockoutCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
// Lockout Duration (pwdLockoutDuration)
toolkit.createLabel( composite, "Lockout Duration (seconds):" );
lockoutDurationText = toolkit.createText( composite, "" );
lockoutDurationText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Max Failure (pwdMaxFailure)
toolkit.createLabel( composite, "Maximum Consecutive Failures (count):" );
maxFailureText = toolkit.createText( composite, "" );
maxFailureText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Failure Count Interval (pwdFailureCountInterval)
toolkit.createLabel( composite, "Failure Count Interval (seconds):" );
failureCountIntervalText = toolkit.createText( composite, "" );
failureCountIntervalText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Max Idle (pwdMaxIdle)
maxIdleCheckbox = toolkit.createButton( composite, "Enable Maximum Idle", SWT.CHECK );
maxIdleCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 3, 1 ) );
Composite maxIdleCheckboxRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Interval (seconds):" );
maxIdleText = toolkit.createText( maxIdleCheckboxRadioIndentComposite, "" );
maxIdleText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// In History (pwdInHistory)
inHistoryCheckbox = toolkit.createButton( composite, "Enable In History", SWT.CHECK );
inHistoryCheckbox.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false, 2, 1 ) );
Composite inHistoryRadioIndentComposite = createRadioIndentComposite( toolkit, composite,
"Used passwords stored in history:" );
inHistoryText = toolkit.createText( inHistoryRadioIndentComposite, "" );
inHistoryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Minimum delay (pwdMinDelay)
toolkit.createLabel( composite, "Minimum Delay (seconds):" );
minimumDelayText = toolkit.createText( composite, "" );
minimumDelayText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
// Maximum Delay (pwdMaxDelay)
toolkit.createLabel( composite, "Maximum Delay (seconds):" );
maximumDelayText = toolkit.createText( composite, "" );
maximumDelayText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
}
/**
* Creates a radio indented composite.
*
* @param toolkit the toolkit
* @param parent the parent composite
* @return a radio indented composite
*/
private Composite createRadioIndentComposite( FormToolkit toolkit, Composite parent, String text )
{
Composite composite = toolkit.createComposite( parent );
GridLayout gridLayout = new GridLayout( 3, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
composite.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) );
toolkit.createLabel( composite, " " );
toolkit.createLabel( composite, text );
return composite;
}
/**
* Adds listeners to UI fields.
*/
private void addListeners()
{
enabledCheckbox.addSelectionListener( buttonSelectionListener );
idText.addModifyListener( textModifyListener );
descriptionText.addModifyListener( textModifyListener );
checkQualityComboViewer.addSelectionChangedListener( viewerSelectionChangedListener );
checkQualityComboViewer.addSelectionChangedListener( checkQualityComboViewerSelectionChangedListener );
validatorText.addModifyListener( textModifyListener );
minimumLengthCheckbox.addSelectionListener( buttonSelectionListener );
minimumLengthCheckbox.addSelectionListener( minimumLengthCheckboxSelectionListener );
minimumLengthText.addModifyListener( textModifyListener );
minimumLengthText.addVerifyListener( integerVerifyListener );
maximumLengthCheckbox.addSelectionListener( buttonSelectionListener );
maximumLengthCheckbox.addSelectionListener( maximumLengthCheckboxSelectionListener );
maximumLengthText.addModifyListener( textModifyListener );
maximumLengthText.addVerifyListener( integerVerifyListener );
minimumAgeText.addModifyListener( textModifyListener );
minimumAgeText.addVerifyListener( integerVerifyListener );
maximumAgeText.addModifyListener( textModifyListener );
maximumAgeText.addVerifyListener( integerVerifyListener );
expireWarningCheckbox.addSelectionListener( buttonSelectionListener );
expireWarningCheckbox.addSelectionListener( expireWarningCheckboxSelectionListener );
expireWarningText.addModifyListener( textModifyListener );
expireWarningText.addVerifyListener( integerVerifyListener );
graceAuthenticationLimitCheckbox.addSelectionListener( buttonSelectionListener );
graceAuthenticationLimitCheckbox.addSelectionListener( graceAuthenticationLimitCheckboxSelectionListener );
graceAuthenticationLimitText.addModifyListener( textModifyListener );
graceAuthenticationLimitText.addVerifyListener( integerVerifyListener );
graceExpireCheckbox.addSelectionListener( buttonSelectionListener );
graceExpireCheckbox.addSelectionListener( graceExpireCheckboxSelectionListener );
graceExpireText.addModifyListener( textModifyListener );
graceExpireText.addVerifyListener( integerVerifyListener );
mustChangeCheckbox.addSelectionListener( buttonSelectionListener );
allowUserChangeCheckbox.addSelectionListener( buttonSelectionListener );
safeModifyCheckbox.addSelectionListener( buttonSelectionListener );
lockoutCheckbox.addSelectionListener( buttonSelectionListener );
lockoutDurationText.addModifyListener( textModifyListener );
lockoutDurationText.addVerifyListener( integerVerifyListener );
maxFailureText.addModifyListener( textModifyListener );
maxFailureText.addVerifyListener( integerVerifyListener );
failureCountIntervalText.addModifyListener( textModifyListener );
failureCountIntervalText.addVerifyListener( integerVerifyListener );
maxIdleCheckbox.addSelectionListener( buttonSelectionListener );
maxIdleCheckbox.addSelectionListener( maxIdleCheckboxSelectionListener );
maxIdleText.addModifyListener( textModifyListener );
maxIdleText.addVerifyListener( integerVerifyListener );
inHistoryCheckbox.addSelectionListener( buttonSelectionListener );
inHistoryCheckbox.addSelectionListener( inHistoryCheckboxSelectionListener );
inHistoryText.addModifyListener( textModifyListener );
inHistoryText.addVerifyListener( integerVerifyListener );
minimumDelayText.addModifyListener( textModifyListener );
minimumDelayText.addVerifyListener( integerVerifyListener );
maximumDelayText.addModifyListener( textModifyListener );
maximumDelayText.addVerifyListener( integerVerifyListener );
}
/**
* Removes listeners to UI fields.
*/
private void removeListeners()
{
enabledCheckbox.removeSelectionListener( buttonSelectionListener );
idText.removeModifyListener( textModifyListener );
descriptionText.removeModifyListener( textModifyListener );
checkQualityComboViewer.removeSelectionChangedListener( viewerSelectionChangedListener );
checkQualityComboViewer.removeSelectionChangedListener( checkQualityComboViewerSelectionChangedListener );
validatorText.removeModifyListener( textModifyListener );
minimumLengthCheckbox.removeSelectionListener( buttonSelectionListener );
minimumLengthCheckbox.removeSelectionListener( minimumLengthCheckboxSelectionListener );
minimumLengthText.removeModifyListener( textModifyListener );
minimumLengthText.removeVerifyListener( integerVerifyListener );
maximumLengthCheckbox.removeSelectionListener( buttonSelectionListener );
maximumLengthCheckbox.removeSelectionListener( maximumLengthCheckboxSelectionListener );
maximumLengthText.removeModifyListener( textModifyListener );
maximumLengthText.removeVerifyListener( integerVerifyListener );
minimumAgeText.removeModifyListener( textModifyListener );
minimumAgeText.removeVerifyListener( integerVerifyListener );
maximumAgeText.removeModifyListener( textModifyListener );
maximumAgeText.removeVerifyListener( integerVerifyListener );
expireWarningCheckbox.removeSelectionListener( buttonSelectionListener );
expireWarningCheckbox.removeSelectionListener( expireWarningCheckboxSelectionListener );
expireWarningText.removeModifyListener( textModifyListener );
expireWarningText.removeVerifyListener( integerVerifyListener );
graceAuthenticationLimitCheckbox.removeSelectionListener( buttonSelectionListener );
graceAuthenticationLimitCheckbox.removeSelectionListener( graceAuthenticationLimitCheckboxSelectionListener );
graceAuthenticationLimitText.removeModifyListener( textModifyListener );
graceAuthenticationLimitText.removeVerifyListener( integerVerifyListener );
graceExpireCheckbox.removeSelectionListener( buttonSelectionListener );
graceExpireCheckbox.removeSelectionListener( graceExpireCheckboxSelectionListener );
graceExpireText.removeModifyListener( textModifyListener );
graceExpireText.removeVerifyListener( integerVerifyListener );
mustChangeCheckbox.removeSelectionListener( buttonSelectionListener );
allowUserChangeCheckbox.removeSelectionListener( buttonSelectionListener );
safeModifyCheckbox.removeSelectionListener( buttonSelectionListener );
lockoutCheckbox.removeSelectionListener( buttonSelectionListener );
lockoutDurationText.removeModifyListener( textModifyListener );
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/Messages.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionsPage extends ServerConfigurationEditorPage
{
/** The Page ID*/
public static final String ID = PartitionsPage.class.getName(); //$NON-NLS-1$
/** The Page Title */
private static final String TITLE = Messages.getString( "PartitionsPage.Partitions" ); //$NON-NLS-1$
/** The Master Details Block */
private PartitionsMasterDetailsBlock masterDetailsBlock;
/** The label provider for partition table viewers */
public static LabelProvider PARTITIONS_LABEL_PROVIDER = new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof PartitionBean )
{
PartitionBean partition = ( PartitionBean ) element;
return NLS
.bind(
"{0} ({1}) [{2}]", new Object[] { partition.getPartitionId(), partition.getPartitionSuffix(), getPartitionType( partition ) } ); //$NON-NLS-1$
}
else if ( element instanceof PartitionWrapper )
{
return getText( ( ( PartitionWrapper ) element ).getPartition() );
}
return super.getText( element );
}
private String getPartitionType( PartitionBean partition )
{
PartitionType type = PartitionType.fromPartition( partition );
if ( type != null )
{
return type.toString();
}
else
{
return "Unknown";
}
}
public Image getImage( Object element )
{
if ( element instanceof PartitionBean )
{
PartitionBean partition = ( PartitionBean ) element;
if ( isSystemPartition( partition ) )
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_PARTITION_SYSTEM );
}
else
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_PARTITION );
}
}
else if ( element instanceof PartitionWrapper )
{
return getImage( ( ( PartitionWrapper ) element ).getPartition() );
}
return super.getImage( element );
}
};
/** The comparator for partition table viewers */
public static ViewerComparator PARTITIONS_COMPARATOR = new ViewerComparator()
{
public int compare( Viewer viewer, Object e1, Object e2 )
{
if ( ( e1 instanceof PartitionBean ) && ( e2 instanceof PartitionBean ) )
{
PartitionBean partition1 = ( PartitionBean ) e1;
PartitionBean partition2 = ( PartitionBean ) e2;
String partition1Id = partition1.getPartitionId();
String partition2Id = partition2.getPartitionId();
if ( ( partition1Id != null ) && ( partition2Id != null ) )
{
return partition1Id.compareTo( partition2Id );
}
}
if ( ( e1 instanceof PartitionWrapper ) && ( e2 instanceof PartitionWrapper ) )
{
return compare( viewer, ( ( PartitionWrapper ) e1 ).getPartition(),
( ( PartitionWrapper ) e2 ).getPartition() );
}
return super.compare( viewer, e1, e2 );
}
};
/**
* Creates a new instance of PartitionsPage.
*
* @param editor
* the associated editor
*/
public PartitionsPage( ServerConfigurationEditor editor )
{
super( editor, ID, TITLE );
}
/**
* {@inheritDoc}
*/
protected void createFormContent( Composite parent, FormToolkit toolkit )
{
masterDetailsBlock = new PartitionsMasterDetailsBlock( this );
masterDetailsBlock.createContent( getManagedForm() );
}
/**
* {@inheritDoc}
*/
protected void refreshUI()
{
if ( isInitialized() )
{
masterDetailsBlock.refreshUI();
}
}
/**
* Indicates if the given partition is the system partition.
*
* @param partition the partition
* @return <code>true</code> if the partition is the system partition,
* <code>false</code> if not.
*/
public static boolean isSystemPartition( PartitionBean partition )
{
if ( partition != null )
{
return "system".equalsIgnoreCase( partition.getPartitionId() ); //$NON-NLS-1$
}
return false;
}
/**
* {@inheritDoc}
*/
public void doSave( IProgressMonitor monitor )
{
if ( masterDetailsBlock != null )
{
masterDetailsBlock.doSave( monitor );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/JavaVersion.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/JavaVersion.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
/**
* An enum used to define the server's Java targeted version. It can be one of :
* <ul>
* <li>Java 7</li>
* <li>Java 8</li>
* </ul>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum JavaVersion
{
JAVA_7( "Java 7" ),
JAVA_8( "Java 8" );
/** The name of the selected version */
private String name;
/** The constructor for this enum */
private JavaVersion( String name )
{
this.name = name;
}
/**
* @return the name
*/
public String getName()
{
return name;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationInput.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationInput.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
* This class represents the Non Existing Server Configuration Input.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ServerConfigurationInput implements IEditorInput
{
/**
* {@inheritDoc}
*/
public String getToolTipText()
{
return getName();
}
/**
* {@inheritDoc}
*/
public String getName()
{
return "ServerConfigurationInput"; //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public boolean exists()
{
return true;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return ApacheDS2ConfigurationPlugin.getDefault().getImageDescriptor(
ApacheDS2ConfigurationPluginConstants.IMG_EDITOR );
}
/**
* {@inheritDoc}
*/
public IPersistableElement getPersistable()
{
return null;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
public Object getAdapter( Class adapter )
{
return null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NewServerConfigurationInput.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/NewServerConfigurationInput.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
* This class represents the Non Existing Server Configuration Input.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class NewServerConfigurationInput implements IEditorInput
{
/**
* {@inheritDoc}
*/
public String getToolTipText()
{
return Messages.getString( "NewServerConfigurationInput.NewApacheDS20ConfigurationFile" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public String getName()
{
return Messages.getString( "NewServerConfigurationInput.NewApacheDS20ConfigurationFile" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public boolean exists()
{
return true;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return null;
}
/**
* {@inheritDoc}
*/
public IPersistableElement getPersistable()
{
return null;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
public Object getAdapter( Class adapter )
{
return null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/SupportedCipher.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/SupportedCipher.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The supported ciphers, and their status (enabled or not) for each Java version. We use a Boolean
* object to store three states :
* <ul>
* <li>Boolean.TRUE : the cipher is enabled for this java version</li>
* <li>Boolean.FALSE : the cipher is disabled for this java version</li>
* <li>null : the cipher is not supportted by this java version</li>
* </ul>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum SupportedCipher
{
// Enabled ciphers
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384( "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384( "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", Boolean.TRUE, Boolean.TRUE),
TLS_RSA_WITH_AES_256_CBC_SHA256( "TLS_RSA_WITH_AES_256_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384( "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384( "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256( "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_256_CBC_SHA256( "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA( "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA( "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_RSA_WITH_AES_256_CBC_SHA( "TLS_RSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA( "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_256_CBC_SHA( "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_256_CBC_SHA( "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_256_CBC_SHA( "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256( "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256( "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_RSA_WITH_AES_128_CBC_SHA256( "TLS_RSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256( "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256( "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_128_CBC_SHA256( "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA( "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA( "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_RSA_WITH_AES_128_CBC_SHA( "TLS_RSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA( "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA( "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_128_CBC_SHA( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_128_CBC_SHA( "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA( "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_RC4_128_SHA( "TLS_ECDHE_RSA_WITH_RC4_128_SHA", Boolean.TRUE, Boolean.TRUE),
SSL_RSA_WITH_RC4_128_SHA( "SSL_RSA_WITH_RC4_128_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_RC4_128_SHA( "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_RC4_128_SHA( "TLS_ECDH_RSA_WITH_RC4_128_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384( "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256( "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384( "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_RSA_WITH_AES_256_GCM_SHA384( "TLS_RSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384( "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384( "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_256_GCM_SHA384( "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_256_GCM_SHA384( "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", null, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256( "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_RSA_WITH_AES_128_GCM_SHA256( "TLS_RSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256( "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256( "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256( "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256( "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", null, Boolean.TRUE),
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA( "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA( "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
SSL_RSA_WITH_3DES_EDE_CBC_SHA( "SSL_RSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA( "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA( "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA( "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA( "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", Boolean.TRUE, Boolean.TRUE),
SSL_RSA_WITH_RC4_128_MD5( "SSL_RSA_WITH_RC4_128_MD5", Boolean.TRUE, Boolean.TRUE),
TLS_EMPTY_RENEGOTIATION_INFO_SCSV( "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", Boolean.TRUE, Boolean.TRUE),
// Disabled ciphers
TLS_DH_anon_WITH_AES_256_GCM_SHA384( "TLS_DH_anon_WITH_AES_256_GCM_SHA384", null, Boolean.FALSE ),
TLS_DH_anon_WITH_AES_128_GCM_SHA256( "TLS_DH_anon_WITH_AES_128_GCM_SHA256", null, Boolean.FALSE ),
TLS_DH_anon_WITH_AES_256_CBC_SHA256( "TLS_DH_anon_WITH_AES_256_CBC_SHA256", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_anon_WITH_AES_256_CBC_SHA( "TLS_ECDH_anon_WITH_AES_256_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_DH_anon_WITH_AES_256_CBC_SHA( "TLS_DH_anon_WITH_AES_256_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_DH_anon_WITH_AES_128_CBC_SHA256( "TLS_DH_anon_WITH_AES_128_CBC_SHA256", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_anon_WITH_AES_128_CBC_SHA( "TLS_ECDH_anon_WITH_AES_128_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_DH_anon_WITH_AES_128_CBC_SHA( "TLS_DH_anon_WITH_AES_128_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_anon_WITH_RC4_128_SHA( "TLS_ECDH_anon_WITH_RC4_128_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DH_anon_WITH_RC4_128_MD5( "SSL_DH_anon_WITH_RC4_128_MD5", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA( "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DH_anon_WITH_3DES_EDE_CBC_SHA( "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_RSA_WITH_NULL_SHA256( "TLS_RSA_WITH_NULL_SHA256", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDHE_ECDSA_WITH_NULL_SHA( "TLS_ECDHE_ECDSA_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDHE_RSA_WITH_NULL_SHA( "TLS_ECDHE_RSA_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_RSA_WITH_NULL_SHA( "SSL_RSA_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_ECDSA_WITH_NULL_SHA( "TLS_ECDH_ECDSA_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_RSA_WITH_NULL_SHA( "TLS_ECDH_RSA_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_ECDH_anon_WITH_NULL_SHA( "TLS_ECDH_anon_WITH_NULL_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_RSA_WITH_NULL_MD5( "SSL_RSA_WITH_NULL_MD5", Boolean.FALSE, Boolean.FALSE ),
SSL_RSA_WITH_DES_CBC_SHA( "SSL_RSA_WITH_DES_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DHE_RSA_WITH_DES_CBC_SHA( "SSL_DHE_RSA_WITH_DES_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DHE_DSS_WITH_DES_CBC_SHA( "SSL_DHE_DSS_WITH_DES_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DH_anon_WITH_DES_CBC_SHA( "SSL_DH_anon_WITH_DES_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_RSA_EXPORT_WITH_RC4_40_MD5( "SSL_RSA_EXPORT_WITH_RC4_40_MD5", Boolean.FALSE, Boolean.FALSE ),
SSL_DH_anon_EXPORT_WITH_RC4_40_MD5( "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", Boolean.FALSE, Boolean.FALSE ),
SSL_RSA_EXPORT_WITH_DES40_CBC_SHA( "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA( "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA( "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA( "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_RC4_128_SHA( "TLS_KRB5_WITH_RC4_128_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_RC4_128_MD5( "TLS_KRB5_WITH_RC4_128_MD5", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_3DES_EDE_CBC_SHA( "TLS_KRB5_WITH_3DES_EDE_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_3DES_EDE_CBC_MD5( "TLS_KRB5_WITH_3DES_EDE_CBC_MD5", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_DES_CBC_SHA( "TLS_KRB5_WITH_DES_CBC_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_WITH_DES_CBC_MD5( "TLS_KRB5_WITH_DES_CBC_MD5", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_EXPORT_WITH_RC4_40_SHA( "TLS_KRB5_EXPORT_WITH_RC4_40_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_EXPORT_WITH_RC4_40_MD5( "TLS_KRB5_EXPORT_WITH_RC4_40_MD5", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA( "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", Boolean.FALSE, Boolean.FALSE ),
TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5( "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", Boolean.FALSE, Boolean.FALSE );
/**
* The list of supported ciphers for JAVA 8
*/
public static final SupportedCipher[] SUPPORTED_CIPHERS =
{
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
TLS_RSA_WITH_AES_256_CBC_SHA256,
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,
TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384,
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA,
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,
TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
TLS_DHE_DSS_WITH_AES_256_CBC_SHA,
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_RSA_WITH_AES_128_CBC_SHA256,
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256,
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
TLS_ECDHE_RSA_WITH_RC4_128_SHA,
SSL_RSA_WITH_RC4_128_SHA,
TLS_ECDH_ECDSA_WITH_RC4_128_SHA,
TLS_ECDH_RSA_WITH_RC4_128_SHA,
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_RSA_WITH_AES_256_GCM_SHA384,
TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384,
TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_DHE_DSS_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
TLS_RSA_WITH_AES_128_GCM_SHA256,
TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256,
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_RSA_WITH_3DES_EDE_CBC_SHA,
TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,
TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,
SSL_RSA_WITH_RC4_128_MD5,
TLS_EMPTY_RENEGOTIATION_INFO_SCSV,
TLS_DH_anon_WITH_AES_256_GCM_SHA384,
TLS_DH_anon_WITH_AES_128_GCM_SHA256,
TLS_DH_anon_WITH_AES_256_CBC_SHA256,
TLS_ECDH_anon_WITH_AES_256_CBC_SHA,
TLS_DH_anon_WITH_AES_256_CBC_SHA,
TLS_DH_anon_WITH_AES_128_CBC_SHA256,
TLS_ECDH_anon_WITH_AES_128_CBC_SHA,
TLS_DH_anon_WITH_AES_128_CBC_SHA,
TLS_ECDH_anon_WITH_RC4_128_SHA,
SSL_DH_anon_WITH_RC4_128_MD5,
TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA,
SSL_DH_anon_WITH_3DES_EDE_CBC_SHA,
TLS_RSA_WITH_NULL_SHA256,
TLS_ECDHE_ECDSA_WITH_NULL_SHA,
TLS_ECDHE_RSA_WITH_NULL_SHA,
SSL_RSA_WITH_NULL_SHA,
TLS_ECDH_ECDSA_WITH_NULL_SHA,
TLS_ECDH_RSA_WITH_NULL_SHA,
TLS_ECDH_anon_WITH_NULL_SHA,
SSL_RSA_WITH_NULL_MD5,
SSL_RSA_WITH_DES_CBC_SHA,
SSL_DHE_RSA_WITH_DES_CBC_SHA,
SSL_DHE_DSS_WITH_DES_CBC_SHA,
SSL_DH_anon_WITH_DES_CBC_SHA,
SSL_RSA_EXPORT_WITH_RC4_40_MD5,
SSL_DH_anon_EXPORT_WITH_RC4_40_MD5,
SSL_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,
SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA,
TLS_KRB5_WITH_RC4_128_SHA,
TLS_KRB5_WITH_RC4_128_MD5,
TLS_KRB5_WITH_3DES_EDE_CBC_SHA,
TLS_KRB5_WITH_3DES_EDE_CBC_MD5,
TLS_KRB5_WITH_DES_CBC_SHA,
TLS_KRB5_WITH_DES_CBC_MD5,
TLS_KRB5_EXPORT_WITH_RC4_40_SHA,
TLS_KRB5_EXPORT_WITH_RC4_40_MD5,
TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA,
TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5
};
/** The supported cipher name */
private String cipher;
/** A flag that tells if the cipher is supported in Java 7 */
private Boolean java7;
/** A flag that tells if the cipher is supported in Java 8 */
private Boolean java8;
/** A map containing all the values */
private static Map<String, SupportedCipher> supportedCiphersByName = new HashMap<String, SupportedCipher>();
/** A list of all the supported ciphers for JAVA 7 */
public static List<SupportedCipher> supportedCiphersJava7 = new ArrayList<SupportedCipher>();
/** A list of all the supported cipher names for JAVA 7 */
public static List<String> supportedCipherNamesJava7 = new ArrayList<String>();
/** A list of all the supported ciphers for JAVA 8 */
public static List<SupportedCipher> supportedCiphersJava8 = new ArrayList<SupportedCipher>();
/** A list of all the supported cipher names for JAVA 8 */
public static List<String> supportedCipherNamesJava8 = new ArrayList<String>();
/** Initialization of the previous maps and lists */
static
{
for ( SupportedCipher cipher : SupportedCipher.values() )
{
supportedCiphersByName.put( cipher.getCipher(), cipher );
if ( cipher.isJava7Implemented() )
{
supportedCiphersJava7.add( cipher );
supportedCipherNamesJava7.add( cipher.cipher );
}
if ( cipher.isJava8Implemented() )
{
supportedCiphersJava8.add( cipher );
supportedCipherNamesJava8.add( cipher.cipher );
}
}
}
/**
* A private constructor used to initialize the enum values
*/
private SupportedCipher( String cipher, Boolean java7, Boolean java8 )
{
this.cipher = cipher;
this.java7 = java7;
this.java8 = java8;
}
/**
* @return the cipher
*/
public String getCipher()
{
return cipher;
}
/**
* @return <code>true</code> if the cipher is enabled on Java 7, <code>false</code> if
* the cipher is disabled in Java 7, or not implemented.
*/
public Boolean isJava7Enabled()
{
return java7 != null && java7;
}
/**
* @return <code>true</code> if the cipher is implemented in Java 7, regardless of it's enabled or disabled
*/
public boolean isJava7Implemented()
{
return java7 != null;
}
/**
* @return <code>true</code> if the cipher is enabled on Java 8, <code>false</code> if
* the cipher is disabled in Java 8, or not implemented.
*/
public boolean isJava8Enabled()
{
return java8!= null && java8;
}
/**
* @return <code>true</code> if the cipher is implemented in Java 8, regardless of it's enabled or disabled
*/
public boolean isJava8Implemented()
{
return java8 != null;
}
/**
* Get the SupportedCipher given a String.
* @param type The supported cipher string we want to find
* @return The found SupportedCipher, or null
*/
public static SupportedCipher getByName( String type )
{
if ( type == null )
{
return null;
}
return supportedCiphersByName.get( type.toUpperCase() );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPoliciesMasterDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPoliciesMasterDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.AuthenticationInterceptorBean;
import org.apache.directory.server.config.beans.InterceptorBean;
import org.apache.directory.server.config.beans.PasswordPolicyBean;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.forms.DetailsPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.MasterDetailsBlock;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
/**
* This class represents the Password Policies Master/Details Block used in the Password Policies Page.
*
* <pre>
* +------------------------------------------------------------------------------------+
* | .----------------------------------. .-------------------------------------------. |
* | | All password Policies | | Password Policy Details | |
* | +----------------------------------+ +-------------------------------------------+ |
* | | +---------------------+ | | Set the properties of the password Policy | |
* | | | Default (enabled) | [ Add ] | | [X] Enabled | |
* | | | | [Delete] | | ID : [//////////] | |
* | | | | | | Description : [////////////////////////] | |
* | | | | | | Attribute : [////////////////////////] | |
* | | | | | .-------------------------------------------. |
* | | | | | | Quality | |
* | | | | | +-------------------------------------------+ |
* | | | | | | Check quality : [=======================] | |
* | | | | | | Validator : [///////////////////////] | |
* | | | | | | [X] Enable Minimum Length | |
* | | | | | | Number of chars : [NNN] | |
* | | | | | | [X] Enable Maximum Length | |
* | | | | | | Number of chars : [NNN] | |
* | | | | | .-------------------------------------------. |
* | | | | | | Expiration | |
* | | | | | +-------------------------------------------+ |
* | | | | | | Minimum age (seconds): [NNN] | |
* | | | | | | Maximum age (seconds): [NNN] | |
* | | | | | | [X] Enable Expire Warning | |
* | | | | | | Number of seconds : [NNN] | |
* | | | | | | [X] Enable Grace Authentication Limit | |
* | | | | | | Number of times : [NNN] | |
* | | | | | | [X] Enable Grace Expire | |
* | | | | | | Interval (seconds) : [NNN] | |
* | | | | | .-------------------------------------------. |
* | | | | | | Options | |
* | | | | | +-------------------------------------------+ |
* | | | | | | [X] Enable Must Change | |
* | | | | | | [X] Enable Allow User Change | |
* | | | | | | [X] Enable Safe Modify | |
* | | | | | .-------------------------------------------. |
* | | | | | | Lockout | |
* | | | | | +-------------------------------------------+ |
* | | | | | | [X] Enable Lockout | |
* | | | | | | Lockout duration (seconds) : [NNN] | |
* | | | | | | Maximum Consecutive Failures : [NNN] | |
* | | | | | | Failure Count Interval : [NNN] | |
* | | | | | | [X] Enable Maximum Idle | |
* | | | | | | Intervals : [NNN] | |
* | | | | | | [X] Enable In History | |
* | | | | | | Used passwords stored in Hist: [NNN] | |
* | | | | | | [X] Delay | |
* | | | | | | Minimum delay (seconds) : [NNN] | |
* | | +---------------------+ | | Maximum delay (seconds) : [NNN] | |
* | +----------------------------------+ +-------------------------------------------+ |
* +------------------------------------------------------------------------------------+
* </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PasswordPoliciesMasterDetailsBlock extends MasterDetailsBlock
{
private static final String NEW_ID = Messages.getString( "PasswordPoliciesMasterDetailsBlock.PasswordPolicyNewId" ); //$NON-NLS-1$
private static final String AUTHENTICATION_INTERCEPTOR_ID = "authenticationInterceptor";
/** The associated page */
private PasswordPoliciesPage page;
/** The Details Page */
private PasswordPolicyDetailsPage detailsPage;
// UI Fields
private TableViewer viewer;
private Button addButton;
private Button deleteButton;
/**
* Creates a new instance of PasswordPoliciesMasterDetailsBlock.
*
* @param page the associated page
*/
public PasswordPoliciesMasterDetailsBlock( PasswordPoliciesPage page )
{
this.page = page;
}
/**
* {@inheritDoc}
*/
public void createContent( IManagedForm managedForm )
{
super.createContent( managedForm );
this.sashForm.setWeights( new int[]
{ 40, 60 } );
}
/**
* {@inheritDoc}
*/
protected void createMasterPart( final IManagedForm managedForm, Composite parent )
{
FormToolkit toolkit = managedForm.getToolkit();
// Creating the Section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( Messages.getString( "PasswordPoliciesMasterDetailsBlock.AllPasswordPolicies" ) ); //$NON-NLS-1$
section.marginWidth = 10;
section.marginHeight = 5;
Composite client = toolkit.createComposite( section, SWT.WRAP );
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout( layout );
toolkit.paintBordersFor( client );
section.setClient( client );
// Creating the Table and Table Viewer
Table table = toolkit.createTable( client, SWT.NULL );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
gd.heightHint = 20;
gd.widthHint = 100;
table.setLayoutData( gd );
final SectionPart spart = new SectionPart( section );
managedForm.addPart( spart );
viewer = new TableViewer( table );
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
managedForm.fireSelectionChanged( spart, event.getSelection() );
}
} );
viewer.setContentProvider( new ArrayContentProvider() );
viewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof PasswordPolicyBean )
{
PasswordPolicyBean passwordPolicy = ( PasswordPolicyBean ) element;
if ( passwordPolicy.isEnabled() )
{
return NLS.bind( "{0} (enabled)", passwordPolicy.getPwdId() );
}
else
{
return NLS.bind( "{0} (disabled)", passwordPolicy.getPwdId() );
}
}
return super.getText( element );
}
public Image getImage( Object element )
{
if ( element instanceof PasswordPolicyBean )
{
PasswordPolicyBean passwordPolicy = ( PasswordPolicyBean ) element;
if ( PasswordPoliciesPage.isDefaultPasswordPolicy( passwordPolicy ) )
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_PASSWORD_POLICY_DEFAULT );
}
else
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_PASSWORD_POLICY );
}
}
return super.getImage( element );
}
} );
viewer.setComparator( new ViewerComparator()
{
public int compare( Viewer viewer, Object e1, Object e2 )
{
if ( ( e1 instanceof PasswordPolicyBean ) && ( e2 instanceof PasswordPolicyBean ) )
{
PasswordPolicyBean passwordPolicy1 = ( PasswordPolicyBean ) e1;
PasswordPolicyBean passwordPolicy2 = ( PasswordPolicyBean ) e2;
String passwordPolicy1Id = passwordPolicy1.getPwdId();
String passwordPolicy2Id = passwordPolicy2.getPwdId();
if ( ( passwordPolicy1Id != null ) && ( passwordPolicy2Id != null ) )
{
return passwordPolicy1Id.compareTo( passwordPolicy2Id );
}
}
return super.compare( viewer, e1, e2 );
}
} );
// Creating the button(s)
addButton = toolkit.createButton( client,
Messages.getString( "PasswordPoliciesMasterDetailsBlock.Add" ), SWT.PUSH ); //$NON-NLS-1$
addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
deleteButton = toolkit.createButton( client,
Messages.getString( "PasswordPoliciesMasterDetailsBlock.Delete" ), SWT.PUSH ); //$NON-NLS-1$
deleteButton.setEnabled( false );
deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
initFromInput();
addListeners();
}
/**
* Initializes the page with the Editor input.
*/
private void initFromInput()
{
AuthenticationInterceptorBean authenticationInterceptor = getAuthenticationInterceptor();
if ( authenticationInterceptor != null )
{
viewer.setInput( authenticationInterceptor.getPasswordPolicies() );
}
else
{
viewer.setInput( null );
}
}
/**
* Refreshes the UI.
*/
public void refreshUI()
{
initFromInput();
viewer.refresh();
}
/**
* Gets the authentication interceptor.
*
* @return the authentication interceptor
*/
private AuthenticationInterceptorBean getAuthenticationInterceptor()
{
// Looking for the authentication interceptor
for ( InterceptorBean interceptor : page.getConfigBean().getDirectoryServiceBean().getInterceptors() )
{
if ( AUTHENTICATION_INTERCEPTOR_ID.equalsIgnoreCase( interceptor.getInterceptorId() )
&& ( interceptor instanceof AuthenticationInterceptorBean ) )
{
return ( AuthenticationInterceptorBean ) interceptor;
}
}
return null;
}
/**
* Add listeners to UI fields.
*/
private void addListeners()
{
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
viewer.refresh();
// Getting the selection of the table viewer
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
// Delete button is enabled when something is selected
deleteButton.setEnabled( !selection.isEmpty() );
// Delete button is not enabled in the case of the system partition
if ( !selection.isEmpty() )
{
PasswordPolicyBean passwordPolicy = ( PasswordPolicyBean ) selection.getFirstElement();
if ( PasswordPoliciesPage.isDefaultPasswordPolicy( passwordPolicy ) )
{
deleteButton.setEnabled( false );
}
}
}
} );
addButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
addNewPasswordPolicy();
}
} );
deleteButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
deleteSelectedPasswordPolicy();
}
} );
}
/**
* This method is called when the 'Add' button is clicked.
*/
private void addNewPasswordPolicy()
{
// Getting a new ID for the password policy
String newId = getNewId();
// Creating and configuring the new password policy
PasswordPolicyBean newPasswordPolicy = new PasswordPolicyBean();
newPasswordPolicy.setPwdId( newId );
newPasswordPolicy.setPwdMaxAge( 0 );
newPasswordPolicy.setPwdFailureCountInterval( 30 );
newPasswordPolicy.setPwdAttribute( "userPassword" );
newPasswordPolicy.setPwdMaxFailure( 5 );
newPasswordPolicy.setPwdLockout( true );
newPasswordPolicy.setPwdMustChange( false );
newPasswordPolicy.setPwdLockoutDuration( 0 );
newPasswordPolicy.setPwdMinLength( 5 );
newPasswordPolicy.setPwdInHistory( 5 );
newPasswordPolicy.setPwdExpireWarning( 600 );
newPasswordPolicy.setPwdMinAge( 0 );
newPasswordPolicy.setPwdAllowUserChange( true );
newPasswordPolicy.setPwdGraceAuthNLimit( 5 );
newPasswordPolicy.setPwdCheckQuality( 1 );
newPasswordPolicy.setPwdMaxLength( 0 );
newPasswordPolicy.setPwdGraceExpire( 0 );
newPasswordPolicy.setPwdMinDelay( 0 );
newPasswordPolicy.setPwdMaxDelay( 0 );
newPasswordPolicy.setPwdMaxIdle( 0 );
// Adding the new password policy to the authentication interceptor
getAuthenticationInterceptor().addPasswordPolicies( newPasswordPolicy );
// Updating the UI and editor
viewer.refresh();
viewer.setSelection( new StructuredSelection( newPasswordPolicy ) );
setEditorDirty();
}
/**
* Gets a new ID for a new password policy.
*
* @return
* a new ID for a new password policy
*/
private String getNewId()
{
int counter = 1;
String name = NEW_ID;
boolean ok = false;
while ( !ok )
{
ok = true;
name = NEW_ID + counter;
for ( PasswordPolicyBean passwordPolicy : getAuthenticationInterceptor().getPasswordPolicies() )
{
if ( passwordPolicy.getPwdId().equalsIgnoreCase( name ) )
{
ok = false;
}
}
counter++;
}
return name;
}
/**
* This method is called when the 'Delete' button is clicked.
*/
private void deleteSelectedPasswordPolicy()
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
PasswordPolicyBean passwordPolicy = ( PasswordPolicyBean ) selection.getFirstElement();
if ( !PasswordPoliciesPage.isDefaultPasswordPolicy( passwordPolicy ) )
{
if ( MessageDialog
.openConfirm(
page.getManagedForm().getForm().getShell(),
Messages.getString( "PasswordPoliciesMasterDetailsBlock.ConfirmDelete" ), //$NON-NLS-1$
NLS.bind(
Messages.getString( "PasswordPoliciesMasterDetailsBlock.AreYouSureDeletePasswordPolicy" ), passwordPolicy.getPwdId() ) ) ) //$NON-NLS-1$
{
getAuthenticationInterceptor().removePasswordPolicies( passwordPolicy );
setEditorDirty();
}
}
}
}
/**
* {@inheritDoc}
*/
protected void registerPages( DetailsPart detailsPart )
{
detailsPage = new PasswordPolicyDetailsPage( this );
detailsPart.registerPage( PasswordPolicyBean.class, detailsPage );
}
/**
* {@inheritDoc}
*/
protected void createToolBarActions( IManagedForm managedForm )
{
// No toolbar needed.
}
/**
* Sets the Editor as dirty.
*/
public void setEditorDirty()
{
( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
viewer.refresh();
}
/**
* Saves the necessary elements to the input model.
*/
public void save()
{
detailsPage.commit( true );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/KerberosServerPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/KerberosServerPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.config.beans.ChangePasswordServerBean;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.InterceptorBean;
import org.apache.directory.server.config.beans.KdcServerBean;
import org.apache.directory.server.config.beans.TransportBean;
import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class KerberosServerPage extends ServerConfigurationEditorPage
{
/** The Page ID*/
public static final String ID = KerberosServerPage.class.getName(); //$NON-NLS-1$
/** The Page Title */
private static final String TITLE = Messages.getString( "KerberosServerPage.KerberosServer" ); //$NON-NLS-1$
/** The encryption types supported by ApacheDS */
private static final EncryptionType[] SUPPORTED_ENCRYPTION_TYPES = new EncryptionType[]
{
EncryptionType.DES_CBC_MD5,
EncryptionType.DES3_CBC_SHA1_KD,
EncryptionType.AES128_CTS_HMAC_SHA1_96,
EncryptionType.AES256_CTS_HMAC_SHA1_96,
EncryptionType.RC4_HMAC
};
// UI Controls
// The Kerberos transport
private Button enableKerberosCheckbox;
private Text kerberosPortText;
private Text kerberosAddressText;
// The ChangePassword transport
private Button enableChangePasswordCheckbox;
private Text changePasswordPortText;
private Text changePasswordAddressText;
// The basic Kerberos settings
private Text primaryKdcRealmText;
private Text kdcSearchBaseDnText;
private CheckboxTableViewer encryptionTypesTableViewer;
// The kerberos Tickets settings
private Button verifyBodyChecksumCheckbox;
private Button allowEmptyAddressesCheckbox;
private Button allowForwardableAddressesCheckbox;
private Button requirePreAuthByEncryptedTimestampCheckbox;
private Button allowPostdatedTicketsCheckbox;
private Button allowRenewableTicketsCheckbox;
private Button allowProxiableTicketsCheckbox;
private Text maximumRenewableLifetimeText;
private Text maximumTicketLifetimeText;
private Text allowableClockSkewText;
// UI Controls Listeners
/**
* The Kerberos checkbox listener
*/
private SelectionAdapter enableKerberosCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
boolean enabled = enableKerberosCheckbox.getSelection();
enableKerberosServer( getDirectoryServiceBean(), enabled );
setEnabled( kerberosPortText, enabled );
setEnabled( kerberosAddressText, enabled );
}
};
/**
* The Kerberos port listener
*/
private ModifyListener kerberosPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
setKerberosPort( getDirectoryServiceBean(), kerberosPortText.getText() );
}
};
/**
* The Kerberos address modify listener
*/
private ModifyListener kerberosAddressTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
setKerberosAddress( getDirectoryServiceBean(), kerberosAddressText.getText() );
}
};
/**
* The ChangePassword checkbox listener
*/
private SelectionAdapter enableChangePasswordCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
boolean enabled = enableChangePasswordCheckbox.getSelection();
getChangePasswordServerBean().setEnabled( enabled );
setEnabled( changePasswordPortText, enabled );
setEnabled( changePasswordAddressText, enabled );
}
};
/**
* The ChangePassword port listener
*/
private ModifyListener changePasswordPortTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
setChangePasswordPort( getDirectoryServiceBean(), changePasswordPortText.getText() );
}
};
/**
* The ChangePassword address modify listener
*/
private ModifyListener changePasswordAddressTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
setChangePasswordAddress( getDirectoryServiceBean(), changePasswordAddressText.getText() );
}
};
private ModifyListener primaryKdcRealmTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
getKdcServerBean().setKrbPrimaryRealm( primaryKdcRealmText.getText() );
}
};
private ModifyListener kdcSearchBaseDnTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
String searchBaseDnValue = kdcSearchBaseDnText.getText();
try
{
Dn searchBaseDn = new Dn( searchBaseDnValue );
getKdcServerBean().setSearchBaseDn( searchBaseDn );
}
catch ( LdapInvalidDnException e1 )
{
// Stay silent
}
}
};
private ICheckStateListener encryptionTypesTableViewerListener = new ICheckStateListener()
{
public void checkStateChanged( CheckStateChangedEvent event )
{
// Checking if the last encryption type is being unchecked
if ( ( getKdcServerBean().getKrbEncryptionTypes().size() == 1 ) && ( event.getChecked() == false ) )
{
// Displaying an error to the user
CommonUIUtils.openErrorDialog( Messages
.getString( "KerberosServerPage.AtLeastOneEncryptionTypeMustBeSelected" ) ); //$NON-NLS-1$
// Reverting the current checked state
encryptionTypesTableViewer.setChecked( event.getElement(), !event.getChecked() );
// Exiting
return;
}
// Setting the editor as dirty
setEditorDirty();
// Clearing previous encryption types
getKdcServerBean().getKrbEncryptionTypes().clear();
// Getting all selected encryption types
Object[] selectedEncryptionTypeObjects = encryptionTypesTableViewer.getCheckedElements();
// Adding each encryption type
for ( Object encryptionTypeObject : selectedEncryptionTypeObjects )
{
if ( encryptionTypeObject instanceof EncryptionType )
{
EncryptionType encryptionType = ( EncryptionType ) encryptionTypeObject;
getKdcServerBean().addKrbEncryptionTypes( encryptionType.getName() );
}
}
}
};
private SelectionAdapter verifyBodyChecksumCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbBodyChecksumVerified( verifyBodyChecksumCheckbox.getSelection() );
}
};
private SelectionAdapter allowEmptyAddressesCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbEmptyAddressesAllowed( allowEmptyAddressesCheckbox.getSelection() );
}
};
private SelectionAdapter allowForwardableAddressesCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbForwardableAllowed( allowForwardableAddressesCheckbox.getSelection() );
}
};
private SelectionAdapter requirePreAuthByEncryptedTimestampCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbPaEncTimestampRequired(
requirePreAuthByEncryptedTimestampCheckbox.getSelection() );
}
};
private SelectionAdapter allowPostdatedTicketsCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbPostdatedAllowed( allowPostdatedTicketsCheckbox.getSelection() );
}
};
/**
* The Allow Renewable Tickets listener
*/
private SelectionAdapter allowRenewableTicketsCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbRenewableAllowed( allowRenewableTicketsCheckbox.getSelection() );
}
};
/**
* The Allow Proxiable Tickets listener
*/
private SelectionAdapter allowProxiableTicketsCheckboxListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
getKdcServerBean().setKrbProxiableAllowed( allowProxiableTicketsCheckbox.getSelection() );
}
};
private ModifyListener maximumRenewableLifetimeTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
getKdcServerBean()
.setKrbMaximumRenewableLifetime( Long.parseLong( maximumRenewableLifetimeText.getText() ) );
}
};
private ModifyListener maximumTicketLifetimeTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
getKdcServerBean().setKrbMaximumTicketLifetime( Long.parseLong( maximumTicketLifetimeText.getText() ) );
}
};
private ModifyListener allowableClockSkewTextListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
getKdcServerBean().setKrbAllowableClockSkew( Long.parseLong( allowableClockSkewText.getText() ) );
}
};
/**
* Creates a new instance of GeneralPage.
*
* @param editor
* the associated editor
*/
public KerberosServerPage( ServerConfigurationEditor editor )
{
super( editor, ID, TITLE );
}
/**
* {@inheritDoc}
*/
protected void createFormContent( Composite parent, FormToolkit toolkit )
{
TableWrapLayout twl = new TableWrapLayout();
twl.numColumns = 2;
parent.setLayout( twl );
// Left Composite
Composite leftComposite = toolkit.createComposite( parent );
leftComposite.setLayout( new GridLayout() );
TableWrapData leftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
leftCompositeTableWrapData.grabHorizontal = true;
leftComposite.setLayoutData( leftCompositeTableWrapData );
// Right Composite
Composite rightComposite = toolkit.createComposite( parent );
rightComposite.setLayout( new GridLayout() );
TableWrapData rightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
rightCompositeTableWrapData.grabHorizontal = true;
rightComposite.setLayoutData( rightCompositeTableWrapData );
// Creating the sections
createKerberosServerSection( toolkit, leftComposite );
createKerberosSettingsSection( toolkit, leftComposite );
createTicketSettingsSection( toolkit, rightComposite );
// Refreshing the UI
refreshUI();
}
/**
* Creates the Kerberos Server section.
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createKerberosServerSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( Messages.getString( "KerberosServerPage.KerberosServer" ) ); //$NON-NLS-1$
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( 4, false );
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
// Enable Kerberos Server Checkbox
enableKerberosCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.EnableKerberosServer" ), SWT.CHECK ); //$NON-NLS-1$
enableKerberosCheckbox
.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, gridLayout.numColumns, 1 ) );
// Kerberos Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.Port" ) ); //$NON-NLS-1$
kerberosPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, "60088" ); //$NON-NLS-1$
// Kerberos Server Address Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.Address" ) ); //$NON-NLS-1$
kerberosAddressText = createAddressText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, DEFAULT_ADDRESS ); //$NON-NLS-1$
// Enable Change Password Server Checkbox
enableChangePasswordCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.EnableKerberosChangePassword" ), //$NON-NLS-1$
SWT.CHECK );
enableChangePasswordCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false,
gridLayout.numColumns, 1 ) );
// Change Password Server Port Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.Port" ) ); //$NON-NLS-1$
changePasswordPortText = createPortText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, "60464" ); //$NON-NLS-1$
// Change Password Server Address Text
toolkit.createLabel( composite, TABULATION );
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.Address" ) ); //$NON-NLS-1$
changePasswordAddressText = createAddressText( toolkit, composite );
createDefaultValueLabel( toolkit, composite, DEFAULT_ADDRESS ); //$NON-NLS-1$
}
/**
* Creates the Kerberos Settings section
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createKerberosSettingsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( Messages.getString( "KerberosServerPage.KerberosSettings" ) ); //$NON-NLS-1$
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout glayout = new GridLayout( 2, false );
composite.setLayout( glayout );
section.setClient( composite );
// SASL Principal Text
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.PrimaryKdcRealm" ) ); //$NON-NLS-1$
primaryKdcRealmText = toolkit.createText( composite, "" ); //$NON-NLS-1$
setGridDataWithDefaultWidth( primaryKdcRealmText, new GridData( SWT.FILL, SWT.NONE, true, false ) );
Label defaultSaslPrincipalLabel = createDefaultValueLabel( toolkit, composite, "EXAMPLE.COM" ); //$NON-NLS-1$
defaultSaslPrincipalLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
// Search Base Dn Text
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.SearchBaseDn" ) ); //$NON-NLS-1$
kdcSearchBaseDnText = toolkit.createText( composite, "" ); //$NON-NLS-1$
setGridDataWithDefaultWidth( kdcSearchBaseDnText, new GridData( SWT.FILL, SWT.NONE, true, false ) );
Label defaultSaslSearchBaseDnLabel = createDefaultValueLabel( toolkit, composite, "ou=users,dc=example,dc=com" ); //$NON-NLS-1$
defaultSaslSearchBaseDnLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
// Encryption Types Table Viewer
Label encryptionTypesLabel = toolkit.createLabel( composite,
Messages.getString( "KerberosServerPage.EncryptionTypes" ) ); //$NON-NLS-1$
encryptionTypesLabel.setLayoutData( new GridData( SWT.BEGINNING, SWT.TOP, false, false ) );
encryptionTypesTableViewer = new CheckboxTableViewer( new Table( composite, SWT.BORDER | SWT.CHECK ) );
encryptionTypesTableViewer.setContentProvider( new ArrayContentProvider() );
encryptionTypesTableViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof EncryptionType )
{
EncryptionType encryptionType = ( EncryptionType ) element;
return encryptionType.getName().toUpperCase();
}
return super.getText( element );
}
} );
encryptionTypesTableViewer.setInput( SUPPORTED_ENCRYPTION_TYPES );
GridData encryptionTypesTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false );
encryptionTypesTableViewerGridData.heightHint = 60;
encryptionTypesTableViewer.getControl().setLayoutData( encryptionTypesTableViewerGridData );
}
/**
* Creates the Tickets Settings section
*
* @param toolkit the toolkit to use
* @param parent the parent composite
*/
private void createTicketSettingsSection( FormToolkit toolkit, Composite parent )
{
// Creation of the section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( Messages.getString( "KerberosServerPage.TicketSettings" ) ); //$NON-NLS-1$
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout layout = new GridLayout( 2, false );
composite.setLayout( layout );
section.setClient( composite );
// Verify Body Checksum Checkbox
verifyBodyChecksumCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.VerifyBodyChecksum" ), SWT.CHECK ); //$NON-NLS-1$
verifyBodyChecksumCheckbox
.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns, 1 ) );
// Allow Empty Addresse Checkbox
allowEmptyAddressesCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.AllowEmptyAddresses" ), SWT.CHECK ); //$NON-NLS-1$
allowEmptyAddressesCheckbox
.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns, 1 ) );
// Allow Forwardable Addresses Checkbox
allowForwardableAddressesCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.AllowForwadableAddresses" ), //$NON-NLS-1$
SWT.CHECK );
allowForwardableAddressesCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false,
layout.numColumns, 1 ) );
// Require Pre-Authentication By Encrypted Timestamp Checkbox
requirePreAuthByEncryptedTimestampCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.RequirePreAuthentication" ), SWT.CHECK ); //$NON-NLS-1$
requirePreAuthByEncryptedTimestampCheckbox
.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns, 1 ) );
// Allow Postdated Tickets Checkbox
allowPostdatedTicketsCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.AllowPostdatedTickets" ), SWT.CHECK ); //$NON-NLS-1$
allowPostdatedTicketsCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns,
1 ) );
// Allow Renewable Tickets Checkbox
allowRenewableTicketsCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.AllowRenewableTickets" ), SWT.CHECK ); //$NON-NLS-1$
allowRenewableTicketsCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns,
1 ) );
// Allow Proxiable Tickets Checkbox
allowProxiableTicketsCheckbox = toolkit.createButton( composite,
Messages.getString( "KerberosServerPage.AllowProxiableTickets" ), SWT.CHECK ); //$NON-NLS-1$
allowProxiableTicketsCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, layout.numColumns,
1 ) );
// Max Renewable Lifetime Text
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.MaxRenewableLifetime" ) ); //$NON-NLS-1$
maximumRenewableLifetimeText = BaseWidgetUtils.createIntegerText( toolkit, composite );
setGridDataWithDefaultWidth( maximumRenewableLifetimeText, new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Max Ticket Lifetime Text
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.MaxTicketLifetime" ) ); //$NON-NLS-1$
maximumTicketLifetimeText = BaseWidgetUtils.createIntegerText( toolkit, composite );
setGridDataWithDefaultWidth( maximumTicketLifetimeText, new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Allowable Clock Skew Text
toolkit.createLabel( composite, Messages.getString( "KerberosServerPage.AllowableClockSkew" ) ); //$NON-NLS-1$
allowableClockSkewText = BaseWidgetUtils.createIntegerText( toolkit, composite );
setGridDataWithDefaultWidth( allowableClockSkewText, new GridData( SWT.FILL, SWT.NONE, true, false ) );
}
/**
* {@inheritDoc}
*/
protected void refreshUI()
{
if ( isInitialized() )
{
removeListeners();
// Kerberos Server
KdcServerBean kdcServerBean = getKdcServerBean();
setSelection( enableKerberosCheckbox, kdcServerBean.isEnabled() );
setEnabled( kerberosPortText, enableKerberosCheckbox.getSelection() );
setEnabled( kerberosAddressText, enableKerberosCheckbox.getSelection() );
setText( kerberosPortText, Integer.toString( kdcServerBean.getTransports()[0].getSystemPort() ) );
setText( kerberosAddressText, kdcServerBean.getTransports()[0].getTransportAddress() );
// Change Password Checkbox
ChangePasswordServerBean changePasswordServerBean = getChangePasswordServerBean();
setSelection( enableChangePasswordCheckbox, changePasswordServerBean.isEnabled() );
setEnabled( changePasswordPortText, enableChangePasswordCheckbox.getSelection() );
setEnabled( changePasswordAddressText, enableChangePasswordCheckbox.getSelection() );
setText( changePasswordPortText, Integer.toString( changePasswordServerBean.getTransports()[0].getSystemPort() ) );
setText( changePasswordAddressText, changePasswordServerBean.getTransports()[0].getTransportAddress() );
// Kerberos Settings
setText( primaryKdcRealmText, kdcServerBean.getKrbPrimaryRealm() );
setText( kdcSearchBaseDnText, kdcServerBean.getSearchBaseDn().toString() );
// Encryption Types
List<String> encryptionTypesNames = kdcServerBean.getKrbEncryptionTypes();
List<EncryptionType> encryptionTypes = new ArrayList<EncryptionType>();
for ( String encryptionTypesName : encryptionTypesNames )
{
EncryptionType encryptionType = EncryptionType.getByName( encryptionTypesName );
if ( !EncryptionType.UNKNOWN.equals( encryptionType ) )
{
encryptionTypes.add( encryptionType );
}
}
encryptionTypesTableViewer.setCheckedElements( encryptionTypes.toArray() );
// Ticket Settings
setSelection( verifyBodyChecksumCheckbox, kdcServerBean.isKrbBodyChecksumVerified() );
setSelection( allowEmptyAddressesCheckbox, kdcServerBean.isKrbEmptyAddressesAllowed() );
setSelection( allowForwardableAddressesCheckbox, kdcServerBean.isKrbForwardableAllowed() );
setSelection( requirePreAuthByEncryptedTimestampCheckbox, kdcServerBean.isKrbPaEncTimestampRequired() );
setSelection( allowPostdatedTicketsCheckbox, kdcServerBean.isKrbPostdatedAllowed() );
setSelection( allowRenewableTicketsCheckbox, kdcServerBean.isKrbRenewableAllowed() );
setSelection( allowProxiableTicketsCheckbox, kdcServerBean.isKrbProxiableAllowed() );
setText( maximumRenewableLifetimeText, Long.toString( kdcServerBean.getKrbMaximumRenewableLifetime() ) );
setText( maximumTicketLifetimeText, Long.toString( kdcServerBean.getKrbMaximumTicketLifetime() ) );
setText( allowableClockSkewText, Long.toString( kdcServerBean.getKrbAllowableClockSkew() ) );
addListeners();
}
}
/**
* Adds listeners to UI Controls.
*/
private void addListeners()
{
// Enable Kerberos Server Checkbox
addDirtyListener( enableKerberosCheckbox );
addSelectionListener( enableKerberosCheckbox, enableKerberosCheckboxListener );
// Kerberos Server Port Text
addDirtyListener( kerberosPortText );
addModifyListener( kerberosPortText, kerberosPortTextListener );
// Kerberos Server Address Text
addDirtyListener( kerberosAddressText );
addModifyListener( kerberosAddressText, kerberosAddressTextListener );
// Enable Change Password Server Checkbox
addDirtyListener( enableChangePasswordCheckbox );
addSelectionListener( enableChangePasswordCheckbox, enableChangePasswordCheckboxListener );
// Change Password Server Port Text
addDirtyListener( changePasswordPortText );
addModifyListener( changePasswordPortText, changePasswordPortTextListener );
// Change Password Server Address Text
addDirtyListener( changePasswordAddressText );
addModifyListener( changePasswordAddressText, changePasswordAddressTextListener );
// Primary KDC Text
addDirtyListener( primaryKdcRealmText );
addModifyListener( primaryKdcRealmText, primaryKdcRealmTextListener );
// KDC Search Base Dn Text
addDirtyListener( kdcSearchBaseDnText );
addModifyListener( kdcSearchBaseDnText, kdcSearchBaseDnTextListener );
// Encryption Types Table Viewer
encryptionTypesTableViewer.addCheckStateListener( encryptionTypesTableViewerListener );
// Verify Body Checksum Checkbox
addDirtyListener( verifyBodyChecksumCheckbox );
addSelectionListener( verifyBodyChecksumCheckbox, verifyBodyChecksumCheckboxListener );
// Allow Empty Addresses Checkbox
addDirtyListener( allowEmptyAddressesCheckbox );
addSelectionListener( allowEmptyAddressesCheckbox, allowEmptyAddressesCheckboxListener );
// Allow Forwardable Addresses Checkbox
addDirtyListener( allowForwardableAddressesCheckbox );
addSelectionListener( allowForwardableAddressesCheckbox, allowForwardableAddressesCheckboxListener );
// Require Pre-Authentication By Encrypted Timestamp Checkbox
addDirtyListener( requirePreAuthByEncryptedTimestampCheckbox );
addSelectionListener( requirePreAuthByEncryptedTimestampCheckbox,
requirePreAuthByEncryptedTimestampCheckboxListener );
// Allow Postdated Tickets Checkbox
addDirtyListener( allowPostdatedTicketsCheckbox );
addSelectionListener( allowPostdatedTicketsCheckbox, allowPostdatedTicketsCheckboxListener );
// Allow Renewable Tickets Checkbox
addDirtyListener( allowRenewableTicketsCheckbox );
addSelectionListener( allowRenewableTicketsCheckbox, allowRenewableTicketsCheckboxListener );
// Allow Proxiable Tickets Checkbox
addDirtyListener( allowProxiableTicketsCheckbox );
addSelectionListener( allowProxiableTicketsCheckbox, allowProxiableTicketsCheckboxListener );
// Maximum Renewable Lifetime Text
addDirtyListener( maximumRenewableLifetimeText );
addModifyListener( maximumRenewableLifetimeText, maximumRenewableLifetimeTextListener );
// Maximum Ticket Lifetime Text
addDirtyListener( maximumTicketLifetimeText );
addModifyListener( maximumTicketLifetimeText, maximumTicketLifetimeTextListener );
// Allowable Clock Skew Text
addDirtyListener( allowableClockSkewText );
addModifyListener( allowableClockSkewText, allowableClockSkewTextListener );
}
/**
* Removes listeners to UI Controls.
*/
private void removeListeners()
{
// Enable Kerberos Server Checkbox
removeDirtyListener( enableKerberosCheckbox );
removeSelectionListener( enableKerberosCheckbox, enableKerberosCheckboxListener );
// Kerberos Server Port Text
removeDirtyListener( kerberosPortText );
removeModifyListener( kerberosPortText, kerberosPortTextListener );
// Kerberos Server Address Text
removeDirtyListener( kerberosAddressText );
removeModifyListener( kerberosAddressText, kerberosAddressTextListener );
// Enable Change Password Server Checkbox
removeDirtyListener( enableChangePasswordCheckbox );
removeSelectionListener( enableChangePasswordCheckbox, enableChangePasswordCheckboxListener );
// Change Password Server Port Text
removeDirtyListener( changePasswordPortText );
removeModifyListener( changePasswordPortText, changePasswordPortTextListener );
// Change Password Server Address Text
removeDirtyListener( changePasswordAddressText );
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/LdapLdapsServersPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/LdapLdapsServersPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.ExtendedOpHandlerBean;
import org.apache.directory.server.config.beans.InterceptorBean;
import org.apache.directory.server.config.beans.LdapServerBean;
import org.apache.directory.server.config.beans.SaslMechHandlerBean;
import org.apache.directory.server.config.beans.TcpTransportBean;
import org.apache.directory.server.config.beans.TransportBean;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* <pre>
* +-------------------------------------------------------------------------------+
* | +------------------------------------+ +------------------------------------+ |
* | | .--------------------------------. | | .--------------------------------. | |
* | | |V LDAP/LDAPS servers | | | |V Supported Authn Mechanisms | | |
* | | +--------------------------------+ | | +--------------------------------+ | |
* | | | [X] Enabled LDAP Server | | | | [X] Simple [X] GSSAPI | | |
* | | | Address : [////////////////] | | | | [X] CRAM-MD5 [X] Digest-MD5 | | |
* | | | Port : [/////////] | | | | [X] NTLM | | |
* | | | nbThreads: [/////////] | | | | Provider : [///////////////] | | |
* | | | backLog : [/////////] | | | | [X] GSS_SPNEGO | | |
* | | | [X] Enabled LDAPS Server | | | | Provider : [///////////////] | | |
* | | | Address : [////////////////] | | | | [X] Delegated | | |
* | | | Port : [/////////] | | | | Host : [////////////////] | | |
* | | | nbThreads: [/////////] | | | | Port : [/////] | | |
* | | | backLog : [/////////] | | | | Ssl/tls : [====] | | |
* | | +--------------------------------+ | | | Trust : [////////////////] | | |
* | | .--------------------------------. | | | Base DN : [////////////////] | | |
* | | |V Server limits | | | +--------------------------------+ | |
* | | +--------------------------------+ | | .--------------------------------. | |
* | | | Max time limit : [////////] | | | |V SASL Settings | | |
* | | | Max size limit : [////////] | | | +--------------------------------+ | |
* | | | Max PDU size : [////////] | | | | SASL Host : [///////////] | | |
* | | +--------------------------------+ | | | SASL Principal : [///////////] | | |
* | | .--------------------------------. | | | Search Base DN : [///////////] | | |
* | | |V SSL/Start TLS keystore | | | | SASL realms : | | |
* | | +--------------------------------+ | | | +-----------------+ | | |
* | | | keystore : [////////] (browse)| | | | | | (add) | | |
* | | | password : [////////////////] | | | | | | (edit) | | |
* | | | [X] Show password | | | | | | (delete) | | |
* | | +--------------------------------+ | | | +-----------------+ | | |
* | | .--------------------------------. | | +--------------------------------+ | |
* | | |V SSL Advanced Settings | | | | |
* | | +--------------------------------+ | | | |
* | | | [X] Require Client Auth | | | | |
* | | | [X] Request Client Auth | | | | |
* | | | Ciphers suite : | | | | |
* | | | +--------------------------+ | | | | |
* | | | |[X] xyz | | | | | |
* | | | |[X] abc | | | | | |
* | | | |[X] def | | | | | |
* | | | +--------------------------+ | | | | |
* | | | Enabled protocols : | | | | |
* | | | [X] SSLv3 [X] TLSv1 | | | | |
* | | | [X] TLSv1.1 [X] TLSv1.2 | | | | |
* | | +--------------------------------+ | | | |
* | | .--------------------------------. | | | |
* | | |V Advanced | | | | |
* | | +--------------------------------+ | | | |
* | | | [X] Enable TLS | | | | |
* | | | [X] Enable ServerSide PWD hash | | | | |
* | | | hashing method {========} | | | | |
* | | | Replication pinger sleep [XXX] | | | | |
* | | | Disk sync delay [XXX] | | | | |
* | | +--------------------------------+ | | | |
* | +------------------------------------+ +------------------------------------+ |
* +-------------------------------------------------------------------------------+
* </pre>
*
* We manage the following parameters :
* LDAP server controls. We manage :
* <ul>
* <li>the address</li>
* <li>the port</li>
* <li>the number of dedicated threads</li>
* <li>the backlog size</li>
* </ul>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LdapLdapsServersPage extends ServerConfigurationEditorPage
{
private static final int DEFAULT_NB_THREADS = 4;
private static final int DEFAULT_BACKLOG_SIZE = 50;
private static final String TRANSPORT_ID_LDAP = "ldap"; //$NON-NLS-1$
public static final String TRANSPORT_ID_LDAPS = "ldaps"; //$NON-NLS-1$
private static final String SASL_MECHANISMS_SIMPLE = "SIMPLE"; //$NON-NLS-1$
private static final String SSL_V3 = "SSLv3";
private static final String TLS_V1_0 = "TLSv1";
private static final String TLS_V1_1 = "TLSv1.1";
private static final String TLS_V1_2 = "TLSv1.2";
private static final String START_TLS_HANDLER_ID = "starttlshandler"; //$NON-NLS-1$
private static final String START_TLS_HANDLER_CLASS = "org.apache.directory.server.ldap.handlers.extended.StartTlsHandler"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_ID = "passwordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SSHA512 = "org.apache.directory.server.core.hash.Ssha512PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SHA512 = "org.apache.directory.server.core.hash.Sha512PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SSHA384 = "org.apache.directory.server.core.hash.Ssha384PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SHA384 = "org.apache.directory.server.core.hash.Sha384PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SSHA256 = "org.apache.directory.server.core.hash.Ssha256PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SHA256 = "org.apache.directory.server.core.hash.Sha256PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_CRYPT = "org.apache.directory.server.core.hash.CryptPasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SMD5 = "org.apache.directory.server.core.hash.Smd5PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_MD5 = "org.apache.directory.server.core.hash.Md5PasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SSHA = "org.apache.directory.server.core.hash.SshaPasswordHashingInterceptor"; //$NON-NLS-1$
private static final String HASHING_PASSWORD_INTERCEPTOR_FQCN_SHA = "org.apache.directory.server.core.hash.ShaPasswordHashingInterceptor"; //$NON-NLS-1$
/** The Page ID*/
public static final String ID = LdapLdapsServersPage.class.getName(); //$NON-NLS-1$
/** The Page Title */
private static final String TITLE = Messages.getString( "LdapLdapsServersPage.LdapLdapsServers" ); //$NON-NLS-1$
// UI Controls
/**
* LDAP server controls. We manage :
* <ul>
* <li>the address</li>
* <li>the port</li>
* <li>the number of dedicated threads</li>
* <li>the backlog size</li>
* </ul>
**/
private Button enableLdapCheckbox;
private Text ldapPortText;
private Text ldapAddressText;
private Text ldapNbThreadsText;
private Text ldapBackLogSizeText;
/** LDAPS server controls */
private Button enableLdapsCheckbox;
private Text ldapsPortText;
private Text ldapsAddressText;
private Text ldapsNbThreadsText;
private Text ldapsBackLogSizeText;
private Button needClientAuthCheckbox;
private Button wantClientAuthCheckbox;
private boolean wantClientAuthStatus;
/** The CiphersSuite controls */
private CheckboxTableViewer ciphersSuiteTableViewer;
/** The EnabledProtocols controls */
private Button sslv3Checkbox;
private Button tlsv1_0Checkbox;
private Button tlsv1_1Checkbox;
private Button tlsv1_2Checkbox;
/** LDAP limits */
private Text maxTimeLimitText;
private Text maxSizeLimitText;
private Text maxPduSizeText;
/** The supported authentication controls */
private Button authMechSimpleCheckbox;
private Button authMechCramMd5Checkbox;
private Button authMechDigestMd5Checkbox;
private Button authMechGssapiCheckbox;
private Button authMechNtlmCheckbox;
private Text authMechNtlmText;
private Button authMechGssSpnegoCheckbox;
private Text authMechGssSpnegoText;
/** The SASL controls */
private Text saslHostText;
private Text saslPrincipalText;
private Text saslSearchBaseDnText;
private TableViewer saslRealmsTableViewer;
private Button addSaslRealmsButton;
private Button editSaslRealmsButton;
private Button deleteSaslRealmsButton;
/** The Advanced controls */
private Button enableTlsCheckbox;
private Button enableServerSidePasswordHashingCheckbox;
private ComboViewer hashingMethodComboViewer;
private Text keystoreFileText;
private Button keystoreFileBrowseButton;
private Text keystorePasswordText;
private Button showPasswordCheckbox;
private Text replicationPingerSleepText;
private Text diskSynchronizationDelayText;
// UI Controls Listeners
/**
* The LDAP transport checkbox listener. When checked, we enable the following
* widgets :
* <ul>
* <li>Port</li>
* <li>Address</li>
* <li>NbThreads</li>
* <li>BackLog</li>
* </ul>
*/
private SelectionAdapter enableLdapCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
boolean enabled = enableLdapCheckbox.getSelection();
getLdapServerTransportBean().setEnabled( enabled );
setEnabled( ldapPortText, enabled );
setEnabled( ldapAddressText, enabled );
setEnabled( ldapNbThreadsText, enabled );
setEnabled( ldapBackLogSizeText, enabled );
}
};
/**
* The LDAP port modify listener
*/
private ModifyListener ldapPortTextListener = event ->
{
try
{
int port = Integer.parseInt( ldapPortText.getText() );
getLdapServerTransportBean().setSystemPort( port );
}
catch ( NumberFormatException nfe1 )
{
System.out.println( "Wrong LDAP TCP Port : it must be an integer" );
}
};
/**
* The LDAP address modify listener
*/
private ModifyListener ldapAddressTextListener = event ->
getLdapServerTransportBean().setTransportAddress( ldapAddressText.getText() );
/**
* The LDAP nbThreads modify listener
*/
private ModifyListener ldapNbThreadsTextListener = event ->
{
try
{
int nbThreads = Integer.parseInt( ldapNbThreadsText.getText() );
getLdapServerTransportBean().setTransportNbThreads( nbThreads );
}
catch ( NumberFormatException nfe2 )
{
System.out.println( "Wrong LDAP NbThreads : it must be an integer" );
}
};
/**
* The LDAP BackLogSize modify listener
*/
private ModifyListener ldapBackLogSizeTextListener = event ->
{
try
{
int backLogSize = Integer.parseInt( ldapBackLogSizeText.getText() );
getLdapServerTransportBean().setTransportBackLog( backLogSize );
}
catch ( NumberFormatException nfe3 )
{
System.out.println( "Wrong LDAP BackLog size : it must be an integer" );
}
};
/**
* The LDAPS transport checkbox listener. When checked, we enable the following
* controls :
* <ul>
* <li>Port</li>
* <li>Address</li>
* <li>NbThreads</li>
* <li>BackLog</li>
* <li>needClientAuth</li>
* <li>wantClientAuth</li>
* <li>Cipher suite (and associated buttons)</li>
* <li>Enabled Protocols (and associated buttons)</li>
* </ul>
*/
private SelectionAdapter enableLdapsCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
boolean enabled = enableLdapsCheckbox.getSelection();
getLdapsServerTransportBean().setEnabled( enabled );
setEnabled( ldapsPortText, enabled );
setEnabled( ldapsAddressText, enabled );
setEnabled( ldapsNbThreadsText, enabled );
setEnabled( ldapsBackLogSizeText, enabled );
}
};
/**
* The LDAPS port modify listener
*/
private ModifyListener ldapsPortTextListener = event ->
{
try
{
int port = Integer.parseInt( ldapsPortText.getText() );
getLdapsServerTransportBean().setSystemPort( port );
}
catch ( NumberFormatException nfe4 )
{
System.out.println( "Wrong LDAPS Port : it must be an integer" );
}
};
/**
* The LDAPS address modify listener
*/
private ModifyListener ldapsAddressTextListener = event ->
getLdapsServerTransportBean().setTransportAddress( ldapsAddressText.getText() );
/**
* The LDAPS nbThreads modify listener
*/
private ModifyListener ldapsNbThreadsTextListener = event ->
{
try
{
int nbThreads = Integer.parseInt( ldapsNbThreadsText.getText() );
getLdapsServerTransportBean().setTransportNbThreads( nbThreads );
}
catch ( NumberFormatException nfe5 )
{
System.out.println( "Wrong LDAPS NbThreads : it must be an integer" );
}
};
/**
* The LDAPS BackLogSize modify listener
*/
private ModifyListener ldapsBackLogSizeTextListener = event ->
{
try
{
int backLogSize = Integer.parseInt( ldapsBackLogSizeText.getText() );
getLdapsServerTransportBean().setTransportBackLog( backLogSize );
}
catch ( NumberFormatException nfe6 )
{
System.out.println( "Wrong LDAPS BackLog size : it must be an integer" );
}
};
/**
* As listener for the NeedClientAuth checkbox : we have to check the
* WantClientAuth checkbox when the NeedClientAuth is selected.
*/
private SelectionAdapter needClientAuthListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
boolean enabled = needClientAuthCheckbox.getSelection();
// Inject the flag in the config
TransportBean ldapTransport = getLdapServerTransportBean();
ldapTransport.setWantClientAuth( enabled );
TransportBean ldapsTransport = getLdapsServerTransportBean();
ldapsTransport.setWantClientAuth( enabled );
// Turn on/off the NeedClientAuth
if ( enabled )
{
wantClientAuthCheckbox.setSelection( enabled );
}
else
{
// restore the previous value
wantClientAuthCheckbox.setSelection( wantClientAuthStatus );
}
// And disable it or enable it
setEnabled( wantClientAuthCheckbox, !enabled );
// last,
}
};
/**
* As listener for the WantClientAuth checkbox
*/
private SelectionAdapter wantClientAuthListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
boolean enabled = wantClientAuthCheckbox.getSelection();
// Inject the flag in the config - for all the transports, as
// it may be for SSL or startTLS -
TransportBean ldapTransport = getLdapServerTransportBean();
ldapTransport.setWantClientAuth( enabled );
TransportBean ldapsTransport = getLdapsServerTransportBean();
ldapsTransport.setWantClientAuth( enabled );
// Keep a track of the WantClientAuth flag
wantClientAuthStatus = enabled;
}
};
/**
* The SASL Host modify listener
*/
private ModifyListener saslHostTextListener = event ->
getLdapServerBean().setLdapServerSaslHost( saslHostText.getText() );
/**
* The SASL principal modify listener
*/
private ModifyListener saslPrincipalTextListener = event ->
getLdapServerBean().setLdapServerSaslPrincipal( saslPrincipalText.getText() );
/**
* The SASL search Base DN modify listener
*/
private ModifyListener saslSearchBaseDnTextListener = event ->
{
String searchBaseDnValue = saslSearchBaseDnText.getText();
try
{
Dn searchBaseDn = new Dn( searchBaseDnValue );
getLdapServerBean().setSearchBaseDn( searchBaseDn );
}
catch ( LdapInvalidDnException e1 )
{
// Stay silent
}
};
/**
* SASL realms Table change
*/
private ISelectionChangedListener saslRealmsTableViewerSelectionChangedListener = event ->
{
StructuredSelection selection = ( StructuredSelection ) saslRealmsTableViewer.getSelection();
editSaslRealmsButton.setEnabled( !selection.isEmpty() );
deleteSaslRealmsButton.setEnabled( !selection.isEmpty() );
};
/**
* SaslRealms Table double-click
*/
private IDoubleClickListener saslRealmsTableViewerDoubleClickListener = event -> editSaslRealmsAction();
/**
* Add SASL realms button
*/
private SelectionListener addSaslRealmsButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
InputDialog dialog = new InputDialog( editSaslRealmsButton.getShell(),
Messages.getString( "LdapLdapsServersPage.Add" ), //$NON-NLS-1$
Messages.getString( "LdapLdapsServersPage.SaslRealms" ), //$NON-NLS-1$
null, null );
if ( dialog.open() == InputDialog.OK )
{
String newSaslRealms = dialog.getValue();
getLdapServerBean().addSaslRealms( newSaslRealms );
saslRealmsTableViewer.refresh();
saslRealmsTableViewer.setSelection( new StructuredSelection( newSaslRealms ) );
setEditorDirty();
}
}
};
/**
* Edit SASL realms button
*/
private SelectionListener editSaslRealmsButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
editSaslRealmsAction();
}
};
/**
* Delete SASL realms button
*/
private SelectionListener deleteSaslRealmsButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
String selectedSaslRealms = getSelectedSaslRealms();
if ( selectedSaslRealms != null )
{
getLdapServerBean().getLdapServerSaslRealms().remove( selectedSaslRealms );
saslRealmsTableViewer.refresh();
setEditorDirty();
}
}
};
/**
* The AuthMech Simple checkbox listener
*/
private SelectionAdapter authMechSimpleCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SASL_MECHANISMS_SIMPLE, authMechSimpleCheckbox.getSelection() );
}
};
/**
* The AuthMech GSSAPI checkbox listener
*/
private SelectionAdapter authMechGssapiCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SupportedSaslMechanisms.GSSAPI,
authMechGssapiCheckbox.getSelection() );
}
};
/**
* The AuthMech CRAM-MD5 checkbox listener
*/
private SelectionAdapter authMechCramMd5CheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SupportedSaslMechanisms.CRAM_MD5,
authMechCramMd5Checkbox.getSelection() );
}
};
/**
* The AuthMech Digest MD5 checkbox listener
*/
private SelectionAdapter authMechDigestMd5CheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SupportedSaslMechanisms.DIGEST_MD5,
authMechDigestMd5Checkbox.getSelection() );
}
};
/**
* The AuthMech GSS-SPNEGO checkbox listener
*/
private SelectionAdapter authMechGssSpnegoCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SupportedSaslMechanisms.GSS_SPNEGO,
authMechGssSpnegoCheckbox.getSelection() );
setEnabled( authMechGssSpnegoText, authMechGssSpnegoCheckbox.getSelection() );
}
};
/**
* The AuthMech GSS-SPNEGO text listener
*/
private ModifyListener authMechGssSpnegoTextListener = event ->
setNtlmMechProviderSupportedAuthenticationMechanism( SupportedSaslMechanisms.GSS_SPNEGO, authMechGssSpnegoText.getText() );
/**
* The AuthMech NTLM checkbox listener
*/
private SelectionAdapter authMechNtlmCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableSupportedAuthenticationMechanism( SupportedSaslMechanisms.NTLM,
authMechNtlmCheckbox.getSelection() );
setEnabled( authMechNtlmText, authMechNtlmCheckbox.getSelection() );
}
};
/**
* The AuthMech NTLM text listener
*/
private ModifyListener authMechNtlmTextListener = event ->
setNtlmMechProviderSupportedAuthenticationMechanism( SupportedSaslMechanisms.NTLM, authMechNtlmText.getText() );
/**
* The maximum time for a SearchRequest's response
*/
private ModifyListener maxTimeLimitTextListener = event ->
getLdapServerBean().setLdapServerMaxTimeLimit( Integer.parseInt( maxTimeLimitText.getText() ) );
/**
* The maximum size for a SearchRequest's response
*/
private ModifyListener maxSizeLimitTextListener = event ->
getLdapServerBean().setLdapServerMaxSizeLimit( Integer.parseInt( maxSizeLimitText.getText() ) );
/**
* The maximum size for a request PDU
*/
private ModifyListener maxPduSizeTextListener = event ->
getLdapServerBean().setMaxPDUSize( Integer.parseInt( maxPduSizeText.getText() ) );
/**
* Tells if TLS is enabled
*/
private SelectionAdapter enableTlsCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
setEnableTls( enableTlsCheckbox.getSelection() );
}
/**
* Enables/disables TLS.
*
* @param enabled the enabled state
*/
private void setEnableTls( boolean enabled )
{
getTlsExtendedOpHandlerBean().setEnabled( enabled );
}
};
/**
* Tell the server to hash the passwords
*/
private SelectionAdapter enableServerSidePasswordHashingCheckboxListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
if ( enableServerSidePasswordHashingCheckbox.getSelection() )
{
enableHashingPasswordInterceptor();
}
else
{
disableHashingPasswordInterceptor();
}
setEnabled( hashingMethodComboViewer.getCombo(), enableServerSidePasswordHashingCheckbox.getSelection() );
}
/**
* Enables the hashing password interceptor.
*/
private void enableHashingPasswordInterceptor()
{
// Getting the hashing password interceptor
InterceptorBean hashingPasswordInterceptor = getHashingPasswordInterceptor();
// If we didn't found one, we need to create it
if ( hashingPasswordInterceptor == null )
{
// Creating a new hashing password interceptor
hashingPasswordInterceptor = createHashingPasswordInterceptor();
}
// Enabling the interceptor
hashingPasswordInterceptor.setEnabled( true );
}
/**
* Disables the hashing password interceptor.
*/
private void disableHashingPasswordInterceptor()
{
// Getting the hashing password interceptor
InterceptorBean hashingPasswordInterceptor = getHashingPasswordInterceptor();
if ( hashingPasswordInterceptor != null )
{
// Disabling the interceptor
hashingPasswordInterceptor.setEnabled( false );
}
}
};
/**
* The list of method to use to hash the passwords
*/
private ISelectionChangedListener hashingMethodComboViewerListener = event -> updateHashingMethod();
/**
* The keyStore file listener
*/
private ModifyListener keystoreFileTextListener = event ->
{
String keystoreFile = keystoreFileText.getText();
if ( ( keystoreFile == null ) || ( keystoreFile.length() == 0 ) )
{
getLdapServerBean().setLdapServerKeystoreFile( null );
}
else
{
getLdapServerBean().setLdapServerKeystoreFile( keystoreFile );
}
};
/**
* Let the user browse the disk to find the keystore file
*/
private SelectionListener keystoreFileBrowseButtonSelectionListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent event )
{
FileDialog fileDialog = new FileDialog( keystoreFileBrowseButton.getShell(), SWT.OPEN );
File file = new File( keystoreFileText.getText() );
if ( file.isFile() )
{
fileDialog.setFilterPath( file.getParent() );
fileDialog.setFileName( file.getName() );
}
else if ( file.isDirectory() )
{
fileDialog.setFilterPath( file.getPath() );
}
else
{
fileDialog.setFilterPath( null );
}
String returnedFileName = fileDialog.open();
if ( returnedFileName != null )
{
keystoreFileText.setText( returnedFileName );
setEditorDirty();
}
}
};
/**
* The keystore password listener
*/
private ModifyListener keystorePasswordTextListener = event ->
{
String keystorePassword = keystorePasswordText.getText();
if ( ( keystorePassword == null ) || ( keystorePassword.length() == 0 ) )
{
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/AbstractPartitionSpecificDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/AbstractPartitionSpecificDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
/**
* This interface represents a block for Partition configuration.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class AbstractPartitionSpecificDetailsBlock<P extends PartitionBean> implements
PartitionSpecificDetailsBlock
{
/** The details page*/
protected PartitionDetailsPage detailsPage;
/** The partition */
protected P partition;
// Listeners
protected ModifyListener dirtyModifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
detailsPage.setEditorDirty();
}
};
protected WidgetModifyListener dirtyWidgetModifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
detailsPage.setEditorDirty();
}
};
protected SelectionListener dirtySelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
detailsPage.setEditorDirty();
}
};
/**
* Creates a new instance of AbstractPartitionSpecificDetailsBlock.
*
* @param detailsPage the details page
* @param partition the partition
*/
public AbstractPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, P partition )
{
this.detailsPage = detailsPage;
this.partition = partition;
}
/**
* {@inheritDoc}
*/
public PartitionDetailsPage getDetailsPage()
{
return detailsPage;
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPoliciesPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PasswordPoliciesPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.server.config.beans.AuthenticationInterceptorBean;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.InterceptorBean;
import org.apache.directory.server.config.beans.PasswordPolicyBean;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This class represents the PasswordPolicy Page of the Server Configuration Editor. It has
* two parts :
* <ul>
* <li>The list of existing password policies</li>
* <li>The detail for each selected password policy</li>
* </ul>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PasswordPoliciesPage extends ServerConfigurationEditorPage
{
/** The authentication interceptor name */
private static final String AUTHENTICATION_INTERCEPTOR_ID = "authenticationInterceptor";
/** Default name for the passwordPolicy */
private static final String PASSWORD_POLICY_ID_DEFAULT = "default";
/** The Page ID*/
public static final String ID = PasswordPoliciesPage.class.getName();
/** The Page Title */
private static final String TITLE = Messages.getString( "PasswordPoliciesPage.PasswordPolicies" ); //$NON-NLS-1$
/** The Master Details Block */
private PasswordPoliciesMasterDetailsBlock masterDetailsBlock;
/**
* Creates a new instance of GeneralPage.
*
* @param editor the associated editor
*/
public PasswordPoliciesPage( ServerConfigurationEditor editor )
{
super( editor, ID, TITLE );
}
/**
* {@inheritDoc}
*/
protected void createFormContent( Composite parent, FormToolkit toolkit )
{
masterDetailsBlock = new PasswordPoliciesMasterDetailsBlock( this );
masterDetailsBlock.createContent( getManagedForm() );
}
/**
* {@inheritDoc}
*/
protected void refreshUI()
{
if ( isInitialized() )
{
masterDetailsBlock.refreshUI();
}
}
/**
* Gets the Password Policy bean.
*
* @param directoryServiceBean the directory service bean
* @return the Password Policy bean
*/
public static PasswordPolicyBean getPasswordPolicyBean( DirectoryServiceBean directoryServiceBean )
{
// Finding the password policy
PasswordPolicyBean passwordPolicyBean = findPasswordPolicyBean( directoryServiceBean );
if ( passwordPolicyBean == null )
{
addPasswordPolicyBean( directoryServiceBean );
}
return passwordPolicyBean;
}
/**
* Gets the Password Policy bean.
*
* @param directoryServiceBean the directory service bean
* @return the Password Policy bean
*/
private static PasswordPolicyBean findPasswordPolicyBean( DirectoryServiceBean directoryServiceBean )
{
return getPasswordPolicyBean( getAuthenticationInterceptorBean( directoryServiceBean ) );
}
/**
* Gets the authentication interceptor.
*
* @param directoryServiceBean the directory service bean
* @return the authentication interceptor
*/
private static AuthenticationInterceptorBean getAuthenticationInterceptorBean(
DirectoryServiceBean directoryServiceBean )
{
// Looking for the authentication interceptor
for ( InterceptorBean interceptor : directoryServiceBean.getInterceptors() )
{
if ( AUTHENTICATION_INTERCEPTOR_ID.equalsIgnoreCase( interceptor.getInterceptorId() )
&& ( interceptor instanceof AuthenticationInterceptorBean ) )
{
return ( AuthenticationInterceptorBean ) interceptor;
}
}
return null;
}
/**
* Gets the Password Policy bean.
*
* @param authenticationInterceptor the authentication interceptor
* @return the Password Policy bean
*/
private static PasswordPolicyBean getPasswordPolicyBean( AuthenticationInterceptorBean authenticationInterceptor )
{
// Looking for the default password policy
if ( authenticationInterceptor != null )
{
for ( PasswordPolicyBean passwordPolicy : authenticationInterceptor.getPasswordPolicies() )
{
if ( PASSWORD_POLICY_ID_DEFAULT.equalsIgnoreCase( passwordPolicy.getPwdId() ) )
{
return passwordPolicy;
}
}
}
return null;
}
/**
* Adds the password policy to the directory service.
*
* @param directoryServiceBean the directory service bean
*/
private static void addPasswordPolicyBean( DirectoryServiceBean directoryServiceBean )
{
AuthenticationInterceptorBean authenticationInterceptor = getAuthenticationInterceptorBean( directoryServiceBean );
if ( authenticationInterceptor != null )
{
// Creating the password policy
PasswordPolicyBean passwordPolicy = new PasswordPolicyBean();
// Configuring the password policy
passwordPolicy.setPwdId( PASSWORD_POLICY_ID_DEFAULT );
passwordPolicy.setPwdAttribute( SchemaConstants.USER_PASSWORD_AT );
passwordPolicy.setPwdMinAge( 0 );
passwordPolicy.setPwdMaxAge( 0 );
passwordPolicy.setPwdInHistory( 5 );
passwordPolicy.setPwdCheckQuality( 1 );
passwordPolicy.setPwdMinLength( 5 );
passwordPolicy.setPwdMaxLength( 0 );
passwordPolicy.setPwdExpireWarning( 600 );
passwordPolicy.setPwdGraceAuthNLimit( 5 );
passwordPolicy.setPwdGraceExpire( 0 );
passwordPolicy.setPwdLockout( true );
passwordPolicy.setPwdLockoutDuration( 0 );
passwordPolicy.setPwdMaxFailure( 5 );
passwordPolicy.setPwdFailureCountInterval( 30 );
passwordPolicy.setPwdMustChange( false );
passwordPolicy.setPwdAllowUserChange( true );
passwordPolicy.setPwdMinDelay( 0 );
passwordPolicy.setPwdMaxDelay( 0 );
passwordPolicy.setPwdMaxIdle( 0 );
passwordPolicy
.setPwdValidator( "org.apache.directory.server.core.api.authn.ppolicy.DefaultPasswordValidator" );
// Adding the password policy to the authentication interceptor
authenticationInterceptor.addPasswordPolicies( passwordPolicy );
}
}
/**
* Indicates if the given password policy is the default one.
*
* @param passwordPolicy the password policy
* @return <code>true</code> if the given password policy is the default one,
* <code>false</code> if not.
*/
public static boolean isDefaultPasswordPolicy( PasswordPolicyBean passwordPolicy )
{
if ( passwordPolicy != null )
{
return PASSWORD_POLICY_ID_DEFAULT.equalsIgnoreCase( passwordPolicy.getPwdId() );
}
return false;
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationDetailsPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationDetailsPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.config.beans.ReplConsumerBean;
import org.apache.directory.studio.common.ui.dialogs.AttributeDialog;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
import org.apache.directory.studio.ldapbrowser.common.widgets.search.FilterWidget;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.utils.SchemaObjectLoader;
import org.apache.directory.studio.common.ui.wrappers.StringValueWrapper;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
* This class represents the Details Page of the Server Configuration Editor for the Replication type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ReplicationDetailsPage implements IDetailsPage
{
/** The associated Master Details Block */
private ReplicationMasterDetailsBlock masterDetailsBlock;
/** The Managed Form */
private IManagedForm mform;
/** The input consumer */
private ReplConsumerBean input;
/** The browser connection */
private IBrowserConnection browserConnection;
/** The Attribute list loader */
private SchemaObjectLoader attributeLoader;
/** The list of attributes */
private List<String> attributesList = new ArrayList<String>();
// UI Widgets
private Button enabledCheckbox;
private Text idText;
private Text descriptionText;
private Button refreshAndPersistModeButton;
private Button refreshOnlyModeButton;
private Text refreshIntervalText;
private Text remoteHostText;
private Text remotePortText;
private Text bindDnText;
private Text bindPasswordText;
private Button showPasswordCheckbox;
private Button useStartTlsCheckbox;
private Text sizeLimitText;
private Text timeLimitText;
private EntryWidget entryWidget;
private FilterWidget filterWidget;
private Button subtreeScopeButton;
private Button oneLevelScopeButton;
private Button objectScopeButton;
private Button allAttributesCheckbox;
private TableViewer attributesTableViewer;
private Button addAttributeButton;
private Button editAttributeButton;
private Button deleteAttributeButton;
private Button findingBaseDnAliasesDereferencingButton;
private Button searchAliasesDereferencingButton;
// Listeners
/** The Text Modify Listener */
private ModifyListener textModifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
/** The button Selection Listener */
private SelectionListener buttonSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
/** The widget Modify Listener */
private WidgetModifyListener widgetModifyListener = new WidgetModifyListener()
{
public void widgetModified( WidgetModifyEvent event )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
private VerifyListener integerVerifyListener = new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
e.doit = false;
}
}
};
private SelectionListener showPasswordCheckboxSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
if ( showPasswordCheckbox.getSelection() )
{
bindPasswordText.setEchoChar( '\0' );
}
else
{
bindPasswordText.setEchoChar( '\u2022' );
}
}
};
private ISelectionChangedListener attributesTableViewerSelectionListener = new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
updateAttributesButtonsEnableState();
}
};
/** The Double Click Listener for the Indexed Attributes Table Viewer */
private IDoubleClickListener attributesTableViewerDoubleClickListener = new IDoubleClickListener()
{
public void doubleClick( DoubleClickEvent event )
{
editSelectedAttribute();
}
};
private SelectionListener addAttributeButtonSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
addNewAttribute();
}
};
private SelectionListener editAttributeButtonSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
editSelectedAttribute();
}
};
private SelectionListener deleteAttributeButtonSelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
deleteSelectedAttribute();
}
};
/**
* Creates a new instance of ReplicationDetailsPage.
*
* @param pmdb
* the associated Master Details Block
*/
public ReplicationDetailsPage( ReplicationMasterDetailsBlock pmdb )
{
masterDetailsBlock = pmdb;
attributeLoader = new SchemaObjectLoader();
// Getting the browser connection associated with the connection in the configuration
browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( masterDetailsBlock.getPage().getConnection() );
}
/**
* {@inheritDoc}
*/
public void createContents( Composite parent )
{
FormToolkit toolkit = mform.getToolkit();
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = 5;
layout.leftMargin = 5;
layout.rightMargin = 2;
layout.bottomMargin = 2;
parent.setLayout( layout );
createDetailsSection( parent, toolkit );
createConnectionSection( parent, toolkit );
createConfigurationSection( parent, toolkit );
}
/**
* Creates the Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createDetailsSection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Replication Consumer Details" );
section.setDescription( "Set the properties of the replication consumer." );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
GridLayout glayout = new GridLayout( 2, false );
client.setLayout( glayout );
section.setClient( client );
// Enabled Checkbox
enabledCheckbox = toolkit.createButton( client, "Enabled", SWT.CHECK );
enabledCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
// ID Text
toolkit.createLabel( client, "ID:" );
idText = toolkit.createText( client, "" );
idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Description Text
toolkit.createLabel( client, "Description:" );
descriptionText = toolkit.createText( client, "" );
descriptionText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
}
/**
* Creates the Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createConnectionSection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Connection" );
section.setDescription( "Set the properties of the connection." );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
composite.setLayout( new GridLayout( 2, false ) );
section.setClient( composite );
// Replication Mode
toolkit.createLabel( composite, "Replication Mode:" );
// Refresh And Persist Mode Button
refreshAndPersistModeButton = toolkit.createButton( composite, "Refresh And Persist", SWT.RADIO );
refreshAndPersistModeButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false ) );
// Refresh Only Mode Button
toolkit.createLabel( composite, "" );
refreshOnlyModeButton = toolkit.createButton( composite, "Refresh Only", SWT.RADIO );
refreshOnlyModeButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false ) );
// Refresh Interval
toolkit.createLabel( composite, "" );
Composite refreshIntervalComposite = toolkit.createComposite( composite );
refreshIntervalComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
refreshIntervalComposite.setLayout( new GridLayout( 3, false ) );
toolkit.createLabel( refreshIntervalComposite, " " );
toolkit.createLabel( refreshIntervalComposite, "Refresh Interval (ms):" );
refreshIntervalText = toolkit.createText( refreshIntervalComposite, "" );
refreshIntervalText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Remote Host Text
toolkit.createLabel( composite, "Remote Host:" );
remoteHostText = toolkit.createText( composite, "" );
remoteHostText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Remote Port Text
toolkit.createLabel( composite, "Remote Port:" );
remotePortText = toolkit.createText( composite, "" );
remotePortText.addVerifyListener( integerVerifyListener );
remotePortText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Bind DN Text
toolkit.createLabel( composite, "Bind DN:" );
bindDnText = toolkit.createText( composite, "" );
bindDnText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Bind Password Text
toolkit.createLabel( composite, "Bind Password:" );
bindPasswordText = toolkit.createText( composite, "" );
bindPasswordText.setEchoChar( '\u2022' );
bindPasswordText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Show Password Checkbox
toolkit.createLabel( composite, "" ); //$NON-NLS-1$
showPasswordCheckbox = toolkit.createButton( composite, "Show password", SWT.CHECK );
showPasswordCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
showPasswordCheckbox.setSelection( false );
// Size Limit Text
toolkit.createLabel( composite, "Size Limit:" );
sizeLimitText = toolkit.createText( composite, "" );
sizeLimitText.addVerifyListener( integerVerifyListener );
sizeLimitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Time Limit Text
toolkit.createLabel( composite, "Time Limit:" );
timeLimitText = toolkit.createText( composite, "" );
timeLimitText.addVerifyListener( integerVerifyListener );
timeLimitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Use Start TLS
toolkit.createLabel( composite, "" ); //$NON-NLS-1$
useStartTlsCheckbox = toolkit.createButton( composite, "Use Start TLS", SWT.CHECK );
useStartTlsCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
useStartTlsCheckbox.setSelection( false );
}
/**
* Creates the Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createConfigurationSection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Configuration" );
section.setDescription( "Set the properties of the configuration." );
TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
td.grabHorizontal = true;
section.setLayoutData( td );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout glayout = new GridLayout( 3, false );
composite.setLayout( glayout );
section.setClient( composite );
// Base DN Text
toolkit.createLabel( composite, "Base DN:" );
entryWidget = new EntryWidget( browserConnection, Dn.EMPTY_DN );
entryWidget.createWidget( composite );
// Filter Text
toolkit.createLabel( composite, "Filter:" );
filterWidget = new FilterWidget();
filterWidget.setBrowserConnection( browserConnection );
filterWidget.createWidget( composite );
// Scope
Label scopeLabel = toolkit.createLabel( composite, "Scope:" );
scopeLabel.setLayoutData( new GridData( SWT.BEGINNING, SWT.TOP, false, false, 1, 3 ) );
// Subtree Scope Button
subtreeScopeButton = toolkit.createButton( composite, "Subtree", SWT.RADIO );
subtreeScopeButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false, 2, 1 ) );
// One Level Scope Button
oneLevelScopeButton = toolkit.createButton( composite, "One Level", SWT.RADIO );
oneLevelScopeButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false, 2, 1 ) );
// Object Scope Button
objectScopeButton = toolkit.createButton( composite, "Object", SWT.RADIO );
objectScopeButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false, 2, 1 ) );
// Attributes Label
Label attributesLabel = toolkit.createLabel( composite, "Attributes:" );
attributesLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, false, false ) );
// All Attributes Checkbox
allAttributesCheckbox = toolkit.createButton( composite, "All Attributes", SWT.CHECK );
allAttributesCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) );
// Attributes Table Viewer
toolkit.createLabel( composite, "" ); //$NON-NLS-1$
Composite attributesTableComposite = toolkit.createComposite( composite );
GridLayout gl = new GridLayout( 2, false );
gl.marginWidth = gl.marginHeight = 0;
attributesTableComposite.setLayout( gl );
attributesTableComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
Table attributesTable = toolkit.createTable( attributesTableComposite, SWT.BORDER );
attributesTable.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ) );
attributesTableViewer = new TableViewer( attributesTable );
attributesTableViewer.setContentProvider( new ArrayContentProvider() );
attributesTableViewer.setInput( attributesList );
addAttributeButton = toolkit.createButton( attributesTableComposite, "Add...", SWT.PUSH );
addAttributeButton.setLayoutData( createNewButtonGridData() );
editAttributeButton = toolkit.createButton( attributesTableComposite, "Edit...", SWT.PUSH );
editAttributeButton.setEnabled( false );
editAttributeButton.setLayoutData( createNewButtonGridData() );
deleteAttributeButton = toolkit.createButton( attributesTableComposite, "Delete", SWT.PUSH );
deleteAttributeButton.setEnabled( false );
deleteAttributeButton.setLayoutData( createNewButtonGridData() );
// Aliases Dereferencing Text
Label aliasesDereferencingLable = toolkit.createLabel( composite, "Aliases\nDereferencing:" );
aliasesDereferencingLable.setLayoutData( new GridData( SWT.BEGINNING, SWT.TOP, false, false, 1, 2 ) );
// Finding Base DN Aliases Dereferencing Button
findingBaseDnAliasesDereferencingButton = toolkit.createButton( composite, "Finding Base DN", SWT.CHECK );
findingBaseDnAliasesDereferencingButton
.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false, 2, 1 ) );
// Search Aliases Dereferencing Button
searchAliasesDereferencingButton = toolkit.createButton( composite, "Search", SWT.CHECK );
searchAliasesDereferencingButton.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false, 2, 1 ) );
}
/**
* Updates the attributes buttons enable state.
*/
private void updateAttributesButtonsEnableState()
{
ISelection selection = attributesTableViewer.getSelection();
editAttributeButton.setEnabled( !selection.isEmpty() );
deleteAttributeButton.setEnabled( !selection.isEmpty() );
}
/**
* Adds a new attribute and opens the attribute dialog.
*/
private void addNewAttribute()
{
AttributeDialog dialog = new AttributeDialog( addAttributeButton.getShell() );
dialog.addNewElement();
dialog.setAttributeNamesAndOids( attributeLoader.getAttributeNamesAndOids() );
if ( AttributeDialog.OK == dialog.open() )
{
String newAttribute = dialog.getEditedElement().getValue();
if ( !attributesList.contains( newAttribute ) )
{
attributesList.add( newAttribute );
}
attributesTableViewer.refresh();
attributesTableViewer.setSelection( new StructuredSelection( newAttribute ) );
masterDetailsBlock.setEditorDirty();
}
}
/**
* Opens an attribute dialog with the selected attribute in the attributes table viewer.
*/
private void editSelectedAttribute()
{
StructuredSelection selection = ( StructuredSelection ) attributesTableViewer.getSelection();
if ( !selection.isEmpty() )
{
String attribute = ( String ) selection.getFirstElement();
AttributeDialog dialog = new AttributeDialog( addAttributeButton.getShell() );
dialog.setEditedElement( new StringValueWrapper( attribute, false ) );
dialog.setAttributeNamesAndOids( attributeLoader.getAttributeNamesAndOids() );
if ( AttributeDialog.OK == dialog.open() )
{
attributesList.remove( attribute );
String newAttribute = dialog.getEditedElement().getValue();
if ( !attributesList.contains( newAttribute ) )
{
attributesList.add( newAttribute );
}
attributesTableViewer.refresh();
attributesTableViewer.setSelection( new StructuredSelection( newAttribute ) );
masterDetailsBlock.setEditorDirty();
}
}
}
/**
* Deletes the selected index in the indexes table viewer.
*/
private void deleteSelectedAttribute()
{
StructuredSelection selection = ( StructuredSelection ) attributesTableViewer.getSelection();
if ( !selection.isEmpty() )
{
String attribute = ( String ) selection.getFirstElement();
attributesList.remove( attribute );
attributesTableViewer.refresh();
masterDetailsBlock.setEditorDirty();
}
}
/**
* Create a new button grid data.
*
* @return the new button grid data
*/
private GridData createNewButtonGridData()
{
GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
gd.widthHint = IDialogConstants.BUTTON_WIDTH;
return gd;
}
/**
* Adds listeners to UI fields.
*/
private void addListeners()
{
enabledCheckbox.addSelectionListener( buttonSelectionListener );
idText.addModifyListener( textModifyListener );
descriptionText.addModifyListener( textModifyListener );
refreshAndPersistModeButton.addSelectionListener( buttonSelectionListener );
refreshOnlyModeButton.addSelectionListener( buttonSelectionListener );
refreshIntervalText.addModifyListener( textModifyListener );
remoteHostText.addModifyListener( textModifyListener );
remotePortText.addModifyListener( textModifyListener );
bindDnText.addModifyListener( textModifyListener );
bindPasswordText.addModifyListener( textModifyListener );
showPasswordCheckbox.addSelectionListener( showPasswordCheckboxSelectionListener );
sizeLimitText.addModifyListener( textModifyListener );
timeLimitText.addModifyListener( textModifyListener );
useStartTlsCheckbox.addSelectionListener( buttonSelectionListener );
entryWidget.addWidgetModifyListener( widgetModifyListener );
filterWidget.addWidgetModifyListener( widgetModifyListener );
subtreeScopeButton.addSelectionListener( buttonSelectionListener );
oneLevelScopeButton.addSelectionListener( buttonSelectionListener );
objectScopeButton.addSelectionListener( buttonSelectionListener );
allAttributesCheckbox.addSelectionListener( buttonSelectionListener );
attributesTableViewer.addDoubleClickListener( attributesTableViewerDoubleClickListener );
attributesTableViewer.addSelectionChangedListener( attributesTableViewerSelectionListener );
addAttributeButton.addSelectionListener( addAttributeButtonSelectionListener );
editAttributeButton.addSelectionListener( editAttributeButtonSelectionListener );
deleteAttributeButton.addSelectionListener( deleteAttributeButtonSelectionListener );
findingBaseDnAliasesDereferencingButton.addSelectionListener( buttonSelectionListener );
searchAliasesDereferencingButton.addSelectionListener( buttonSelectionListener );
}
/**
* Removes listeners to UI fields.
*/
private void removeListeners()
{
enabledCheckbox.removeSelectionListener( buttonSelectionListener );
idText.removeModifyListener( textModifyListener );
descriptionText.removeModifyListener( textModifyListener );
refreshAndPersistModeButton.removeSelectionListener( buttonSelectionListener );
refreshOnlyModeButton.removeSelectionListener( buttonSelectionListener );
refreshIntervalText.removeModifyListener( textModifyListener );
remoteHostText.removeModifyListener( textModifyListener );
remotePortText.removeModifyListener( textModifyListener );
bindDnText.removeModifyListener( textModifyListener );
bindPasswordText.removeModifyListener( textModifyListener );
showPasswordCheckbox.removeSelectionListener( showPasswordCheckboxSelectionListener );
sizeLimitText.removeModifyListener( textModifyListener );
timeLimitText.removeModifyListener( textModifyListener );
useStartTlsCheckbox.removeSelectionListener( buttonSelectionListener );
entryWidget.removeWidgetModifyListener( widgetModifyListener );
filterWidget.removeWidgetModifyListener( widgetModifyListener );
subtreeScopeButton.removeSelectionListener( buttonSelectionListener );
oneLevelScopeButton.removeSelectionListener( buttonSelectionListener );
objectScopeButton.removeSelectionListener( buttonSelectionListener );
allAttributesCheckbox.removeSelectionListener( buttonSelectionListener );
attributesTableViewer.removeDoubleClickListener( attributesTableViewerDoubleClickListener );
attributesTableViewer.removeSelectionChangedListener( attributesTableViewerSelectionListener );
addAttributeButton.removeSelectionListener( addAttributeButtonSelectionListener );
editAttributeButton.removeSelectionListener( editAttributeButtonSelectionListener );
deleteAttributeButton.removeSelectionListener( deleteAttributeButtonSelectionListener );
findingBaseDnAliasesDereferencingButton.removeSelectionListener( buttonSelectionListener );
searchAliasesDereferencingButton.removeSelectionListener( buttonSelectionListener );
}
/**
* {@inheritDoc}
*/
public void selectionChanged( IFormPart part, ISelection selection )
{
IStructuredSelection ssel = ( IStructuredSelection ) selection;
if ( ssel.size() == 1 )
{
input = ( ReplConsumerBean ) ssel.getFirstElement();
}
else
{
input = null;
}
refresh();
}
/**
* {@inheritDoc}
*/
public void commit( boolean onSave )
{
if ( input != null )
{
// Enabled
input.setEnabled( enabledCheckbox.getSelection() );
// ID
input.setReplConsumerId( ServerConfigurationEditorUtils.checkEmptyString( idText.getText() ) );
// Description
input.setDescription( ServerConfigurationEditorUtils.checkEmptyString( descriptionText.getText() ) );
// Refresh Mode
input.setReplRefreshNPersist( refreshAndPersistModeButton.getSelection() );
// Refresh Interval
try
{
input.setReplRefreshInterval( Long.parseLong( refreshIntervalText.getText() ) );
}
catch ( NumberFormatException e )
{
input.setReplRefreshInterval( 60000 );
}
// Remote Host
input.setReplProvHostName( ServerConfigurationEditorUtils.checkEmptyString( remoteHostText.getText() ) );
// Remote Port
try
{
input.setReplProvPort( Integer.parseInt( remotePortText.getText() ) );
}
catch ( NumberFormatException e )
{
input.setReplProvPort( 0 );
}
// Bind DN
input.setReplUserDn( ServerConfigurationEditorUtils.checkEmptyString( bindDnText.getText() ) );
// Bind Password
String password = ServerConfigurationEditorUtils.checkEmptyString( bindPasswordText.getText() );
if ( password != null )
{
input.setReplUserPassword( password.getBytes() );
}
else
{
input.setReplUserPassword( null );
}
// Size Limit
try
{
input.setReplSearchSizeLimit( Integer.parseInt( sizeLimitText.getText() ) );
}
catch ( NumberFormatException e )
{
input.setReplSearchSizeLimit( 0 );
}
// Time Limit
try
{
input.setReplSearchTimeout( Integer.parseInt( timeLimitText.getText() ) );
}
catch ( NumberFormatException e )
{
input.setReplSearchTimeout( 0 );
}
// Use Start TLS
input.setReplUseTls( useStartTlsCheckbox.getSelection() );
// Search Base DN
Dn baseDn = entryWidget.getDn();
if ( baseDn != null )
{
input.setSearchBaseDn( ServerConfigurationEditorUtils.checkEmptyString( baseDn.toString() ) );
}
else
{
input.setSearchBaseDn( null );
}
// Search Filter
input.setReplSearchFilter( ServerConfigurationEditorUtils.checkEmptyString( filterWidget.getFilter() ) );
// Search Scope
SearchScope scope = getSearchScope();
if ( scope != null )
{
input.setReplSearchScope( scope.getLdapUrlValue() );
}
else
{
input.setReplSearchScope( null );
}
// Aliases Dereferencing
input.setReplAliasDerefMode( getAliasDerefMode().getJndiValue() );
// Attributes
List<String> replAttributes = new ArrayList<String>();
replAttributes.addAll( attributesList );
// All (User) Attribute
if ( allAttributesCheckbox.getSelection() )
{
replAttributes.add( SchemaConstants.ALL_USER_ATTRIBUTES );
}
input.setReplAttributes( replAttributes );
}
}
/**
* Gets the search scope.
*
* @return the search scope
*/
private SearchScope getSearchScope()
{
if ( subtreeScopeButton.getSelection() )
{
return SearchScope.SUBTREE;
}
else if ( oneLevelScopeButton.getSelection() )
{
return SearchScope.ONELEVEL;
}
else if ( objectScopeButton.getSelection() )
{
return SearchScope.OBJECT;
}
return null;
}
/**
* Gets the aliases dereferencing mode.
*
* @return the aliases dereferencing mode
*/
private AliasDerefMode getAliasDerefMode()
{
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ConnectionServerConfigurationInput.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ConnectionServerConfigurationInput.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.studio.apacheds.configuration.jobs.EntryBasedConfigurationPartition;
import org.apache.directory.studio.connection.core.Connection;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
* This class represents the Non Existing Server Configuration Input.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ConnectionServerConfigurationInput implements IEditorInput
{
/** The connection */
private Connection connection;
/** The original configuration partition */
private EntryBasedConfigurationPartition originalPartition;
/**
* Creates a new instance of ConnectionServerConfigurationInput.
*
* @param connection
* the connection
*/
public ConnectionServerConfigurationInput( Connection connection )
{
this.connection = connection;
}
/**
* Gets the connection.
*
* @return
* the connection
*/
public Connection getConnection()
{
return connection;
}
/**
* Gets the original configuration partition.
*
* @return
* the original configuration partition
*/
public EntryBasedConfigurationPartition getOriginalPartition()
{
return originalPartition;
}
/**
* Sets the original configuration partition.
*
* @param originalPartition
* the original configuration
*/
public void setOriginalPartition( EntryBasedConfigurationPartition originalPartition )
{
this.originalPartition = originalPartition;
}
/**
* {@inheritDoc}
*/
public String getToolTipText()
{
return NLS.bind(
Messages.getString( "ConnectionServerConfigurationInput.ConnectionConfiguration" ), connection.getName() ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public String getName()
{
return NLS.bind(
Messages.getString( "ConnectionServerConfigurationInput.ConnectionConfiguration" ), connection.getName() ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public boolean exists()
{
return connection != null;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return null;
}
/**
* {@inheritDoc}
*/
public IPersistableElement getPersistable()
{
return null;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
public Object getAdapter( Class adapter )
{
return null;
}
/**
* {@inheritDoc}
*/
public boolean equals( Object obj )
{
if ( obj instanceof ConnectionServerConfigurationInput )
{
ConnectionServerConfigurationInput input = ( ConnectionServerConfigurationInput ) obj;
if ( input.exists() && exists() )
{
Connection inputConnection = input.getConnection();
if ( inputConnection != null )
{
return inputConnection.equals( connection );
}
}
}
return false;
}
/**
* {@inheritDoc}
*/
public int hashCode()
{
return connection.hashCode();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionDetailsPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionDetailsPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.DefaultAttribute;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.ldif.LdifReader;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.config.beans.IndexBean;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
import org.apache.directory.server.config.beans.MavibotIndexBean;
import org.apache.directory.server.config.beans.MavibotPartitionBean;
import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.dialogs.AttributeValueDialog;
import org.apache.directory.studio.apacheds.configuration.dialogs.JdbmIndexDialog;
import org.apache.directory.studio.apacheds.configuration.dialogs.MavibotIndexDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
/**
* This class represents the Details Page of the Server Configuration Editor for the Partition type
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PartitionDetailsPage implements IDetailsPage
{
/** The class instance */
private PartitionDetailsPage instance;
/** The associated Master Details Block */
private PartitionsMasterDetailsBlock masterDetailsBlock;
/** The partition wrapper */
private PartitionWrapper partitionWrapper;
/** The partition specific details block */
private PartitionSpecificDetailsBlock partitionSpecificDetailsBlock;
/** The Context Entry */
private Entry contextEntry;
/** The Indexes List */
private List<IndexBean> indexesList;
// UI fields
private Composite parentComposite;
private FormToolkit toolkit;
private Composite partitionSpecificDetailsComposite;
private Section specificSettingsSection;
private Composite specificSettingsSectionComposite;
private ComboViewer partitionTypeComboViewer;
private Text idText;
private Text suffixText;
private Button synchOnWriteCheckbox;
private Button autoGenerateContextEntryCheckbox;
private TableViewer contextEntryTableViewer;
private Button contextEntryAddButton;
private Button contextEntryEditButton;
private Button contextEntryDeleteButton;
private TableViewer indexesTableViewer;
private Button indexesAddButton;
private Button indexesEditButton;
private Button indexesDeleteButton;
// Listeners
/** The Text Modify Listener */
private ModifyListener textModifyListener = event ->
{
commit( true );
masterDetailsBlock.setEditorDirty();
};
private ModifyListener suffixTextModifyListener = event -> autoGenerateContextEntry();
/** The Checkbox Selection Listener */
private SelectionListener checkboxSelectionListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
commit( true );
masterDetailsBlock.setEditorDirty();
}
};
private SelectionListener autoGenerateContextEntryCheckboxSelectionListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
autoGenerateContextEntry();
updateContextEntryEnableState();
}
};
/** The Selection Changed Listener for the Context Entry Table Viewer */
private ISelectionChangedListener contextEntryTableViewerSelectionListener = event -> updateContextEntryEnableState();
/** The Double Click Listener for the Indexed Attributes Table Viewer */
private IDoubleClickListener contextEntryTableViewerDoubleClickListener = event -> editSelectedContextEntry();
/** The Listener for the Add button of the Context Entry Section */
private SelectionListener contextEntryAddButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
AttributeValueDialog dialog = new AttributeValueDialog( new AttributeValueObject( "", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$
if ( AttributeValueDialog.OK == dialog.open() && dialog.isDirty() )
{
AttributeValueObject newAttributeValueObject = dialog.getAttributeValueObject();
Attribute attribute = contextEntry.get( newAttributeValueObject.getAttribute() );
if ( attribute != null )
{
try
{
attribute.add( newAttributeValueObject.getValue() );
}
catch ( LdapInvalidAttributeValueException liave )
{
// Will never occur
}
}
else
{
try
{
contextEntry.put( new DefaultAttribute( newAttributeValueObject.getAttribute(),
newAttributeValueObject.getValue() ) );
}
catch ( LdapException e1 )
{
// Will never occur
}
}
contextEntryTableViewer.refresh();
resizeContextEntryTableColumnsToFit();
masterDetailsBlock.setEditorDirty();
// dirty = true; TODO
commit( true );
}
}
};
private ISelectionChangedListener partitionTypeComboViewerSelectionChangedListener = event ->
{
PartitionType type = ( PartitionType ) ( ( StructuredSelection ) partitionTypeComboViewer.getSelection() )
.getFirstElement();
if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
{
PartitionBean partition = partitionWrapper.getPartition();
// Only change the type if it's a different one
if ( type != PartitionType.fromPartition( partition ) )
{
switch ( type )
{
case JDBM:
JdbmPartitionBean newJdbmPartition = new JdbmPartitionBean();
copyPartitionProperties( partition, newJdbmPartition );
partitionWrapper.setPartition( newJdbmPartition );
break;
case MAVIBOT:
MavibotPartitionBean newMavibotPartition = new MavibotPartitionBean();
copyPartitionProperties( partition, newMavibotPartition );
partitionWrapper.setPartition( newMavibotPartition );
break;
default:
break;
}
refresh();
setEditorDirty();
}
}
};
/** The Listener for the Edit button of the Context Entry Section */
private SelectionListener contextEntryEditButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
editSelectedContextEntry();
}
};
/** The Listener for the Delete button of the Context Entry Section */
private SelectionListener contextEntryDeleteButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
StructuredSelection selection = ( StructuredSelection ) contextEntryTableViewer.getSelection();
if ( !selection.isEmpty() )
{
AttributeValueObject attributeValueObject = ( AttributeValueObject ) selection.getFirstElement();
Attribute attribute = contextEntry.get( attributeValueObject.getAttribute() );
if ( attribute != null )
{
attribute.remove( attributeValueObject.getValue() );
contextEntryTableViewer.refresh();
resizeContextEntryTableColumnsToFit();
masterDetailsBlock.setEditorDirty();
// dirty = true; TODO
commit( true );
}
}
}
};
/** The Selection Changed Listener for the Indexed Attributes Table Viewer */
private ISelectionChangedListener indexedAttributesTableViewerListener = event ->
{
indexesEditButton.setEnabled( !event.getSelection().isEmpty() );
indexesDeleteButton.setEnabled( !event.getSelection().isEmpty() );
};
/** The Double Click Listener for the Indexed Attributes Table Viewer */
private IDoubleClickListener indexedAttributesTableViewerDoubleClickListener = event -> editSelectedIndex();
/** The Listener for the Add button of the Indexed Attributes Section */
private SelectionListener indexedAttributeAddButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
addNewIndex();
}
/**
* Adds a new index and opens the index dialog.
*/
private void addNewIndex()
{
PartitionType partitionType = ( PartitionType ) ( ( StructuredSelection ) partitionTypeComboViewer
.getSelection() ).getFirstElement();
if ( partitionType != null )
{
IndexBean newIndex = null;
// JDBM partition
if ( partitionType == PartitionType.JDBM )
{
JdbmIndexBean newJdbmIndex = new JdbmIndexBean();
newJdbmIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
newJdbmIndex.setIndexCacheSize( 100 );
JdbmIndexDialog dialog = new JdbmIndexDialog( newJdbmIndex );
if ( JdbmIndexDialog.OK == dialog.open() )
{
newIndex = dialog.getIndex();
}
else
{
// Cancel
return;
}
}
// Mavibot Partition
else if ( partitionType == PartitionType.MAVIBOT )
{
MavibotIndexBean newMavibotIndex = new MavibotIndexBean();
newMavibotIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
MavibotIndexDialog dialog = new MavibotIndexDialog( newMavibotIndex );
if ( MavibotIndexDialog.OK == dialog.open() )
{
newIndex = dialog.getIndex();
}
else
{
// Cancel
return;
}
}
// Checking the new index
if ( newIndex != null )
{
indexesList.add( newIndex );
indexesTableViewer.refresh();
indexesTableViewer.setSelection( new StructuredSelection( newIndex ) );
masterDetailsBlock.setEditorDirty();
}
}
}
};
/** The Listener for the Edit button of the Indexed Attributes Section */
private SelectionListener indexedAttributeEditButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
editSelectedIndex();
}
};
/** The Listener for the Delete button of the Indexed Attributes Section */
private SelectionListener indexedAttributeDeleteButtonListener = new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent e )
{
deleteSelectedIndex();
}
/**
* Deletes the selected index in the indexes table viewer
*/
private void deleteSelectedIndex()
{
StructuredSelection selection = ( StructuredSelection ) indexesTableViewer.getSelection();
if ( !selection.isEmpty() )
{
IndexBean selectedIndex = ( IndexBean ) selection.getFirstElement();
if ( MessageDialog
.openConfirm( indexesDeleteButton.getShell(),
Messages.getString( "PartitionDetailsPage.ConfirmDelete" ), //$NON-NLS-1$
NLS.bind(
Messages.getString( "PartitionDetailsPage.AreYouSureDeleteIndex" ), selectedIndex.getIndexAttributeId() ) ) ) //$NON-NLS-1$
{
indexesList.remove( selectedIndex );
indexesTableViewer.refresh();
masterDetailsBlock.setEditorDirty();
}
}
}
};
/**
* Creates a new instance of PartitionDetailsPage.
*
* @param pmdb
* the associated Master Details Block
*/
public PartitionDetailsPage( PartitionsMasterDetailsBlock pmdb )
{
instance = this;
masterDetailsBlock = pmdb;
}
/**
* {@inheritDoc}
*/
public void createContents( Composite parent )
{
this.parentComposite = parent;
parent.setLayout( new GridLayout() );
createGeneralDetailsSection( parent, toolkit );
createContextEntrySection( parent, toolkit );
createPartitionSpecificSettingsSection( parent, toolkit );
createIndexesSection( parent, toolkit );
}
/**
* Creates the General Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createGeneralDetailsSection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( Messages.getString( "PartitionDetailsPage.PartitionsGeneralDetails" ) ); //$NON-NLS-1$
section.setDescription( Messages.getString( "PartitionDetailsPage.SetPropertiesOfPartition" ) ); //$NON-NLS-1$
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
GridLayout glayout = new GridLayout( 2, false );
client.setLayout( glayout );
section.setClient( client );
// Type
toolkit.createLabel( client, "Partition Type:" );
Combo partitionTypeCombo = new Combo( client, SWT.READ_ONLY | SWT.SINGLE );
partitionTypeCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
partitionTypeComboViewer = new ComboViewer( partitionTypeCombo );
partitionTypeComboViewer.setContentProvider( new ArrayContentProvider() );
partitionTypeComboViewer.setInput( new Object[]
{ PartitionType.JDBM, PartitionType.MAVIBOT } );
// ID
toolkit.createLabel( client, Messages.getString( "PartitionDetailsPage.Id" ) ); //$NON-NLS-1$
idText = toolkit.createText( client, "" ); //$NON-NLS-1$
idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Suffix
toolkit.createLabel( client, "Suffix:" ); //$NON-NLS-1$
suffixText = toolkit.createText( client, "" ); //$NON-NLS-1$
suffixText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Synchronisation On Write
synchOnWriteCheckbox = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.SynchronizationOnWrite" ), SWT.CHECK ); //$NON-NLS-1$
synchOnWriteCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
}
/**
* Creates the Context Entry Section.
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createContextEntrySection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
section.setText( "Context Entry" ); //$NON-NLS-1$
section.setDescription( "Set the attribute/value pairs for the Context Entry of the partition." ); //$NON-NLS-1$
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
client.setLayout( new GridLayout( 2, false ) );
section.setClient( client );
// Auto Generate Context Entry Checkbox
autoGenerateContextEntryCheckbox = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.AutoGenerateContextEntryFromSuffixDn" ), //$NON-NLS-1$
SWT.CHECK );
autoGenerateContextEntryCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
// Context Entry Table Viewer
Table contextEntryTable = toolkit.createTable( client, SWT.NONE );
GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
gd.heightHint = 62;
gd.widthHint = 50;
contextEntryTable.setLayoutData( gd );
TableColumn idColumn = new TableColumn( contextEntryTable, SWT.LEFT, 0 );
idColumn.setText( Messages.getString( "PartitionDetailsPage.Attribute" ) ); //$NON-NLS-1$
idColumn.setWidth( 100 );
TableColumn valueColumn = new TableColumn( contextEntryTable, SWT.LEFT, 1 );
valueColumn.setText( Messages.getString( "PartitionDetailsPage.Value" ) ); //$NON-NLS-1$
valueColumn.setWidth( 100 );
contextEntryTable.setHeaderVisible( true );
contextEntryTableViewer = new TableViewer( contextEntryTable );
contextEntryTableViewer.setContentProvider( new IStructuredContentProvider()
{
public Object[] getElements( Object inputElement )
{
List<AttributeValueObject> elements = new ArrayList<>();
Entry entry = ( Entry ) inputElement;
Iterator<Attribute> attributes = entry.iterator();
while ( attributes.hasNext() )
{
Attribute attribute = attributes.next();
Iterator<Value> values = attribute.iterator();
while ( values.hasNext() )
{
Value value = values.next();
elements.add( new AttributeValueObject( attribute.getId(), value.getString() ) );
}
}
return elements.toArray();
}
@Override
public void dispose()
{
}
@Override
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
}
} );
contextEntryTableViewer.setLabelProvider( new ITableLabelProvider()
{
public String getColumnText( Object element, int columnIndex )
{
if ( element != null )
{
switch ( columnIndex )
{
case 0:
return ( ( AttributeValueObject ) element ).getAttribute();
case 1:
return ( ( AttributeValueObject ) element ).getValue();
default:
break;
}
}
return null;
}
public Image getColumnImage( Object element, int columnIndex )
{
return null;
}
public void addListener( ILabelProviderListener listener )
{
}
public void dispose()
{
}
public boolean isLabelProperty( Object element, String property )
{
return false;
}
public void removeListener( ILabelProviderListener listener )
{
}
} );
GridData buttonsGD = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
buttonsGD.widthHint = IDialogConstants.BUTTON_WIDTH;
// Context Entry Add Button
contextEntryAddButton = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.Add" ), SWT.PUSH ); //$NON-NLS-1$
contextEntryAddButton.setLayoutData( buttonsGD );
// Context Entry Edit Button
contextEntryEditButton = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.Edit" ), SWT.PUSH ); //$NON-NLS-1$
contextEntryEditButton.setEnabled( false );
contextEntryEditButton.setLayoutData( buttonsGD );
// Context Entry Delete Button
contextEntryDeleteButton = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.Delete" ), SWT.PUSH ); //$NON-NLS-1$
contextEntryDeleteButton.setEnabled( false );
contextEntryDeleteButton.setLayoutData( buttonsGD );
}
/**
* Updates the context entry widgets enable state.
*/
private void updateContextEntryEnableState()
{
contextEntryTableViewer.getTable().setEnabled( !autoGenerateContextEntryCheckbox.getSelection() );
contextEntryAddButton.setEnabled( !autoGenerateContextEntryCheckbox.getSelection() );
contextEntryEditButton.setEnabled( ( !autoGenerateContextEntryCheckbox.getSelection() )
&& ( !contextEntryTableViewer.getSelection().isEmpty() ) );
contextEntryDeleteButton.setEnabled( ( !autoGenerateContextEntryCheckbox.getSelection() )
&& ( !contextEntryTableViewer.getSelection().isEmpty() ) );
}
/**
* Creates the Partition Specific Settings Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createPartitionSpecificSettingsSection( Composite parent, FormToolkit toolkit )
{
// Creating the Section
specificSettingsSection = toolkit.createSection( parent, Section.TWISTIE | Section.EXPANDED
| Section.TITLE_BAR );
specificSettingsSection.marginWidth = 10;
specificSettingsSection.setText( "Partition Specific Settings" );
specificSettingsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Creating the Composite
specificSettingsSectionComposite = toolkit.createComposite( specificSettingsSection );
toolkit.paintBordersFor( specificSettingsSectionComposite );
GridLayout gd = new GridLayout();
gd.marginHeight = gd.marginWidth = 0;
gd.verticalSpacing = gd.horizontalSpacing = 0;
specificSettingsSectionComposite.setLayout( gd );
specificSettingsSection.setClient( specificSettingsSectionComposite );
}
/**
* Disposes the inner specific settings composite.
*/
private void disposeSpecificSettingsComposite()
{
if ( ( partitionSpecificDetailsComposite != null ) && !( partitionSpecificDetailsComposite.isDisposed() ) )
{
partitionSpecificDetailsComposite.dispose();
}
partitionSpecificDetailsComposite = null;
}
/**
* Updates the partition specific settings section.
*/
private void updatePartitionSpecificSettingsSection()
{
// Disposing existing specific settings composite
disposeSpecificSettingsComposite();
// Create the specific settings block content
if ( partitionSpecificDetailsBlock != null )
{
partitionSpecificDetailsComposite = partitionSpecificDetailsBlock.createBlockContent(
specificSettingsSectionComposite,
toolkit );
partitionSpecificDetailsBlock.refresh();
}
parentComposite.layout( true, true );
// Making the section visible or not
specificSettingsSection.setVisible( partitionSpecificDetailsBlock != null );
}
/**
* Creates the Indexes Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
private void createIndexesSection( Composite parent, FormToolkit toolkit )
{
// Section
Section indexedAttributesSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
indexedAttributesSection.marginWidth = 10;
indexedAttributesSection.setText( Messages.getString( "PartitionDetailsPage.IndexedAttributes" ) ); //$NON-NLS-1$
indexedAttributesSection.setDescription( Messages
.getString( "PartitionDetailsPage.SetIndexedAttributesOfPartition" ) ); //$NON-NLS-1$
indexedAttributesSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite indexedAttributesClient = toolkit.createComposite( indexedAttributesSection );
toolkit.paintBordersFor( indexedAttributesClient );
indexedAttributesClient.setLayout( new GridLayout( 2, false ) );
indexedAttributesSection.setClient( indexedAttributesClient );
// TableViewer
Table indexedAttributesTable = toolkit.createTable( indexedAttributesClient, SWT.NONE );
GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
gd.heightHint = 80;
indexedAttributesTable.setLayoutData( gd );
indexesTableViewer = new TableViewer( indexedAttributesTable );
indexesTableViewer.setContentProvider( new ArrayContentProvider() );
indexesTableViewer.setLabelProvider( new LabelProvider()
{
@Override
public String getText( Object element )
{
if ( element instanceof JdbmIndexBean )
{
JdbmIndexBean jdbmIndexBean = ( JdbmIndexBean ) element;
return NLS.bind( "{0} [{1}]", jdbmIndexBean.getIndexAttributeId(), //$NON-NLS-1$
jdbmIndexBean.getIndexCacheSize() );
}
else if ( element instanceof MavibotIndexBean )
{
MavibotIndexBean mavibotIndexBean = ( MavibotIndexBean ) element;
return mavibotIndexBean.getIndexAttributeId();
}
return super.getText( element );
}
@Override
public Image getImage( Object element )
{
if ( element instanceof IndexBean )
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_INDEX );
}
return super.getImage( element );
}
} );
// Add button
indexesAddButton = toolkit.createButton( indexedAttributesClient,
Messages.getString( "PartitionDetailsPage.Add" ), SWT.PUSH ); //$NON-NLS-1$
indexesAddButton.setLayoutData( createNewButtonGridData() );
// Edit button
indexesEditButton = toolkit.createButton( indexedAttributesClient,
Messages.getString( "PartitionDetailsPage.Edit" ), SWT.PUSH ); //$NON-NLS-1$
indexesEditButton.setEnabled( false );
indexesEditButton.setLayoutData( createNewButtonGridData() );
// Delete button
indexesDeleteButton = toolkit.createButton( indexedAttributesClient,
Messages.getString( "PartitionDetailsPage.Delete" ), SWT.PUSH ); //$NON-NLS-1$
indexesDeleteButton.setEnabled( false );
indexesDeleteButton.setLayoutData( createNewButtonGridData() );
}
/**
* Create a new button grid data.
*
* @return the new button grid data
*/
private GridData createNewButtonGridData()
{
GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
gd.widthHint = IDialogConstants.BUTTON_WIDTH;
return gd;
}
/**
* Adds listeners to UI fields.
*/
private void addListeners()
{
partitionTypeComboViewer.addSelectionChangedListener( partitionTypeComboViewerSelectionChangedListener );
idText.addModifyListener( textModifyListener );
suffixText.addModifyListener( textModifyListener );
suffixText.addModifyListener( suffixTextModifyListener );
synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener );
autoGenerateContextEntryCheckbox.addSelectionListener( autoGenerateContextEntryCheckboxSelectionListener );
contextEntryTableViewer.addDoubleClickListener( contextEntryTableViewerDoubleClickListener );
contextEntryTableViewer.addSelectionChangedListener( contextEntryTableViewerSelectionListener );
contextEntryAddButton.addSelectionListener( contextEntryAddButtonListener );
contextEntryEditButton.addSelectionListener( contextEntryEditButtonListener );
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/AttributeValueObject.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/AttributeValueObject.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
/**
* This class implements an Attribute Value Object that is used in the PartitionDetailsPage.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AttributeValueObject
{
/** The attribute */
private String attribute;
/** The value */
private String value;
/**
* Creates a new instance of AttributeValueObject.
*
* @param attribute
* the attribute
* @param value
* the value
*/
public AttributeValueObject( String attribute, String value )
{
this.attribute = attribute;
this.value = value;
}
/**
* Gets the attribute.
*
* @return
* the attribute.
*/
public String getAttribute()
{
return attribute;
}
/**
* Sets the attribute.
*
* @param attribute
* the new attribute
*/
public void setId( String attribute )
{
this.attribute = attribute;
}
/**
* Gets the value.
*
* @return
* the value
*/
public String getValue()
{
return value;
}
/**
* Sets the value.
*
* @param value
* the new value
*/
public void setValue( String value )
{
this.value = value;
}
/**
* {@inheritDoc}
*/
public String toString()
{
return "Attribute=\"" + attribute + "\", Value=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionSpecificDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionSpecificDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This interface represents a block for Partition Specific Details.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface PartitionSpecificDetailsBlock
{
/**
* Creates the block content.
*
* @param parent the parent composite
* @param toolkit the toolkit
*/
Composite createBlockContent( Composite parent, FormToolkit toolkit );
/**
* Gets the associated details page.
*
* @return the associated details page.
*/
PartitionDetailsPage getDetailsPage();
/**
* Refreshes the UI based on the input.
*/
void refresh();
/**
* If part is displaying information loaded from a model, this method
* instructs it to commit the new (modified) data back into the model.
*
* @param onSave
* indicates if commit is called during 'save' operation or for
* some other reason (for example, if form is contained in a
* wizard or a multi-page editor and the user is about to leave
* the page).
*/
void commit( boolean onSave );
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditorPage.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditorPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.directory.server.config.beans.ConfigBean;
import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.studio.apacheds.configuration.actions.EditorExportConfigurationAction;
import org.apache.directory.studio.apacheds.configuration.actions.EditorImportConfigurationAction;
import org.apache.directory.studio.common.ui.CommonUIConstants;
import org.apache.directory.studio.common.ui.CommonUIPlugin;
import org.apache.directory.studio.connection.core.Connection;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
/**
* This class represents the General Page of the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public abstract class ServerConfigurationEditorPage extends FormPage
{
/** The default LDAP port */
protected static final int DEFAULT_PORT_LDAP = 10389;
/** The default LDAPS port */
protected static final int DEFAULT_PORT_LDAPS = 10636;
/** The default Kerberos port */
protected static final int DEFAULT_PORT_KERBEROS = 60088;
/** The default LDAPS port */
protected static final int DEFAULT_PORT_CHANGE_PASSWORD = 60464;
/** The default IPV4 address for servers */
protected static final String DEFAULT_ADDRESS = "0.0.0.0"; //$NON-NLS-1$
protected static final String TABULATION = " "; //$NON-NLS-1$
/** A flag to indicate if the page is initialized */
protected boolean isInitialized = false;
// Dirty listeners
private ModifyListener dirtyModifyListener = new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
setEditorDirty();
}
};
private SelectionListener dirtySelectionListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
setEditorDirty();
}
};
private ISelectionChangedListener dirtySelectionChangedListener = new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
setEditorDirty();
}
};
/**
* Creates a new instance of GeneralPage.
*
* @param editor the associated editor
* @param id the unique identifier
* @param title The page title
*/
public ServerConfigurationEditorPage( ServerConfigurationEditor editor, String id, String title )
{
super( editor, id, title );
}
/**
* Gets the ServerConfigurationEditor object associated with the page.
*
* @return the ServerConfigurationEditor object associated with the page
*/
public ServerConfigurationEditor getServerConfigurationEditor()
{
return ( ServerConfigurationEditor ) getEditor();
}
/**
* Sets the associated editor dirty.
*/
protected void setEditorDirty()
{
getServerConfigurationEditor().setDirty( true );
}
/**
* Gets the configuration bean associated with the editor.
*
* @return the configuration bean associated with the editor
*/
public ConfigBean getConfigBean()
{
Configuration configuration = getServerConfigurationEditor().getConfiguration();
if ( configuration == null )
{
configuration = new Configuration( new ConfigBean(), null );
getServerConfigurationEditor().setConfiguration( configuration );
}
return configuration.getConfigBean();
}
/**
* Gets the directory service associated with the editor.
*
* @return the directory service bean associated with the editor
*/
public DirectoryServiceBean getDirectoryServiceBean()
{
DirectoryServiceBean directoryServiceBean = getConfigBean().getDirectoryServiceBean();
if ( directoryServiceBean == null )
{
directoryServiceBean = new DirectoryServiceBean();
getConfigBean().addDirectoryService( directoryServiceBean );
}
return directoryServiceBean;
}
/**
* Gets the connection associated with the editor.
*
* @return the connection
*/
public Connection getConnection()
{
IEditorInput editorInput = getEditorInput();
if ( editorInput instanceof ConnectionServerConfigurationInput )
{
return ( ( ConnectionServerConfigurationInput ) editorInput ).getConnection();
}
return null;
}
/**
* {@inheritDoc}
*/
protected void createFormContent( IManagedForm managedForm )
{
ScrolledForm form = managedForm.getForm();
form.setText( getTitle() );
Composite parent = form.getBody();
parent.setLayout( new GridLayout() );
FormToolkit toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading( form.getForm() );
ServerConfigurationEditor editor = ( ServerConfigurationEditor ) getEditor();
IToolBarManager toolbarManager = form.getToolBarManager();
toolbarManager.add( new EditorImportConfigurationAction( editor ) );
toolbarManager.add( new Separator() );
toolbarManager.add( new EditorExportConfigurationAction( editor ) );
toolbarManager.update( true );
createFormContent( parent, toolkit );
isInitialized = true;
}
/**
* Subclasses must implement this method to create the content of their form.
*
* @param parent the parent element
* @param toolkit the form toolkit
*/
protected abstract void createFormContent( Composite parent, FormToolkit toolkit );
/**
* Refreshes the UI.
*/
protected abstract void refreshUI();
/**
* Indicates if the page is initialized.
*
* @return <code>true</code> if the page is initialized,
* <code>false</code> if not.
*/
public boolean isInitialized()
{
return isInitialized;
}
/**
* Creates a Text that can be used to enter a port number.
*
* @param toolkit the toolkit
* @param parent the parent
* @return a Text that can be used to enter a port number
*/
protected Text createPortText( FormToolkit toolkit, Composite parent )
{
Text portText = toolkit.createText( parent, "" ); //$NON-NLS-1$
GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false );
gd.widthHint = 42;
portText.setLayoutData( gd );
portText.addVerifyListener( new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
// Check that it's a valid port. It should be
// any value between 0 and 65535
// Skip spaces on both sides
char[] port = e.text.trim().toCharArray();
if ( port.length > 0 )
{
for ( char c : port )
{
if ( ( c < '0' ) || ( c > '9' ) )
{
// This is an error
e.doit = false;
break;
}
}
}
}
} );
// the port can only have 5 chars max
portText.setTextLimit( 5 );
return portText;
}
/**
* Creates a Text that can be used to enter an address. If the address is incorrect,
* it will be in red while typing until it gets correct.
*
* @param toolkit the toolkit
* @param parent the parent
* @return a Text that can be used to enter an address
*/
protected Text createAddressText( FormToolkit toolkit, Composite parent )
{
final Text addressText = toolkit.createText( parent, "" ); //$NON-NLS-1$
GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false );
gd.widthHint = 200;
addressText.setLayoutData( gd );
addressText.addModifyListener( new ModifyListener()
{
Display display = addressText.getDisplay();
// Check that the address is valid
public void modifyText( ModifyEvent e )
{
Text addressText = (Text)e.widget;
String address = addressText.getText();
try
{
InetAddress.getAllByName( address );
addressText.setForeground( null );
}
catch ( UnknownHostException uhe )
{
addressText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
}
}
} );
// An address can be fairly long...
addressText.setTextLimit( 256 );
return addressText;
}
/**
* Creates a Text that can be used to enter the number of threads
* (which limit is 999)
*
* @param toolkit the toolkit
* @param parent the parent
* @return a Text that can be used to enter the number of threads
*/
protected Text createNbThreadsText( FormToolkit toolkit, Composite parent )
{
Text nbThreadsText = toolkit.createText( parent, "" ); //$NON-NLS-1$
GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false );
gd.widthHint = 42;
nbThreadsText.setLayoutData( gd );
nbThreadsText.addVerifyListener( new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
// Check that it's a valid number of threads. It should be
// any value between 0 and 999
// Skip spaces on both sides
char[] nbThreads = e.text.trim().toCharArray();
if ( nbThreads.length > 0 )
{
for ( char c : nbThreads )
{
if ( ( c < '0' ) || ( c > '9' ) )
{
// This is an error
e.doit = false;
break;
}
}
}
}
} );
// We can't have more than 999 threads
nbThreadsText.setTextLimit( 3 );
return nbThreadsText;
}
/**
* Creates a Text that can be used to enter the backLog size
*
* @param toolkit the toolkit
* @param parent the parent
* @return a Text that can be used to enter the backlog size
*/
protected Text createBackLogSizeText( FormToolkit toolkit, Composite parent )
{
Text backLogSizetText = toolkit.createText( parent, "" ); //$NON-NLS-1$
GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false );
gd.widthHint = 42;
backLogSizetText.setLayoutData( gd );
backLogSizetText.addVerifyListener( new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
// Check that it's a valid size. It should be
// any value between 0 and 99999
// Skip spaces on both sides
char[] backlogSize = e.text.trim().toCharArray();
if ( backlogSize.length > 0 )
{
for ( char c : backlogSize )
{
if ( ( c < '0' ) || ( c > '9' ) )
{
// This is an error
e.doit = false;
break;
}
}
}
}
} );
// the backlog size can only have 5 chars max
backLogSizetText.setTextLimit( 5 );
return backLogSizetText;
}
/**
* Creates default value Label.
*
* @param toolkit the toolkit
* @param parent the parent
* @param text the text string
* @return a default value Label
*/
protected Label createDefaultValueLabel( FormToolkit toolkit, Composite parent, String text )
{
Label label = toolkit.createLabel( parent,
NLS.bind( Messages.getString( "ServerConfigurationEditorPage.DefaultWithValue" ), text ), SWT.WRAP ); //$NON-NLS-1$
label.setForeground( CommonUIPlugin.getDefault().getColor( CommonUIConstants.KEYWORD_1_COLOR ) );
return label;
}
/**
* Set some Label to Bold
*
* @param label the Label we want to see as Bold
* @return a Label with bold text
*/
protected Label setBold( Label label )
{
FontData fontData = label.getFont().getFontData()[0];
Font boldFont = JFaceResources.getFontRegistry().getBold( fontData.getName() );
label.setFont( boldFont );
return label;
}
/**
* Adds a modify listener to the given Text.
*
* @param text the Text control
* @param listener the listener
*/
protected void addModifyListener( Text text, ModifyListener listener )
{
if ( ( text != null ) && ( !text.isDisposed() ) && ( listener != null ) )
{
text.addModifyListener( listener );
}
}
/**
* Adds a selection changed listener to the given Viewer.
*
* @param viewer the viewer control
* @param listener the listener
*/
protected void addSelectionChangedListener( Viewer viewer, ISelectionChangedListener listener )
{
if ( ( viewer != null ) && ( viewer.getControl() != null ) && ( !viewer.getControl().isDisposed() )
&& ( listener != null ) )
{
viewer.addSelectionChangedListener( listener );
}
}
/**
* Adds a double click listener to the given StructuredViewer.
*
* @param viewer the viewer control
* @param listener the listener
*/
protected void addDoubleClickListener( StructuredViewer viewer, IDoubleClickListener listener )
{
if ( ( viewer != null ) && ( viewer.getControl() != null ) && ( !viewer.getControl().isDisposed() )
&& ( listener != null ) )
{
viewer.addDoubleClickListener( listener );
}
}
/**
* Adds a selection listener to the given Button.
*
* @param button the Button control
* @param listener the listener
*/
protected void addSelectionListener( Button button, SelectionListener listener )
{
if ( ( button != null ) && ( !button.isDisposed() ) && ( listener != null ) )
{
button.addSelectionListener( listener );
}
}
/**
* Removes a modify listener to the given Text.
*
* @param text the Text control
* @param listener the listener
*/
protected void removeModifyListener( Text text, ModifyListener listener )
{
if ( ( text != null ) && ( !text.isDisposed() ) && ( listener != null ) )
{
text.removeModifyListener( listener );
}
}
/**
* Removes a selection changed listener to the given Viewer.
*
* @param viewer the viewer control
* @param listener the listener
*/
protected void removeSelectionChangedListener( Viewer viewer, ISelectionChangedListener listener )
{
if ( ( viewer != null ) && ( viewer.getControl() != null ) && ( !viewer.getControl().isDisposed() )
&& ( listener != null ) )
{
viewer.removeSelectionChangedListener( listener );
}
}
/**
* Removes a selection changed listener to the given Viewer.
*
* @param viewer the viewer control
* @param listener the listener
*/
protected void removeDoubleClickListener( StructuredViewer viewer, IDoubleClickListener listener )
{
if ( ( viewer != null ) && ( viewer.getControl() != null ) && ( !viewer.getControl().isDisposed() )
&& ( listener != null ) )
{
viewer.removeDoubleClickListener( listener );
}
}
/**
* Removes a selection listener to the given Button.
*
* @param button the Button control
* @param listener the listener
*/
protected void removeSelectionListener( Button button, SelectionListener listener )
{
if ( ( button != null ) && ( !button.isDisposed() ) && ( listener != null ) )
{
button.removeSelectionListener( listener );
}
}
/**
* Adds a 'dirty' listener to the given Text.
*
* @param text the Text control
*/
protected void addDirtyListener( Text text )
{
addModifyListener( text, dirtyModifyListener );
}
/**
* Adds a 'dirty' listener to the given Button.
*
* @param button the Button control
*/
protected void addDirtyListener( Button button )
{
addSelectionListener( button, dirtySelectionListener );
}
/**
* Adds a 'dirty' listener to the given Viewer.
*
* @param viewer the viewer control
*/
protected void addDirtyListener( Viewer viewer )
{
addSelectionChangedListener( viewer, dirtySelectionChangedListener );
}
/**
* Removes a 'dirty' listener to the given Text.
*
* @param text the Text control
*/
protected void removeDirtyListener( Text text )
{
removeModifyListener( text, dirtyModifyListener );
}
/**
* Removes a 'dirty' listener to the given Button.
*
* @param button the Button control
*/
protected void removeDirtyListener( Button button )
{
removeSelectionListener( button, dirtySelectionListener );
}
/**
* Removes a 'dirty' listener to the given Viewer.
*
* @param viewer the viewer control
*/
protected void removeDirtyListener( Viewer viewer )
{
removeSelectionChangedListener( viewer, dirtySelectionChangedListener );
}
/**
* Sets the selection state of the button widget.
* <p>
* Verifies that the button exists and is not disposed
* before applying the new selection state.
*
* @param button the button
* @param selected the new selection state
*/
protected void setSelection( Button button, boolean selected )
{
if ( ( button != null ) && ( !button.isDisposed() ) )
{
button.setSelection( selected );
}
}
/**
* Sets the selection of the viewer widget.
* <p>
* Verifies that the viewer exists and is not disposed
* before applying the new selection.
*
* @param button the button
* @param selection the new selection
*/
protected void setSelection( Viewer viewer, Object selection )
{
if ( ( viewer != null ) && ( viewer.getControl() != null ) && ( !viewer.getControl().isDisposed() ) )
{
viewer.setSelection( new StructuredSelection( selection ) );
}
}
/**
* Sets the contents of the text widget.
* <p>
* Verifies that the button exists and is not disposed
* before applying the new text.
*
* @param text the text
* @param string the new text
*/
protected void setText( Text text, String string )
{
if ( ( text != null ) && ( !text.isDisposed() ) )
{
if ( string == null )
{
string = ""; //$NON-NLS-1$
}
text.setText( string );
}
}
/**
* Sets the focus to the given control.
*
* @param control the control
*/
protected void setFocus( Control control )
{
if ( ( control != null ) && ( !control.isDisposed() ) )
{
control.setFocus();
}
}
/**
* Sets the enabled state to the given control.
*
* @param control the control
* @param enabled the enabled state
*/
protected void setEnabled( Control control, boolean enabled )
{
if ( ( control != null ) && ( !control.isDisposed() ) )
{
control.setEnabled( enabled );
}
}
/**
* Sets the given {@link GridData} to the control
* and sets the width to a default value.
*
* @param control the control
* @param gd the grid data
*/
protected void setGridDataWithDefaultWidth( Control control, GridData gd )
{
gd.widthHint = 50;
control.setLayoutData( gd );
}
/**
* A shared method used to create a Section, based on a GridLayout.
*
* @param toolkit The Form toolkit
* @param parent The parent
* @param title The Section title
* @param nbColumns The number of columns for the inner grid
*
* @return The created Composite
*/
protected Composite createSection( FormToolkit toolkit, Composite parent, String title, int nbColumns, int style )
{
Section section = toolkit.createSection( parent, style );
section.setText( Messages.getString( title ) );
section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
GridLayout gridLayout = new GridLayout( nbColumns, false );
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout( gridLayout );
section.setClient( composite );
return composite;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationMasterDetailsBlock.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ReplicationMasterDetailsBlock.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import org.apache.directory.api.ldap.model.constants.LdapConstants;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.server.config.beans.ReplConsumerBean;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.forms.DetailsPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.MasterDetailsBlock;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
/**
* This class represents the Replication Master/Details Block used in the Replication Page.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ReplicationMasterDetailsBlock extends MasterDetailsBlock
{
private static final String NEW_ID = "consumer";
/** The associated page */
private ReplicationPage page;
/** The Details Page */
private ReplicationDetailsPage detailsPage;
// UI Fields
private TableViewer viewer;
private Button addButton;
private Button deleteButton;
/**
* Creates a new instance of ReplicationMasterDetailsBlock.
*
* @param page
* the associated page
*/
public ReplicationMasterDetailsBlock( ReplicationPage page )
{
this.page = page;
}
/**
* {@inheritDoc}
*/
public void createContent( IManagedForm managedForm )
{
super.createContent( managedForm );
this.sashForm.setWeights( new int[]
{ 30, 70 } );
}
/**
* {@inheritDoc}
*/
protected void createMasterPart( final IManagedForm managedForm, Composite parent )
{
FormToolkit toolkit = managedForm.getToolkit();
sashForm.setOrientation( SWT.HORIZONTAL );
// Creating the Section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
section.setText( "All Replication Consummers" );
section.marginWidth = 10;
section.marginHeight = 5;
Composite client = toolkit.createComposite( section, SWT.WRAP );
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout( layout );
toolkit.paintBordersFor( client );
section.setClient( client );
// Creating the Table and Table Viewer
Table table = toolkit.createTable( client, SWT.NULL );
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
gd.heightHint = 20;
gd.widthHint = 100;
table.setLayoutData( gd );
final SectionPart spart = new SectionPart( section );
managedForm.addPart( spart );
viewer = new TableViewer( table );
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
managedForm.fireSelectionChanged( spart, event.getSelection() );
}
} );
viewer.setContentProvider( new ArrayContentProvider() );
viewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
if ( element instanceof ReplConsumerBean )
{
ReplConsumerBean consumer = ( ReplConsumerBean ) element;
return consumer.getReplConsumerId();
}
return super.getText( element );
}
public Image getImage( Object element )
{
if ( element instanceof ReplConsumerBean )
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_REPLICATION_CONSUMER );
}
return super.getImage( element );
}
} );
viewer.setComparator( new ViewerComparator()
{
public int compare( Viewer viewer, Object e1, Object e2 )
{
if ( ( e1 instanceof ReplConsumerBean ) && ( e2 instanceof ReplConsumerBean ) )
{
ReplConsumerBean o1 = ( ReplConsumerBean ) e1;
ReplConsumerBean o2 = ( ReplConsumerBean ) e2;
String id1 = o1.getReplConsumerId();
String id2 = o2.getReplConsumerId();
if ( ( id1 != null ) && ( id2 != null ) )
{
return id1.compareTo( id2 );
}
}
return super.compare( viewer, e1, e2 );
}
} );
// Creating the button(s)
addButton = toolkit.createButton( client, "Add", SWT.PUSH );
addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
deleteButton.setEnabled( false );
deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
initFromInput();
addListeners();
}
/**
* Refreshes the UI.
*/
public void refreshUI()
{
initFromInput();
viewer.refresh();
}
/**
* Initializes the page with the Editor input.
*/
private void initFromInput()
{
viewer.setInput( page.getConfigBean().getDirectoryServiceBean().getLdapServerBean().getReplConsumers() );
}
/**
* Add listeners to UI fields.
*/
private void addListeners()
{
viewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
viewer.refresh();
// Getting the selection of the table viewer
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
// Delete button is enabled when something is selected
deleteButton.setEnabled( !selection.isEmpty() );
}
} );
addButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
addNewConsumer();
}
} );
deleteButton.addSelectionListener( new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
deleteSelectedConsumer();
}
} );
}
/**
* This method is called when the 'Add' button is clicked.
*/
private void addNewConsumer()
{
String newId = getNewId();
ReplConsumerBean consumerBean = getNewReplConsumerBean();
consumerBean.setReplConsumerId( newId );
page.getConfigBean().getDirectoryServiceBean().getLdapServerBean().addReplConsumers( consumerBean );
viewer.refresh();
viewer.setSelection( new StructuredSelection( consumerBean ) );
setEditorDirty();
}
/**
* Gets a new ReplConsumerBean.
*
* @return a new ReplConsumerBean
*/
private ReplConsumerBean getNewReplConsumerBean()
{
ReplConsumerBean consumerBean = new ReplConsumerBean();
consumerBean.setEnabled( true );
consumerBean.setReplAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES.getJndiValue() );
consumerBean.setReplProvHostName( "localhost" );
consumerBean.setReplProvPort( 10389 );
consumerBean.setReplSearchFilter( LdapConstants.OBJECT_CLASS_STAR );
consumerBean.setReplSearchScope( SearchScope.SUBTREE.getLdapUrlValue() );
consumerBean.setReplUserDn( "uid=admin,ou=system" );
consumerBean.setReplUserPassword( "secret".getBytes() );
consumerBean.setReplRefreshInterval( 60 * 1000 );
consumerBean.setReplRefreshNPersist( true );
consumerBean.addReplAttributes( SchemaConstants.ALL_USER_ATTRIBUTES );
consumerBean.setSearchBaseDn( "dc=example,dc=com" );
return consumerBean;
}
/**
* Gets a new ID for a new Partition.
*
* @return
* a new ID for a new Partition
*/
private String getNewId()
{
int counter = 1;
String name = NEW_ID;
boolean ok = false;
while ( !ok )
{
ok = true;
name = NEW_ID + counter;
for ( ReplConsumerBean consumer : page.getConfigBean().getDirectoryServiceBean().getLdapServerBean()
.getReplConsumers() )
{
if ( consumer.getReplConsumerId().equalsIgnoreCase( name ) )
{
ok = false;
}
}
counter++;
}
return name;
}
/**
* This method is called when the 'Delete' button is clicked.
*/
private void deleteSelectedConsumer()
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
if ( !selection.isEmpty() )
{
ReplConsumerBean consumer = ( ReplConsumerBean ) selection.getFirstElement();
if ( MessageDialog.openConfirm( page.getManagedForm().getForm().getShell(), "Confirm Delete",
NLS.bind( "Are you sure you want to delete replication consumer ''{0}''?",
consumer.getReplConsumerId() ) ) )
{
page.getConfigBean().getDirectoryServiceBean().getLdapServerBean().getReplConsumers().remove( consumer );
setEditorDirty();
}
}
}
/**
* {@inheritDoc}
*/
protected void registerPages( DetailsPart detailsPart )
{
detailsPage = new ReplicationDetailsPage( this );
detailsPart.registerPage( ReplConsumerBean.class, detailsPage );
}
/**
* {@inheritDoc}
*/
protected void createToolBarActions( IManagedForm managedForm )
{
// TODO Auto-generated method stub
}
/**
* Sets the Editor as dirty.
*/
public void setEditorDirty()
{
( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
viewer.refresh();
}
/**
* Saves the necessary elements to the input model.
*/
public void save()
{
detailsPage.commit( true );
}
/**
* Gets the replication page.
*
* @return the replication
*/
public ReplicationPage getPage()
{
return this.page;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditorUtils.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ServerConfigurationEditorUtils.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.editor;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.csn.CsnFactory;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.util.FileUtils;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.config.ConfigWriter;
import org.apache.directory.server.core.api.DnFactory;
import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
import org.apache.directory.server.core.partition.ldif.AbstractLdifPartition;
import org.apache.directory.server.core.partition.ldif.LdifPartition;
import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.jobs.EntryBasedConfigurationPartition;
import org.apache.directory.studio.apacheds.configuration.jobs.PartitionsDiffComputer;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.apache.directory.studio.common.ui.filesystem.PathEditorInput;
import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.part.FileEditorInput;
/**
* This class contains helpful methods for the Server Configuration Editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ServerConfigurationEditorUtils
{
/**
* Performs the "Save as..." action.
*
* @param monitor the monitor
* @param shell the shell
* @param input the editor input
* @param configWriter the configuration writer
* @param newInput a flag to indicate if a new input is required
* @return the new input for the editor
* @throws Exception
*/
public static IEditorInput saveAs( IProgressMonitor monitor, Shell shell, IEditorInput input,
ConfigWriter configWriter, Configuration configuration, boolean newInput )
throws Exception
{
// detect IDE or RCP:
// check if perspective org.eclipse.ui.resourcePerspective is available
boolean isIDE = CommonUIUtils.isIDEEnvironment();
if ( isIDE )
{
// Asking the user for the location where to 'save as' the file
SaveAsDialog dialog = new SaveAsDialog( shell );
String inputClassName = input.getClass().getName();
if ( input instanceof FileEditorInput )
{
// FileEditorInput class is used when the file is opened
// from a project in the workspace.
dialog.setOriginalFile( ( ( FileEditorInput ) input ).getFile() );
}
else if ( input instanceof IPathEditorInput )
{
dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
.getFile( ( ( IPathEditorInput ) input ).getPath() ) );
}
else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" ) //$NON-NLS-1$
|| inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) ) //$NON-NLS-1$
{
// The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
// is used when opening a file from the menu File > Open... in Eclipse 3.2.x
// The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
// opening a file from the menu File > Open... in Eclipse 3.3.x
dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
.getFile( new Path( input.getToolTipText() ) ) );
}
else
{
dialog.setOriginalName( ApacheDS2ConfigurationPluginConstants.CONFIG_LDIF );
}
// Open the dialog
if ( openDialogInUIThread( dialog ) != Dialog.OK )
{
return null;
}
// Getting if the resulting file
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult() );
// Creating the file if it does not exist
if ( !file.exists() )
{
file.create( new ByteArrayInputStream( "".getBytes() ), true, null ); //$NON-NLS-1$
}
// Creating the new input for the editor
FileEditorInput fei = new FileEditorInput( file );
// Saving the file to disk
File configFile = fei.getPath().toFile();
saveConfiguration( configFile, configWriter, configuration );
return fei;
}
else
{
boolean canOverwrite = false;
String path = null;
while ( !canOverwrite )
{
// Open FileDialog
path = openFileDialogInUIThread( shell );
if ( path == null )
{
return null;
}
// Check whether file exists and if so, confirm overwrite
final File externalFile = new File( path );
if ( externalFile.exists() )
{
String question = NLS.bind(
Messages.getString( "ServerConfigurationEditorUtils.TheFileAlreadyExistsWantToReplace" ), path ); //$NON-NLS-1$
MessageDialog overwriteDialog = new MessageDialog( shell,
Messages.getString( "ServerConfigurationEditorUtils.Question" ), null, question, //$NON-NLS-1$
MessageDialog.QUESTION, new String[]
{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 );
int overwrite = openDialogInUIThread( overwriteDialog );
switch ( overwrite )
{
case 0: // Yes
canOverwrite = true;
break;
case 1: // No
break;
case 2: // Cancel
default:
return null;
}
}
else
{
canOverwrite = true;
}
}
// Saving the file to disk
saveConfiguration( new File(path), configWriter, configuration );
// Checking if a new input is required
if ( newInput )
{
// Creating the new input for the editor
return new PathEditorInput( new Path( path ) );
}
else
{
return null;
}
}
}
/**
* Opens a {@link Dialog} in the UI thread.
*
* @param dialog the dialog
* @return the result of the dialog
*/
private static int openDialogInUIThread( final Dialog dialog )
{
// Defining our own encapsulating class for the result
class DialogResult
{
private int result;
public int getResult()
{
return result;
}
public void setResult( int result )
{
this.result = result;
}
}
// Creating an object to hold the result
final DialogResult result = new DialogResult();
// Opening the dialog in the UI thread
Display.getDefault().syncExec( () -> result.setResult( dialog.open() ) );
return result.getResult();
}
/**
* Opens a {@link FileDialog} in the UI thread.
*
* @param shell the shell
* @return the result of the dialog
*/
private static String openFileDialogInUIThread( final Shell shell )
{
// Defining our own encapsulating class for the result
class DialogResult
{
private String result;
public String getResult()
{
return result;
}
public void setResult( String result )
{
this.result = result;
}
}
// Creating an object to hold the result
final DialogResult result = new DialogResult();
// Opening the dialog in the UI thread
Display.getDefault().syncExec( () ->
{
FileDialog dialog = new FileDialog( shell, SWT.SAVE );
result.setResult( dialog.open() );
} );
return result.getResult();
}
/**
* Saves the configuration.
*
* @param input the connection server configuration input
* @param configWriter the configuration writer
* @param monitor the monitor
* @return <code>true</code> if the operation is successful, <code>false</code> if not
* @throws Exception
*/
public static void saveConfiguration( ConnectionServerConfigurationInput input, ConfigWriter configWriter,
IProgressMonitor monitor ) throws Exception
{
// Getting the original configuration partition
EntryBasedConfigurationPartition originalPartition = input.getOriginalPartition();
// Creating a new configuration partition
SchemaManager schemaManager = ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager();
EntryBasedConfigurationPartition newconfigurationPartition = new EntryBasedConfigurationPartition(
schemaManager );
newconfigurationPartition.initialize();
List<LdifEntry> convertedLdifEntries = configWriter.getConvertedLdifEntries();
for ( LdifEntry ldifEntry : convertedLdifEntries )
{
newconfigurationPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
}
// Suspends event firing in current thread.
ConnectionEventRegistry.suspendEventFiringInCurrentThread();
try
{
// Comparing both partitions to get the list of modifications to be applied
PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer();
partitionsDiffComputer.setOriginalPartition( originalPartition );
partitionsDiffComputer.setDestinationPartition( newconfigurationPartition );
List<LdifEntry> modificationsList = partitionsDiffComputer.computeModifications( new String[]
{ SchemaConstants.ALL_USER_ATTRIBUTES } );
// Building the resulting LDIF
StringBuilder modificationsLdif = new StringBuilder();
for ( LdifEntry ldifEntry : modificationsList )
{
modificationsLdif.append( ldifEntry.toString() );
modificationsLdif.append( '\n' );
}
// Getting the browser connection associated with the connection
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( input.getConnection() );
// Creating a StudioProgressMonitor to run the LDIF with
StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new NullProgressMonitor() );
// Updating the configuration with the resulting LDIF
ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(), true, true,
studioProgressMonitor );
// Checking if there were errors during the execution of the LDIF
if ( studioProgressMonitor.errorsReported() )
{
throw new Exception(
Messages.getString( "ServerConfigurationEditorUtils.ChangesCouldNotBeSavedToConnection" ) ); //$NON-NLS-1$
}
else
{
// Swapping the new configuration partition
input.setOriginalPartition( newconfigurationPartition );
}
}
finally
{
// Resumes event firing in current thread.
ConnectionEventRegistry.resumeEventFiringInCurrentThread();
}
}
/**
* Saves the configuration.
*
* @param file the file
* @param configWriter the configuration writer
* @throws Exception
*/
public static void saveConfiguration( File file, ConfigWriter configWriter, Configuration configuration )
throws Exception
{
SchemaManager schemaManager = ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager();
DnFactory dnFactory = null;
CsnFactory csnFactory = new CsnFactory( 0 );
if ( file != null )
{
// create partiton
AbstractLdifPartition configPartition;
if ( file.getName().equals( ApacheDS2ConfigurationPluginConstants.OU_CONFIG_LDIF ) )
{
File confDir = file.getParentFile();
File ouConfigLdifFile = new File( confDir, ApacheDS2ConfigurationPluginConstants.OU_CONFIG_LDIF );
File ouConfigDir = new File( confDir, ApacheDS2ConfigurationPluginConstants.OU_CONFIG );
if ( ouConfigLdifFile.exists() && ouConfigDir.exists() )
{
ouConfigLdifFile.delete();
FileUtils.deleteDirectory( ouConfigDir );
}
configPartition = createMultiFileConfiguration( confDir, schemaManager, dnFactory );
}
else
{
if ( file.exists() )
{
file.delete();
}
configPartition = createSingleFileConfiguration( file, schemaManager, dnFactory );
}
// write entries to partition
List<LdifEntry> convertedLdifEntries = configWriter.getConvertedLdifEntries();
for ( LdifEntry ldifEntry : convertedLdifEntries )
{
Entry entry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
if ( entry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
{
entry.add( SchemaConstants.ENTRY_CSN_AT, csnFactory.newInstance().toString() );
}
if ( entry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
{
String uuid = UUID.randomUUID().toString();
entry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
}
configPartition.add( new AddOperationContext( null, entry ) );
}
}
}
private static SingleFileLdifPartition createSingleFileConfiguration( File configFile, SchemaManager schemaManager,
DnFactory dnFactory) throws Exception
{
SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager, dnFactory );
configPartition.setId( "config" );
configPartition.setPartitionPath( configFile.toURI() );
configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
configPartition.setSchemaManager( schemaManager );
configPartition.initialize();
return configPartition;
}
private static LdifPartition createMultiFileConfiguration( File confDir, SchemaManager schemaManager,
DnFactory dnFactory ) throws Exception
{
LdifPartition configPartition = new LdifPartition( schemaManager, dnFactory );
configPartition.setId( "config" );
configPartition.setPartitionPath( confDir.toURI() );
configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
configPartition.setSchemaManager( schemaManager );
configPartition.initialize();
return configPartition;
}
// TODO: something link this should be used in future to only write changes to partition
private static List<LdifEntry> computeModifications( ConfigWriter configWriter,
AbstractBTreePartition originalPartition ) throws Exception
{
// Creating a new configuration partition
SchemaManager schemaManager = ApacheDS2ConfigurationPlugin.getDefault().getSchemaManager();
EntryBasedConfigurationPartition newconfigurationPartition = new EntryBasedConfigurationPartition(
schemaManager );
newconfigurationPartition.initialize();
List<LdifEntry> convertedLdifEntries = configWriter.getConvertedLdifEntries();
for ( LdifEntry ldifEntry : convertedLdifEntries )
{
newconfigurationPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
}
// Comparing both partitions to get the list of modifications to be applied
PartitionsDiffComputer partitionsDiffComputer = new PartitionsDiffComputer();
partitionsDiffComputer.setOriginalPartition( originalPartition );
partitionsDiffComputer.setDestinationPartition( newconfigurationPartition );
return partitionsDiffComputer.computeModifications( new String[]
{ SchemaConstants.ALL_USER_ATTRIBUTES } );
}
/**
* Checks if the string is <code>null</code>
* and returns an empty string in that case.
*
* @param s the string
* @return a non-<code>null</code> string
*/
public static String checkNull( String s )
{
if ( s == null )
{
return "";
}
return s;
}
/**
* Checks if the string is <code>null</code>
* and returns an empty string in that case.
*
* @param s the string
* @return a non-<code>null</code> string
*/
public static String checkEmptyString( String s )
{
if ( Strings.isEmpty( s ) )
{
return null;
}
return s;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/EditorImportConfigurationAction.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/EditorImportConfigurationAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.actions;
import java.io.File;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.editor.Configuration;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.apache.directory.studio.apacheds.configuration.jobs.LoadConfigurationRunnable;
import org.apache.directory.studio.common.ui.CommonUIUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* This class implements the create connection action for an ApacheDS 2.0 server.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EditorImportConfigurationAction extends Action
{
private static final String DIALOG_TITLE = Messages
.getString( "EditorImportConfigurationAction.SelectConfigurationFile" ); //$NON-NLS-1$
/** The associated editor */
private ServerConfigurationEditor editor;
/**
* Creates a new instance of EditorImportConfigurationAction.
*
* @param editor the associated editor
*/
public EditorImportConfigurationAction( ServerConfigurationEditor editor )
{
this.editor = editor;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return ApacheDS2ConfigurationPlugin.getDefault().getImageDescriptor(
ApacheDS2ConfigurationPluginConstants.IMG_IMPORT );
}
/**
* {@inheritDoc}
*/
public String getText()
{
return Messages.getString( "EditorImportConfigurationAction.ImportConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public void run()
{
try
{
// Checking if the editor has unsaved modifications
if ( editor.isDirty() )
{
// Requiring a confirmation from the user before discarding the unsaved modifications
if ( !MessageDialog
.openConfirm(
editor.getSite().getShell(),
Messages.getString( "EditorImportConfigurationAction.UnsavedModifications" ), //$NON-NLS-1$
Messages
.getString( "EditorImportConfigurationAction.ConfigurationHasUnsavedModificationsSureToContinue" ) ) ) //$NON-NLS-1$
{
return;
}
}
// The file that will be used to load the configuration
File file = null;
// detect IDE or RCP:
boolean isIDE = CommonUIUtils.isIDEEnvironment();
if ( isIDE )
{
// Opening a dialog for file selection
ElementTreeSelectionDialog dialog = createWorkspaceFileSelectionDialog();
if ( dialog.open() == Dialog.OK )
{
// Getting the input stream for the selected file
Object firstResult = dialog.getFirstResult();
if ( firstResult instanceof IFile )
{
file = ( ( IFile ) firstResult ).getLocation().toFile();
}
}
else
{
// Cancel button has been clicked
return;
}
}
else
{
// Opening a dialog for file selection
FileDialog dialog = new FileDialog( editor.getSite().getShell(), SWT.OPEN | SWT.SINGLE );
dialog.setText( DIALOG_TITLE );
dialog.setFilterPath( System.getProperty( "user.home" ) ); //$NON-NLS-1$
String filePath = dialog.open();
if ( filePath == null )
{
// Cancel button has been clicked
return;
}
// Checking the file
file = new File( filePath );
if ( !file.exists() || !file.isFile() || !file.canRead() )
{
// This is not a valid file
return;
}
}
// Checking if we found an input stream
if ( file == null )
{
return;
}
// Requiring a confirmation from the user
if ( !MessageDialog
.openConfirm(
editor.getSite().getShell(),
Messages.getString( "EditorImportConfigurationAction.OverwriteExistingConfiguration" ), //$NON-NLS-1$
Messages
.getString( "EditorImportConfigurationAction.AreYouSureYouWantToOverwriteTheExistingConfiguration" ) ) ) //$NON-NLS-1$
{
return;
}
// Reading the configuration of the file
Configuration configuration = LoadConfigurationRunnable.readConfiguration( file );
// Resetting the configuration back to the editor
editor.resetConfiguration( configuration );
}
catch ( Exception e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
e.getMessage() ) );
MessageDialog
.openError(
editor.getSite().getShell(),
Messages.getString( "EditorImportConfigurationAction.ErrorImportingConfigurationFile" ), //$NON-NLS-1$
NLS.bind(
Messages
.getString( "EditorImportConfigurationAction.AnErrorOccurredWhenImportingTheSelectedFile" ), //$NON-NLS-1$
e.getMessage() ) );
}
}
/**
* Creates a {@link Dialog} to select a single file in the workspace.
*
* @return a {@link Dialog} to select a single file in the workspace
*/
private ElementTreeSelectionDialog createWorkspaceFileSelectionDialog()
{
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( editor.getSite().getShell(),
new WorkbenchLabelProvider(), new WorkbenchContentProvider() );
dialog.setInput( ResourcesPlugin.getWorkspace().getRoot() );
dialog.setMessage( Messages.getString( "EditorImportConfigurationAction.SelectConfigurationFileToImport" ) ); //$NON-NLS-1$
dialog.setTitle( DIALOG_TITLE );
dialog.setAllowMultiple( false );
dialog.setStatusLineAboveButtons( false );
dialog.setValidator( new ISelectionStatusValidator()
{
/** The validated status */
private Status validated = new Status( IStatus.OK, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
IStatus.OK, "", null ); //$NON-NLS-1$
/** The not validated status */
private Status notValidated = new Status( IStatus.ERROR, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
IStatus.ERROR, "", null ); //$NON-NLS-1$
public IStatus validate( Object[] selection )
{
if ( selection != null )
{
if ( selection.length > 0 )
{
Object selectedObject = selection[0];
if ( selectedObject instanceof IFile )
{
return validated;
}
}
}
return notValidated;
}
} );
return dialog;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/Messages.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.actions;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/OpenConfigurationAction.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/OpenConfigurationAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.actions;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.editor.ConnectionServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.apache.directory.studio.connection.core.Connection;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* This class implements the action which opens the configuration.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenConfigurationAction implements IObjectActionDelegate
{
/** The selected connection */
private Connection selectedConnection;
/**
* {@inheritDoc}
*/
public void run( IAction action )
{
if ( selectedConnection != null )
{
try
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try
{
page.openEditor( new ConnectionServerConfigurationInput( selectedConnection ),
ServerConfigurationEditor.ID );
}
catch ( PartInitException e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
e.getMessage() ) );
}
}
catch ( Exception e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
e.getMessage() ) );
}
}
}
/**
* {@inheritDoc}
*/
public void selectionChanged( IAction action, ISelection selection )
{
StructuredSelection structuredSelection = ( StructuredSelection ) selection;
if ( ( structuredSelection.size() == 1 ) && ( structuredSelection.getFirstElement() instanceof Connection ) )
{
selectedConnection = ( Connection ) structuredSelection.getFirstElement();
}
else
{
selectedConnection = null;
}
}
/**
* {@inheritDoc}
*/
public void setActivePart( IAction action, IWorkbenchPart targetPart )
{
// Nothing to do
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/EditorExportConfigurationAction.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/actions/EditorExportConfigurationAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.actions;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditorUtils;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
/**
* This class implements the create connection action for an ApacheDS 2.0 server.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EditorExportConfigurationAction extends Action
{
/** The associated editor */
private ServerConfigurationEditor editor;
/**
* Creates a new instance of EditorExportConfigurationAction.
*
* @param editor
* the associated editor
*/
public EditorExportConfigurationAction( ServerConfigurationEditor editor )
{
this.editor = editor;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return ApacheDS2ConfigurationPlugin.getDefault().getImageDescriptor(
ApacheDS2ConfigurationPluginConstants.IMG_EXPORT );
}
/**
* {@inheritDoc}
*/
public String getText()
{
return Messages.getString( "EditorExportConfigurationAction.ExportConfiguration" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public void run()
{
try
{
ServerConfigurationEditorUtils.saveAs( new NullProgressMonitor(), editor.getSite()
.getShell(), editor.getEditorInput(), editor.getConfigWriter(), editor.getConfiguration(), false );
}
catch ( Exception e )
{
ApacheDS2ConfigurationPlugin.getDefault().getLog().log(
new Status( Status.ERROR, "org.apache.directory.studio.apacheds.configuration",
e.getMessage() ) );
MessageDialog
.openError( editor.getSite().getShell(),
Messages.getString( "EditorExportConfigurationAction.ErrorExportingConfigurationFile" ), //$NON-NLS-1$
NLS.bind(
Messages
.getString( "EditorExportConfigurationAction.AnErrorOccurredWhenExportingTheSelectedFile" ), e.getMessage() ) ); //$NON-NLS-1$
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/Messages.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.dialogs;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/AttributeValueDialog.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/AttributeValueDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.dialogs;
import org.apache.directory.studio.apacheds.configuration.editor.AttributeValueObject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
/**
* This class implements the Dialog for Attribute Value.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AttributeValueDialog extends Dialog
{
/** The Attribute Value Object */
private AttributeValueObject attributeValueObject;
/** The dirty flag */
private boolean dirty = false;
// UI Fields
private Text attributeText;
private Text valueText;
/**
* Creates a new instance of AttributeValueDialog.
*/
public AttributeValueDialog( AttributeValueObject attributeValueObject )
{
super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
this.attributeValueObject = attributeValueObject;
}
/**
* {@inheritDoc}
*/
protected void configureShell( Shell newShell )
{
super.configureShell( newShell );
newShell.setText( Messages.getString( "AttributeValueDialog.AttributeValueDialog" ) ); //$NON-NLS-1$
}
/**
* This create a dialog like :
*
* <pre>
* +------------------------------------------------+
* | Attribute: [ ] Value: [ ] |
* +------------------------------------------------+
* </pre>
* {@inheritDoc}
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( 2, false );
composite.setLayout( layout );
composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
Label attributeLabel = new Label( composite, SWT.NONE );
attributeLabel.setText( Messages.getString( "AttributeValueDialog.Attribute" ) ); //$NON-NLS-1$
attributeText = new Text( composite, SWT.BORDER );
attributeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Label valueLabel = new Label( composite, SWT.NONE );
valueLabel.setText( Messages.getString( "AttributeValueDialog.Value" ) ); //$NON-NLS-1$
valueText = new Text( composite, SWT.BORDER );
valueText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
initFromInput();
addListeners();
return composite;
}
/**
* Initializes the UI from the input.
*/
private void initFromInput()
{
String attribute = attributeValueObject.getAttribute();
attributeText.setText( ( attribute == null ) ? "" : attribute ); //$NON-NLS-1$
Object value = attributeValueObject.getValue();
valueText.setText( ( value == null ) ? "" : value.toString() ); //$NON-NLS-1$
}
/**
* Adds listeners to the UI Fields.
*/
private void addListeners()
{
attributeText.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
dirty = true;
}
} );
valueText.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
dirty = true;
}
} );
}
/**
* {@inheritDoc}
*/
protected void okPressed()
{
attributeValueObject.setId( attributeText.getText() );
attributeValueObject.setValue( valueText.getText() );
super.okPressed();
}
/**
* Gets the Attribute Value Object.
*
* @return the Attribute Value Object
*/
public AttributeValueObject getAttributeValueObject()
{
return attributeValueObject;
}
/**
* Returns the dirty flag of the dialog.
*
* @return the dirty flag of the dialog
*/
public boolean isDirty()
{
return dirty;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/MavibotIndexDialog.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/MavibotIndexDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.dialogs;
import org.apache.directory.server.config.beans.MavibotIndexBean;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
/**
* This class implements the Dialog for a Mavibot index.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class MavibotIndexDialog extends Dialog
{
/** The Indexed Attribute */
private MavibotIndexBean index;
/** The dirty flag */
private boolean dirty = false;
// UI Fields
private Text attributeIdText;
/**
* Creates a new instance of MavibotIndexDialog.
*/
public MavibotIndexDialog( MavibotIndexBean index )
{
super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
this.index = index;
}
/**
* {@inheritDoc}
*/
protected void configureShell( Shell newShell )
{
super.configureShell( newShell );
newShell.setText( Messages.getString( "MavibotIndexDialog.IndexedAttributeDialog" ) ); //$NON-NLS-1$
}
/**
* This create a dialog like :
*
* <pre>
* +------------------------------+
* | Attribute ID: [ ] |
* +------------------------------+
* </pre>
* {@inheritDoc}
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( 2, false );
composite.setLayout( layout );
composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
Label attributeIdLabel = new Label( composite, SWT.NONE );
attributeIdLabel.setText( Messages.getString( "MavibotIndexDialog.AttributeID" ) ); //$NON-NLS-1$
attributeIdText = new Text( composite, SWT.BORDER );
attributeIdText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
initFromInput();
addListeners();
return composite;
}
/**
* Initializes the UI from the input.
*/
private void initFromInput()
{
String attributeId = index.getIndexAttributeId();
attributeIdText.setText( ( attributeId == null ) ? "" : attributeId ); //$NON-NLS-1$
}
/**
* Adds listeners to the UI Fields.
*/
private void addListeners()
{
attributeIdText.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
dirty = true;
}
} );
}
/**
* {@inheritDoc}
*/
protected void okPressed()
{
index.setIndexAttributeId( attributeIdText.getText() );
super.okPressed();
}
/**
* Gets the Indexed Attribute.
*
* @return the Indexed Attribute
*/
public MavibotIndexBean getIndex()
{
return index;
}
/**
* Returns the dirty flag of the dialog.
*
* @return
* the dirty flag of the dialog
*/
public boolean isDirty()
{
return dirty;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/JdbmIndexDialog.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/dialogs/JdbmIndexDialog.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.dialogs;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
/**
* This class implements the Dialog for a JDBM index.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class JdbmIndexDialog extends Dialog
{
/** The Indexed Attribute */
private JdbmIndexBean index;
/** The dirty flag */
private boolean dirty = false;
// UI Fields
private Text attributeIdText;
private Text cacheSizeText;
/**
* Creates a new instance of JdbmIndexDialog.
*/
public JdbmIndexDialog( JdbmIndexBean index )
{
super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
this.index = index;
}
/**
* {@inheritDoc}
*/
protected void configureShell( Shell newShell )
{
super.configureShell( newShell );
newShell.setText( Messages.getString( "JdbmIndexDialog.IndexedAttributeDialog" ) ); //$NON-NLS-1$
}
/**
* This create a dialog like :
*
* <pre>
* +-----------------------------------------------------+
* | Attribute ID: [ ] Cache Size: [ ] |
* +-----------------------------------------------------+
* </pre>
* {@inheritDoc}
*/
protected Control createDialogArea( Composite parent )
{
Composite composite = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout( 2, false );
composite.setLayout( layout );
composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
Label attributeIdLabel = new Label( composite, SWT.NONE );
attributeIdLabel.setText( Messages.getString( "JdbmIndexDialog.AttributeID" ) ); //$NON-NLS-1$
attributeIdText = new Text( composite, SWT.BORDER );
attributeIdText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Label cacheSizeLabel = new Label( composite, SWT.NONE );
cacheSizeLabel.setText( Messages.getString( "JdbmIndexDialog.CacheSize" ) ); //$NON-NLS-1$
cacheSizeText = new Text( composite, SWT.BORDER );
cacheSizeText.addVerifyListener( new VerifyListener()
{
public void verifyText( VerifyEvent e )
{
// The cache size must be a numeric
if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
e.doit = false;
}
}
} );
cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
initFromInput();
addListeners();
return composite;
}
/**
* Initializes the UI from the input.
*/
private void initFromInput()
{
String attributeId = index.getIndexAttributeId();
attributeIdText.setText( ( attributeId == null ) ? "" : attributeId ); //$NON-NLS-1$
cacheSizeText.setText( "" + index.getIndexCacheSize() ); //$NON-NLS-1$
}
/**
* Adds listeners to the UI Fields.
*/
private void addListeners()
{
attributeIdText.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
dirty = true;
}
} );
cacheSizeText.addModifyListener( new ModifyListener()
{
public void modifyText( ModifyEvent e )
{
dirty = true;
}
} );
}
/**
* {@inheritDoc}
*/
protected void okPressed()
{
index.setIndexAttributeId( attributeIdText.getText() );
try
{
index.setIndexCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
}
catch ( NumberFormatException e )
{
// Nothing to do, it won't happen
}
super.okPressed();
}
/**
* Gets the Indexed Attribute.
*
* @return the Indexed Attribute
*/
public JdbmIndexBean getIndex()
{
return index;
}
/**
* Returns the dirty flag of the dialog.
*
* @return the dirty flag of the dialog
*/
public boolean isDirty()
{
return dirty;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java | plugins/apacheds.configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/wizards/NewApacheDSConfigurationFileWizard.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.apacheds.configuration.wizards;
import org.apache.directory.studio.apacheds.configuration.editor.NewServerConfigurationInput;
import org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* This class implements the New ApacheDS Configuration File Wizard.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class NewApacheDSConfigurationFileWizard extends Wizard implements INewWizard
{
/**
* {@inheritDoc}
*/
public void addPages()
{
// This wizard has no page
}
/**
* {@inheritDoc}
*/
public boolean performFinish()
{
try
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor( new NewServerConfigurationInput(), ServerConfigurationEditor.ID );
}
catch ( PartInitException e )
{
// Should never happen
return false;
}
return true;
}
/**
* {@inheritDoc}
*/
public void init( IWorkbench workbench, IStructuredSelection selection )
{
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/MultiTabEntryEditorMatchingStrategy.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/MultiTabEntryEditorMatchingStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorMatchingStrategy;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.PartInitException;
/**
* Matching strategy for a multi tab entry editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class MultiTabEntryEditorMatchingStrategy implements IEditorMatchingStrategy
{
/**
* Returns true if the given editor is multi-tab and the input resolved entries
* are equal.
*/
public boolean matches( IEditorReference editorRef, IEditorInput input )
{
if ( !( input instanceof EntryEditorInput ) )
{
return false;
}
EntryEditorInput entryEditorInput = ( EntryEditorInput ) input;
if ( entryEditorInput.getExtension() == null )
{
return false;
}
if ( !entryEditorInput.getExtension().isMultiWindow() )
{
return false;
}
if ( !editorRef.getId().equals( entryEditorInput.getExtension().getEditorId() ) )
{
return false;
}
try
{
IEditorInput otherInput = editorRef.getEditorInput();
if ( !( otherInput instanceof EntryEditorInput ) )
{
return false;
}
EntryEditorInput otherEntryEditorInput = ( EntryEditorInput ) otherInput;
if ( entryEditorInput.getResolvedEntry() == null && otherEntryEditorInput.getResolvedEntry() == null )
{
return true;
}
return entryEditorInput.getResolvedEntry() != null && otherEntryEditorInput.getResolvedEntry() != null
&& entryEditorInput.getResolvedEntry().equals( otherEntryEditorInput.getResolvedEntry() );
}
catch ( PartInitException e )
{
return false;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
import org.apache.directory.studio.connection.core.event.ConnectionUpdateAdapter;
import org.apache.directory.studio.connection.core.event.ConnectionUpdateListener;
import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
import org.apache.directory.studio.connection.ui.RunnableContextRunner;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener;
import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
import org.apache.directory.studio.ldapbrowser.core.events.ValueAddedEvent;
import org.apache.directory.studio.ldapbrowser.core.events.ValueDeletedEvent;
import org.apache.directory.studio.ldapbrowser.core.events.ValueModifiedEvent;
import org.apache.directory.studio.ldapbrowser.core.events.ValueMultiModificationEvent;
import org.apache.directory.studio.ldapbrowser.core.events.ValueRenamedEvent;
import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
import org.apache.directory.studio.ldapbrowser.core.model.IValue;
import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.apache.directory.studio.ldifparser.LdifFormatParameters;
import org.apache.directory.studio.ldifparser.model.LdifFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* A EntryEditorManager is used to manage entry editors. It provides methods to get
* the best or alternative entry editors for a given entry.
*
* The available value editors are specified by the extension point
* <code>org.apache.directory.studio.entryeditors</code>.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EntryEditorManager
{
private static final String ID_ATTR = "id"; //$NON-NLS-1$
private static final String NAME_ATTR = "name"; //$NON-NLS-1$
private static final String DESCRIPTION_ATTR = "description"; //$NON-NLS-1$
private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
private static final String CLASS_ATTR = "class"; //$NON-NLS-1$
private static final String EDITOR_ID_ATTR = "editorId"; //$NON-NLS-1$
private static final String MULTI_WINDOW_ATTR = "multiWindow"; //$NON-NLS-1$
private static final String PRIORITY_ATTR = "priority"; //$NON-NLS-1$
/** The priorities separator */
public static final String PRIORITIES_SEPARATOR = ","; //$NON-NLS-1$
/** The list of entry editors */
private Map<String, EntryEditorExtension> entryEditorExtensions = new HashMap<>();
/** The shared reference copies for open-save-close editors; original entry -> reference copy */
private Map<IEntry, IEntry> oscSharedReferenceCopies = new HashMap<>();
/** The shared working copies for open-save-close editors; original entry -> working copy */
private Map<IEntry, IEntry> oscSharedWorkingCopies = new HashMap<>();
/** The shared reference copies for auto-save editors; original entry -> reference copy */
private Map<IEntry, IEntry> autoSaveSharedReferenceCopies = new HashMap<>();
/** The shared working copies for auto-save editors; original entry -> working copy */
private Map<IEntry, IEntry> autoSaveSharedWorkingCopies = new HashMap<>();
/** The comparator for entry editors */
private Comparator<EntryEditorExtension> entryEditorComparator = new Comparator<EntryEditorExtension>()
{
@Override
public int compare( EntryEditorExtension o1, EntryEditorExtension o2 )
{
if ( o1 == null )
{
return ( o2 == null ) ? 0 : -1;
}
if ( o2 == null )
{
return 1;
}
// Getting priorities
int o1Priority = o1.getPriority();
int o2Priority = o2.getPriority();
if ( o1Priority != o2Priority )
{
return ( o1Priority > o2Priority ) ? -1 : 1;
}
// Getting names
String o1Name = o1.getName();
String o2Name = o2.getName();
if ( o1Name == null )
{
return ( o2Name == null ) ? 0 : -1;
}
return o1Name.compareTo( o2Name );
}
};
/** The listener for workbench part update */
private IPartListener2 partListener = new IPartListener2()
{
@Override
public void partActivated( IWorkbenchPartReference partRef )
{
cleanupCopies( partRef.getPage() );
IEntryEditor editor = getEntryEditor( partRef );
if ( editor != null )
{
EntryEditorInput eei = editor.getEntryEditorInput();
IEntry originalEntry = eei.getResolvedEntry();
IEntry oscSharedReferenceCopy = oscSharedReferenceCopies.get( originalEntry );
IEntry oscSharedWorkingCopy = oscSharedWorkingCopies.get( originalEntry );
if ( editor.isAutoSave() )
{
// check if the same entry is used in an OSC editor and is dirty -> should save first?
if ( oscSharedReferenceCopy != null && oscSharedWorkingCopy != null )
{
LdifFile diff = Utils.computeDiff( oscSharedReferenceCopy, oscSharedWorkingCopy );
if ( diff != null )
{
MessageDialog dialog = new MessageDialog( partRef.getPart( false ).getSite().getShell(),
Messages.getString( "EntryEditorManager.SaveChanges" ), null,//$NON-NLS-1$
Messages.getString( "EntryEditorManager.SaveChangesDescription" ), //$NON-NLS-1$
MessageDialog.QUESTION, new String[]
{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0 );
int result = dialog.open();
if ( result == 0 )
{
saveSharedWorkingCopy( originalEntry, true, null );
}
}
}
}
else
{
// check if original entry was updated
if ( ( oscSharedReferenceCopy != null ) && ( oscSharedWorkingCopy != null ) )
{
LdifFile refDiff = Utils.computeDiff( originalEntry, oscSharedReferenceCopy );
if ( refDiff != null )
{
// check if we could just update the working copy
LdifFile workDiff = Utils.computeDiff( oscSharedReferenceCopy, oscSharedWorkingCopy );
if ( workDiff != null )
{
askUpdateSharedWorkingCopy( partRef, originalEntry, oscSharedWorkingCopy, null );
}
}
}
}
}
}
@Override
public void partOpened( IWorkbenchPartReference partRef )
{
}
@Override
public void partClosed( IWorkbenchPartReference partRef )
{
cleanupCopies( partRef.getPage() );
}
@Override
public void partInputChanged( IWorkbenchPartReference partRef )
{
cleanupCopies( partRef.getPage() );
}
@Override
public void partHidden( IWorkbenchPartReference partRef )
{
}
@Override
public void partDeactivated( IWorkbenchPartReference partRef )
{
}
@Override
public void partBroughtToTop( IWorkbenchPartReference partRef )
{
}
@Override
public void partVisible( IWorkbenchPartReference partRef )
{
}
};
/** The listener for entry update */
private EntryUpdateListener entryUpdateListener = new EntryUpdateListener()
{
@Override
public void entryUpdated( EntryModificationEvent event )
{
IEntry modifiedEntry = event.getModifiedEntry();
IBrowserConnection browserConnection = modifiedEntry.getBrowserConnection();
IEntry originalEntry = browserConnection.getEntryFromCache( modifiedEntry.getDn() );
if ( modifiedEntry == originalEntry )
{
// an original entry has been modified, check if we could update the editors
// if the OSC editor is not dirty we could update the working copy
IEntry oscSharedReferenceCopy = oscSharedReferenceCopies.get( originalEntry );
IEntry oscSharedWorkingCopy = oscSharedWorkingCopies.get( originalEntry );
if ( ( oscSharedReferenceCopy != null ) && ( oscSharedWorkingCopy != null ) )
{
LdifFile refDiff = Utils.computeDiff( originalEntry, oscSharedReferenceCopy );
if ( refDiff != null )
{
// diff between original entry and reference copy
LdifFile workDiff = Utils.computeDiff( oscSharedReferenceCopy, oscSharedWorkingCopy );
if ( workDiff == null )
{
// no changes on working copy, update
updateOscSharedReferenceCopy( originalEntry );
updateOscSharedWorkingCopy( originalEntry );
// inform all OSC editors
List<IEntryEditor> oscEditors = getOscEditors( oscSharedWorkingCopy );
for ( IEntryEditor editor : oscEditors )
{
editor.workingCopyModified( event.getSource() );
}
}
else
{
// changes on working copy, ask before update
IWorkbenchPartReference reference = getActivePartRef( getOscEditors( oscSharedWorkingCopy ) );
if ( reference != null )
{
askUpdateSharedWorkingCopy( reference, originalEntry, oscSharedWorkingCopy, event
.getSource() );
}
}
}
else
{
// no diff betweeen original entry and reference copy, check if editor is dirty
LdifFile workDiff = Utils.computeDiff( oscSharedReferenceCopy, oscSharedWorkingCopy );
if ( workDiff != null )
{
// changes on working copy, ask before update
IWorkbenchPartReference reference = getActivePartRef( getOscEditors( oscSharedWorkingCopy ) );
if ( reference != null )
{
askUpdateSharedWorkingCopy( reference, originalEntry, oscSharedWorkingCopy, event
.getSource() );
}
}
}
}
// always update auto-save working copies, if necessary
IEntry autoSaveSharedReferenceCopy = autoSaveSharedReferenceCopies.get( originalEntry );
IEntry autoSaveSharedWorkingCopy = autoSaveSharedWorkingCopies.get( originalEntry );
if ( ( autoSaveSharedReferenceCopy != null ) && ( autoSaveSharedWorkingCopy != null ) )
{
LdifFile diff = Utils.computeDiff( originalEntry, autoSaveSharedReferenceCopy );
if ( diff != null )
{
updateAutoSaveSharedReferenceCopy( originalEntry );
updateAutoSaveSharedWorkingCopy( originalEntry );
List<IEntryEditor> editors = getAutoSaveEditors( autoSaveSharedWorkingCopy );
for ( IEntryEditor editor : editors )
{
editor.workingCopyModified( event.getSource() );
}
}
}
// check all editors: if the input does not exist any more then close the editor
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
// Collecting editor references to close
List<IEditorReference> editorReferences = new ArrayList<>();
for ( IEditorReference ref : activePage.getEditorReferences() )
{
IEntryEditor editor = getEntryEditor( ref );
if ( editor != null )
{
EntryEditorInput entryEditorInput = editor.getEntryEditorInput();
if ( entryEditorInput != null )
{
IEntry resolvedEntry = entryEditorInput.getResolvedEntry();
if ( ( editor != null ) && ( resolvedEntry != null ) )
{
IBrowserConnection bc = resolvedEntry.getBrowserConnection();
Dn dn = resolvedEntry.getDn();
if ( bc.getEntryFromCache( dn ) == null )
{
editorReferences.add( ref );
}
}
}
}
}
// Closing the corresponding editor references
if ( !editorReferences.isEmpty() )
{
activePage.closeEditors( editorReferences.toArray( new IEditorReference[0] ), false );
}
}
else if ( oscSharedWorkingCopies.containsKey( originalEntry )
&& ( oscSharedWorkingCopies.get( originalEntry ) == modifiedEntry ) )
{
// OSC working copy has been modified: inform OSC editors
IEntry oscSharedWorkingCopy = oscSharedWorkingCopies.get( originalEntry );
List<IEntryEditor> oscEditors = getOscEditors( oscSharedWorkingCopy );
for ( IEntryEditor editor : oscEditors )
{
editor.workingCopyModified( event.getSource() );
}
}
else if ( autoSaveSharedWorkingCopies.containsValue( originalEntry )
&& ( autoSaveSharedWorkingCopies.get( originalEntry ) == modifiedEntry ) )
{
// auto-save working copy has been modified: save and inform all auto-save editors
IEntry autoSaveSharedReferenceCopy = autoSaveSharedReferenceCopies.get( originalEntry );
IEntry autoSaveSharedWorkingCopy = autoSaveSharedWorkingCopies.get( originalEntry );
// sanity check: never save if event source is the EntryEditorManager
if ( event.getSource() instanceof EntryEditorManager )
{
return;
}
// only save if we receive a real value modification event
if ( !( ( event instanceof ValueAddedEvent ) ||
( event instanceof ValueDeletedEvent ) ||
( event instanceof ValueModifiedEvent ) ||
( event instanceof ValueRenamedEvent ) ||
( event instanceof ValueMultiModificationEvent ) ) )
{
return;
}
// consistency check: don't save if there is an empty value, silently return in that case
for ( IAttribute attribute : autoSaveSharedWorkingCopy.getAttributes() )
{
for ( IValue value : attribute.getValues() )
{
if ( value.isEmpty() )
{
return;
}
}
}
LdifFile diff = Utils.computeDiff( autoSaveSharedReferenceCopy, autoSaveSharedWorkingCopy );
if ( diff != null )
{
// remove entry from map, reduces number of fired events
autoSaveSharedReferenceCopies.remove( originalEntry );
autoSaveSharedWorkingCopies.remove( originalEntry );
UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry, diff
.toFormattedString( LdifFormatParameters.DEFAULT ) );
RunnableContextRunner.execute( runnable, null, true );
// put entry back to map
autoSaveSharedReferenceCopies.put( originalEntry, autoSaveSharedReferenceCopy );
autoSaveSharedWorkingCopies.put( originalEntry, autoSaveSharedWorkingCopy );
// don't care if status is ok or not: always update
updateAutoSaveSharedReferenceCopy( originalEntry );
updateAutoSaveSharedWorkingCopy( originalEntry );
List<IEntryEditor> editors = getAutoSaveEditors( autoSaveSharedWorkingCopy );
for ( IEntryEditor editor : editors )
{
editor.workingCopyModified( event.getSource() );
}
}
}
}
};
/** The listener for connection update */
private ConnectionUpdateListener connectionUpdateListener = new ConnectionUpdateAdapter()
{
@Override
public void connectionClosed( Connection connection )
{
closeEditorsBelongingToConnection( connection );
}
@Override
public void connectionRemoved( Connection connection )
{
closeEditorsBelongingToConnection( connection );
}
};
/**
* Creates a new instance of EntryEditorManager.
*/
public EntryEditorManager()
{
if ( PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null )
{
getEditorManager();
}
}
/**
* Get the EditorManager instance
*/
public void getEditorManager()
{
initEntryEditorExtensions();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( partListener );
EventRegistry
.addEntryUpdateListener( entryUpdateListener, BrowserCommonActivator.getDefault().getEventRunner() );
ConnectionEventRegistry.addConnectionUpdateListener( connectionUpdateListener, ConnectionUIPlugin.getDefault()
.getEventRunner() );
}
/**
* Initializes the entry editors extensions.
*/
private void initEntryEditorExtensions()
{
entryEditorExtensions = new HashMap<>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint( BrowserUIConstants.ENTRY_EDITOR_EXTENSION_POINT );
IConfigurationElement[] members = extensionPoint.getConfigurationElements();
// For each extension:
for ( IConfigurationElement member : members )
{
EntryEditorExtension bean = new EntryEditorExtension();
IExtension extension = member.getDeclaringExtension();
String extendingPluginId = extension.getNamespaceIdentifier();
bean.setId( member.getAttribute( ID_ATTR ) );
bean.setName( member.getAttribute( NAME_ATTR ) );
bean.setDescription( member.getAttribute( DESCRIPTION_ATTR ) );
String iconPath = member.getAttribute( ICON_ATTR );
ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( extendingPluginId, iconPath );
if ( icon == null )
{
icon = ImageDescriptor.getMissingImageDescriptor();
}
bean.setIcon( icon );
bean.setClassName( member.getAttribute( CLASS_ATTR ) );
bean.setEditorId( member.getAttribute( EDITOR_ID_ATTR ) );
bean.setMultiWindow( "true".equalsIgnoreCase( member.getAttribute( MULTI_WINDOW_ATTR ) ) ); //$NON-NLS-1$
bean.setPriority( Integer.parseInt( member.getAttribute( PRIORITY_ATTR ) ) );
try
{
bean.setEditorInstance( ( IEntryEditor ) member.createExecutableExtension( CLASS_ATTR ) );
}
catch ( CoreException e )
{
// Will never happen
}
entryEditorExtensions.put( bean.getId(), bean );
}
}
public void dispose()
{
IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if ( ww != null )
{
ww.getPartService().removePartListener( partListener );
EventRegistry.removeEntryUpdateListener( entryUpdateListener );
}
}
/**
* Gets the entry editor extensions.
*
* @return the entry editor extensions
*/
public Collection<EntryEditorExtension> getEntryEditorExtensions()
{
return entryEditorExtensions.values();
}
/**
* Gets the entry editor extension.
*
* @param id the entry editor extension id
*
* @return the entry editor extension, null if none found
*/
public EntryEditorExtension getEntryEditorExtension( String id )
{
return entryEditorExtensions.get( id );
}
/**
* Gets the sorted entry editor extensions.
*
* @return
* the sorted entry editor extensions
*/
public Collection<EntryEditorExtension> getSortedEntryEditorExtensions()
{
boolean useUserPriority = BrowserUIPlugin.getDefault().getPluginPreferences().getBoolean(
BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES );
if ( useUserPriority )
{
return getEntryEditorExtensionsSortedByUserPriority();
}
else
{
return getEntryEditorExtensionsSortedByDefaultPriority();
}
}
/**
* Gets the entry editor extensions sorted by default priority.
*
* @return
* the entry editor extensions sorted by default priority
*/
public Collection<EntryEditorExtension> getEntryEditorExtensionsSortedByDefaultPriority()
{
// Getting all entry editors
Collection<EntryEditorExtension> entryEditorExtensions = getEntryEditorExtensions();
// Creating the sorted entry editors list
ArrayList<EntryEditorExtension> sortedEntryEditorsList = new ArrayList<>(
entryEditorExtensions.size() );
// Adding the remaining entry editors
for ( EntryEditorExtension entryEditorExtension : entryEditorExtensions )
{
sortedEntryEditorsList.add( entryEditorExtension );
}
// Sorting the remaining entry editors based on their priority
Collections.sort( sortedEntryEditorsList, entryEditorComparator );
return sortedEntryEditorsList;
}
/**
* Gets the entry editor extensions sorted by user's priority.
*
* @return
* the entry editor extensions sorted by user's priority
*/
public Collection<EntryEditorExtension> getEntryEditorExtensionsSortedByUserPriority()
{
// Getting all entry editors
Collection<EntryEditorExtension> entryEditorExtensions = BrowserUIPlugin.getDefault().getEntryEditorManager()
.getEntryEditorExtensions();
// Creating the sorted entry editors list
Collection<EntryEditorExtension> sortedEntryEditorsList = new ArrayList<>(
entryEditorExtensions.size() );
// Getting the user's priorities
String userPriorities = BrowserUIPlugin.getDefault().getPluginPreferences().getString(
BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USER_PRIORITIES );
if ( ( userPriorities != null ) && ( !"".equals( userPriorities ) ) ) //$NON-NLS-1$
{
String[] splittedUserPriorities = userPriorities.split( PRIORITIES_SEPARATOR );
if ( ( splittedUserPriorities != null ) && ( splittedUserPriorities.length > 0 ) )
{
// Creating a map where entry editors are accessible via their ID
Map<String, EntryEditorExtension> entryEditorsMap = new HashMap<>();
for ( EntryEditorExtension entryEditorExtension : entryEditorExtensions )
{
entryEditorsMap.put( entryEditorExtension.getId(), entryEditorExtension );
}
// Adding the entry editors according to the user's priority
for ( String entryEditorId : splittedUserPriorities )
{
// Verifying the entry editor is present in the map
if ( entryEditorsMap.containsKey( entryEditorId ) )
{
// Adding it to the sorted list
sortedEntryEditorsList.add( entryEditorsMap.get( entryEditorId ) );
}
}
}
// If some new plugins have been added recently, their new
// entry editors may not be present in the string stored in
// the preferences.
// We are then adding them at the end of the sorted list.
// Creating a list of remaining entry editors
List<EntryEditorExtension> remainingEntryEditors = new ArrayList<>();
for ( EntryEditorExtension entryEditorExtension : entryEditorExtensions )
{
// Verifying the entry editor is present in the sorted list
if ( !sortedEntryEditorsList.contains( entryEditorExtension ) )
{
// Adding it to the remaining list
remainingEntryEditors.add( entryEditorExtension );
}
}
// Sorting the remaining entry editors based on their priority
Collections.sort( remainingEntryEditors, entryEditorComparator );
// Adding the remaining entry editors
for ( EntryEditorExtension entryEditorExtension : remainingEntryEditors )
{
sortedEntryEditorsList.add( entryEditorExtension );
}
}
return sortedEntryEditorsList;
}
/**
* Closes the open editors belonging to the given connection.
*
* @param connection
* the connection
*/
private void closeEditorsBelongingToConnection( Connection connection )
{
if ( connection != null )
{
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
// Collecting editor references to close
List<IEditorReference> editorReferences = new ArrayList<>();
for ( IEditorReference ref : activePage.getEditorReferences() )
{
IEntryEditor editor = getEntryEditor( ref );
if ( ( editor != null ) && ( editor.getEntryEditorInput().getResolvedEntry() != null ) )
{
IBrowserConnection bc = editor.getEntryEditorInput().getResolvedEntry().getBrowserConnection();
if ( connection.equals( bc.getConnection() ) )
{
editorReferences.add( ref );
}
}
}
// Closing the corresponding editor references
if ( !editorReferences.isEmpty() )
{
activePage.closeEditors( editorReferences.toArray( new IEditorReference[0] ), false );
}
}
}
/**
* Opens an entry editor with the given entry editor extension and one of
* the given entries, search results or bookmarks.
*
* @param extension the entry editor extension
* @param entries an array of entries
* @param searchResults an array of search results
* @param bookmarks an arrays of bookmarks
*/
public void openEntryEditor( EntryEditorExtension extension, IEntry[] entries, ISearchResult[] searchResults,
IBookmark[] bookmarks )
{
OpenEntryEditorRunnable runnable = new OpenEntryEditorRunnable( extension, entries, searchResults, bookmarks );
StudioBrowserJob job = new StudioBrowserJob( runnable );
job.setPriority( Job.INTERACTIVE ); // Highest priority (just in case)
job.execute();
}
/**
* Opens an entry editor with one of the given entries, search results or bookmarks.
*
* @param entries an array of entries
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/SingleTabEntryEditorMatchingStrategy.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/SingleTabEntryEditorMatchingStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorMatchingStrategy;
import org.eclipse.ui.IEditorReference;
/**
* Matching strategy for a single tab entry editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class SingleTabEntryEditorMatchingStrategy implements IEditorMatchingStrategy
{
/**
* Returns true if the given editor is single-tab and the input refers
* the same editor.
*/
public boolean matches( IEditorReference editorRef, IEditorInput input )
{
if ( !( input instanceof EntryEditorInput ) )
{
return false;
}
EntryEditorInput entryEditorInput = ( EntryEditorInput ) input;
if ( entryEditorInput.getExtension() == null )
{
return false;
}
if ( entryEditorInput.getExtension().isMultiWindow() )
{
return false;
}
if ( !editorRef.getId().equals( entryEditorInput.getExtension().getEditorId() ) )
{
return false;
}
return true;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorExtension.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.resource.ImageDescriptor;
/**
* A bean class to hold the entry editor extension point properties.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EntryEditorExtension
{
/** The ID. */
private String id = null;
/** The name. */
private String name = null;
/** The description. */
private String description = null;
/** The icon. */
private ImageDescriptor icon = null;
/** The class name. */
private String className = null;
/** The editor id. */
private String editorId = null;
/** The multi window flag. */
private boolean multiWindow = true;
/** The priority. */
private int priority = 0;
/** The configuration element. */
private IConfigurationElement member = null;
/** The editor instance */
private IEntryEditor editorInstance = null;
/**
* Gets the id.
*
* @return the id
*/
public String getId()
{
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId( String id )
{
this.id = id;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName( String name )
{
this.name = name;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription()
{
return description;
}
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription( String description )
{
this.description = description;
}
/**
* Gets the icon.
*
* @return the icon
*/
public ImageDescriptor getIcon()
{
return icon;
}
/**
* Sets the icon.
*
* @param icon the new icon
*/
public void setIcon( ImageDescriptor icon )
{
this.icon = icon;
}
/**
* Gets the class name.
*
* @return the class name
*/
public String getClassName()
{
return className;
}
/**
* Sets the class name.
*
* @param className the new class name
*/
public void setClassName( String className )
{
this.className = className;
}
/**
* Gets the editor id.
*
* @return the editor id
*/
public String getEditorId()
{
return editorId;
}
/**
* Sets the editor id.
*
* @param editorId the new editor id
*/
public void setEditorId( String editorId )
{
this.editorId = editorId;
}
/**
* Checks if is multi window.
*
* @return true, if is multi window
*/
public boolean isMultiWindow()
{
return multiWindow;
}
/**
* Sets the multi window.
*
* @param multiWindow the new multi window
*/
public void setMultiWindow( boolean multiWindow )
{
this.multiWindow = multiWindow;
}
/**
* Gets the priority.
*
* @return the priority
*/
public int getPriority()
{
return priority;
}
/**
* Sets the priority.
*
* @param priority the new priority
*/
public void setPriority( int priority )
{
this.priority = priority;
}
/**
* Gets the member.
*
* @return the member
*/
public IConfigurationElement getMember()
{
return member;
}
/**
* Sets the member.
*
* @param member the new member
*/
public void setMember( IConfigurationElement member )
{
this.member = member;
}
/**
* Gets the editor instance.
*
* @return
* the editor instance
*/
public IEntryEditor getEditorInstance()
{
return editorInstance;
}
/**
* Sets the editor instance
*
* @param editorInstance
* the editor instance
*/
public void setEditorInstance( IEntryEditor editorInstance )
{
this.editorInstance = editorInstance;
}
@Override
public String toString()
{
return "EntryEditorExtension [className=" + className + ", description=" + description + ", editorId=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ editorId + ", icon=" + icon + ", id=" + id + ", member=" + member + ", name=" + name + ", priority=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ priority + ", multiWindow=" + multiWindow + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/Messages.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
import org.apache.directory.studio.ldapbrowser.core.model.impl.RootDSE;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
* The input for the entry editor.
*
* This class also manages the shared reference copy and the shared working copy
* of the original entry. Each manual-save editor <b>must</b> use these entry
* copies!
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EntryEditorInput implements IEditorInput
{
/** The entry input */
private IEntry entry;
/** The search result input */
private ISearchResult searchResult;
/** The bookmark input */
private IBookmark bookmark;
/** The entry editor extension. */
private EntryEditorExtension extension;
/** The resolved entry, based on the entry, searchResult and bookmark */
private IEntry resolvedEntry;
/**
* Creates a new instance of EntryEditorInput with an IEntry as
* domain object.
*
* @param entry the entry input
*/
public EntryEditorInput( IEntry entry, EntryEditorExtension extension )
{
this( entry, null, null, extension );
}
/**
* Creates a new instance of EntryEditorInput with an ISearchResult as
* domain object.
*
* @param searchResult the search result input
*/
public EntryEditorInput( ISearchResult searchResult, EntryEditorExtension extension )
{
this( null, searchResult, null, extension );
}
/**
* Creates a new instance of EntryEditorInput with an IBookmark as
* domain object.
*
* @param bookmark the bookmark input
*/
public EntryEditorInput( IBookmark bookmark, EntryEditorExtension extension )
{
this( null, null, bookmark, extension );
}
/**
* The private constructor, which is called by all the public constructors.
*/
private EntryEditorInput( IEntry entry, ISearchResult searchResult, IBookmark bookmark,
EntryEditorExtension extension )
{
this.entry = entry;
this.searchResult = searchResult;
this.bookmark = bookmark;
this.extension = extension;
if ( entry != null )
{
resolvedEntry = entry;
}
else if ( searchResult != null )
{
resolvedEntry = searchResult.getEntry();
}
else if ( bookmark != null )
{
resolvedEntry = bookmark.getEntry();
}
if ( resolvedEntry != null )
{
resolvedEntry = resolvedEntry.getBrowserConnection().getEntryFromCache( resolvedEntry.getDn() );
}
}
/**
* This implementation always return false because
* an entry should not be visible in the
* "File Most Recently Used" menu.
*
* {@inheritDoc}
*/
public boolean exists()
{
return false;
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return extension.getIcon();
}
/**
* {@inheritDoc}
*/
public String getName()
{
if ( resolvedEntry != null )
{
if ( resolvedEntry instanceof RootDSE )
{
return Messages.getString( "EntryEditorNavigationLocation.RootDSE" ); //$NON-NLS-1$
}
else
{
return resolvedEntry.getDn().getName();
}
}
return Messages.getString( "EntryEditorInput.NoEntrySelected" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public String getToolTipText()
{
if ( resolvedEntry != null )
{
IBrowserConnection connection = resolvedEntry.getBrowserConnection();
if ( ( connection != null ) && ( connection.getConnection() != null ) )
{
return getName() + " - " + connection.getConnection().getName();//$NON-NLS-1$
}
else
{
return getName();
}
}
return Messages.getString( "EntryEditorInput.NoEntrySelected" ); //$NON-NLS-1$
}
/**
* This implementation always return null.
*
* {@inheritDoc}
*/
public IPersistableElement getPersistable()
{
return null;
}
/**
* {@inheritDoc}
*/
public Object getAdapter( Class adapter )
{
return null;
}
/**
* Gets the entry editor extension.
*
* @return the entry editor extension
*/
public EntryEditorExtension getExtension()
{
return extension;
}
/**
* Gets the resolved entry, either the entry input itself
* or the entry behind the search result input or the entry behind
* the bookmark input.
*
* @return the resolved entry
*/
public IEntry getResolvedEntry()
{
return resolvedEntry;
}
/**
* Gets the shared working copy of the shared reference entry.
* This is used by all manual-save entry editors.
*
* @return the shared working copy of the shared reference entry
*/
public IEntry getSharedWorkingCopy( IEntryEditor editor )
{
if ( resolvedEntry != null )
{
return BrowserUIPlugin.getDefault().getEntryEditorManager().getSharedWorkingCopy( resolvedEntry, editor );
}
return null;
}
/**
* Checks if the shared working copy is dirty.
* @param entryEditor
*
* @return true, if the shared working copy is dirty
*/
public boolean isSharedWorkingCopyDirty( IEntryEditor editor )
{
boolean dirty = BrowserUIPlugin.getDefault().getEntryEditorManager().isSharedWorkingCopyDirty(
resolvedEntry, editor );
return dirty;
}
/**
* Save the difference between the shared reference copy and the shared working copy
* to the directory server.
*
* @param handleError the handle error
* @param editor the entry editor
*
* @return the status or null if there was nothing to save
*/
public IStatus saveSharedWorkingCopy( boolean handleError, IEntryEditor editor )
{
IStatus status = BrowserUIPlugin.getDefault().getEntryEditorManager().saveSharedWorkingCopy(
resolvedEntry, handleError, editor );
return status;
}
/**
* Resets the shared reference copy and the shared working copy.
*
* @param editor the entry editor
*/
public void resetSharedWorkingCopy( IEntryEditor editor )
{
BrowserUIPlugin.getDefault().getEntryEditorManager().resetSharedWorkingCopy( resolvedEntry, editor );
}
/**
* Gets the entry input, may be null.
*
* @return the entry input or null
*/
public IEntry getEntryInput()
{
return entry;
}
/**
* Gets the search result input, may be null.
*
* @return the search result input or null
*/
public ISearchResult getSearchResultInput()
{
return searchResult;
}
/**
* Gets the bookmark input, may be null.
*
* @return the bookmark input or null
*/
public IBookmark getBookmarkInput()
{
return bookmark;
}
/**
* Gets the input, may be null.
*
* @return the input or null
*/
public Object getInput()
{
if ( entry != null )
{
return entry;
}
else if ( searchResult != null )
{
return searchResult;
}
else if ( bookmark != null )
{
return bookmark;
}
else
{
return null;
}
}
/**
* {@inheritDoc}
*/
public int hashCode()
{
if ( extension == null )
{
return 0;
}
else if ( extension.isMultiWindow() )
{
if ( resolvedEntry == null )
{
return 0;
}
else
{
return resolvedEntry.getDn().hashCode();
}
}
else
{
return 0;
}
}
/**
* The result depends
*
* {@inheritDoc}
*/
public boolean equals( Object obj )
{
if ( !( obj instanceof EntryEditorInput ) )
{
return false;
}
EntryEditorInput other = ( EntryEditorInput ) obj;
if ( extension == null && other.extension == null )
{
return true;
}
if ( this.getExtension() != other.getExtension() )
{
return false;
}
if ( this.getInput() == null && other.getInput() == null )
{
return true;
}
else if ( this.getInput() == null || other.getInput() == null )
{
return false;
}
else
{
return other.getInput().equals( this.getInput() );
}
}
/**
* @see Object#toString()
*/
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( resolvedEntry );
return sb.toString();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.jobs.StudioConnectionBulkRunnableWithProgress;
import org.apache.directory.studio.connection.core.jobs.StudioConnectionRunnableWithProgressAdapter;
import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
import org.apache.directory.studio.ldapbrowser.core.model.IContinuation;
import org.apache.directory.studio.ldapbrowser.core.model.IContinuation.State;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* Runnable to open an entry editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenEntryEditorRunnable extends StudioConnectionRunnableWithProgressAdapter implements
StudioConnectionBulkRunnableWithProgress
{
/** The entries */
private IEntry[] entries;
/** The entries found in a search operation */
private ISearchResult[] searchResults;
/** The bookmarked elements */
private IBookmark[] bookmarks;
/** The extensions, if any */
private EntryEditorExtension extension;
/**
* Creates a new instance of OpenEntryEditorRunnable.
* <p>
* Opens an entry editor with the given entry editor extension and one of
* the given entries, search results or bookmarks.
*
* @param extension the entry editor extension
* @param entries an array of entries
* @param searchResults an array of search results
* @param bookmarks an arrays of bookmarks
*/
public OpenEntryEditorRunnable( EntryEditorExtension extension, IEntry[] entries, ISearchResult[] searchResults,
IBookmark[] bookmarks )
{
super();
this.extension = extension;
this.entries = entries;
this.searchResults = searchResults;
this.bookmarks = bookmarks;
}
/**
* {@inheritDoc}
*/
public String getName()
{
return Messages.getString( "OpenEntryEditorRunnable.OpenEntryEditor" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public Object[] getLockedObjects()
{
if ( entries.length == 1 )
{
return new Object[]
{ entries[0] };
}
else if ( searchResults.length == 1 )
{
return new Object[]
{ searchResults[0].getEntry() };
}
else if ( bookmarks.length == 1 )
{
return new Object[]
{ bookmarks[0].getEntry() };
}
else
{
return new Object[0];
}
}
/**
* {@inheritDoc}
*/
public Connection[] getConnections()
{
if ( entries.length == 1 )
{
return new Connection[]
{ entries[0].getBrowserConnection().getConnection() };
}
else if ( searchResults.length == 1 )
{
return new Connection[]
{ searchResults[0].getEntry().getBrowserConnection().getConnection() };
}
else if ( bookmarks.length == 1 )
{
return new Connection[]
{ bookmarks[0].getEntry().getBrowserConnection().getConnection() };
}
else
{
return new Connection[0];
}
}
/**
* {@inheritDoc}
*/
public void run( StudioProgressMonitor monitor )
{
monitor.setTaskName( Messages.getString( "OpenEntryEditorRunnable.OpeningEntryEditor" ) ); //$NON-NLS-1$
// Getting the entry to open
IEntry entry = null;
if ( entries.length == 1 )
{
entry = entries[0];
}
else if ( searchResults.length == 1 )
{
entry = searchResults[0].getEntry();
}
else if ( bookmarks.length == 1 )
{
entry = bookmarks[0].getEntry();
}
if ( entry != null )
{
if ( entry instanceof IContinuation )
{
IContinuation continuation = ( IContinuation ) entry;
if ( continuation.getState() == State.UNRESOLVED )
{
continuation.resolve();
}
}
else
{
// Making sure attributes are initialized
if ( !entry.isAttributesInitialized() )
{
InitializeAttributesRunnable.initializeAttributes( entry, monitor );
}
}
}
// If no entry editor was provided, find the correct one
if ( extension == null )
{
// Looking for the correct entry editor
for ( EntryEditorExtension entryEditorExtension : BrowserUIPlugin.getDefault().getEntryEditorManager()
.getSortedEntryEditorExtensions() )
{
// Verifying that the editor can handle the entry
if ( entryEditorExtension.getEditorInstance().canHandle( entry ) )
{
extension = entryEditorExtension;
break;
}
}
}
// Getting the editor's ID and creating the proper editor input
final String editorId = extension.getEditorId();
final EntryEditorInput editorInput;
if ( entries.length == 1 )
{
editorInput = new EntryEditorInput( entries[0], extension );
}
else if ( searchResults.length == 1 )
{
editorInput = new EntryEditorInput( searchResults[0], extension );
}
else if ( bookmarks.length == 1 )
{
editorInput = new EntryEditorInput( bookmarks[0], extension );
}
else
{
editorInput = new EntryEditorInput( ( IEntry ) null, extension );
}
// Opening the editor
Display.getDefault().syncExec( new Runnable()
{
public void run()
{
try
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( editorInput,
editorId, false );
}
catch ( PartInitException e )
{
throw new RuntimeException( e );
}
}
} );
}
/**
* {@inheritDoc}
*/
public void runNotification( StudioProgressMonitor monitor )
{
// Nothing to notify
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.apache.directory.studio.connection.ui.RunnableContextRunner;
import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
public class EntryEditorUtils
{
/**
* Checks if the attributes of the given entry are initialized and
* initializes them if necessary.
*
* @param entry the entry
* @return
* the job associated with the attributes initialization,
* or <code>null</code> if the attributes were already initialized
*/
public static void ensureAttributesInitialized( IEntry entry )
{
if ( !entry.isAttributesInitialized() )
{
InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( entry );
RunnableContextRunner.execute( runnable, null, true );
}
}
/**
* Gets the entry editor input from the editor input.
*
* @param input the input
*
* @return the entry editor input
*/
public static EntryEditorInput getEntryEditorInput( IEditorInput input )
{
if ( input instanceof EntryEditorInput )
{
EntryEditorInput eei = ( EntryEditorInput ) input;
return eei;
}
else
{
throw new IllegalArgumentException( "Expected an EntryEditorInput" ); //$NON-NLS-1$
}
}
/**
* Gets the text used in the history navigation list.
*
* @param input the input
*
* @return the text
*/
public static String getHistoryNavigationText( EntryEditorInput input )
{
if ( input != null )
{
if ( input.getEntryInput() != null )
{
String connectionName = input.getEntryInput().getBrowserConnection().getConnection() == null ? "" //$NON-NLS-1$
: " - " + input.getEntryInput().getBrowserConnection().getConnection().getName(); //$NON-NLS-1$
if ( input.getEntryInput() instanceof IRootDSE )
{
return Messages.getString( "EntryEditorNavigationLocation.RootDSE" ) + connectionName; //$NON-NLS-1$ //$NON-NLS-2$
}
else
{
return NLS.bind( Messages.getString( "EntryEditorNavigationLocation.Entry" ), //$NON-NLS-1$
input.getEntryInput().getDn().getName() ) + connectionName;
}
}
else if ( input.getSearchResultInput() != null )
{
String connectionName = input.getSearchResultInput().getEntry().getBrowserConnection().getConnection() == null ? "" //$NON-NLS-1$
: " - " + input.getSearchResultInput().getEntry().getBrowserConnection().getConnection().getName(); //$NON-NLS-1$
if ( input.getSearchResultInput() instanceof IRootDSE )
{
return Messages.getString( "EntryEditorNavigationLocation.RootDSE" ) + connectionName; //$NON-NLS-1$ //$NON-NLS-2$
}
else
{
return NLS.bind( Messages.getString( "EntryEditorNavigationLocation.SearchResult" ), //$NON-NLS-1$
input.getSearchResultInput().getDn().getName() ) + connectionName; //$NON-NLS-1$
}
}
else if ( input.getBookmarkInput() != null )
{
String connectionName = input.getBookmarkInput().getBrowserConnection().getConnection() == null ? "" //$NON-NLS-1$
: " - " + input.getBookmarkInput().getBrowserConnection().getConnection().getName(); //$NON-NLS-1$
if ( input.getBookmarkInput() instanceof IRootDSE )
{
return Messages.getString( "EntryEditorNavigationLocation.RootDSE" ) + connectionName; //$NON-NLS-1$
}
else
{
return NLS.bind( Messages.getString( "EntryEditorNavigationLocation.Bookmark" ), //$NON-NLS-1$
input.getBookmarkInput().getDn().getName() ) + connectionName;
}
}
else
{
return Messages.getString( "EntryEditorUtils.NoEntrySelected" ); //$NON-NLS-1$
}
}
return null;
}
/**
* Asks the user if he wants to save the modifications made to the entry before
* opening the new input.
* <p>
* If the user answers 'Yes', then the entry's modifications are saved.
* <p>
* This method returns whether or not the whole operation completed.
* <p>Based on this return value, <code>true</code> or <code>false</code>, the editor
* then updates its input or not.
*
* @param editor
* the editor
* @return
* <code>true</code> if the whole operation completed correctly,
* <code>false</code> if not.
*/
public static boolean askSaveSharedWorkingCopyBeforeInputChange( IEntryEditor editor )
{
// Asking for saving the modifications
MessageDialog dialog = new MessageDialog( Display.getCurrent().getActiveShell(), Messages
.getString( "EntryEditorUtils.SaveChanges" ), null, Messages //$NON-NLS-1$
.getString( "EntryEditorUtils.SaveChangesDescription" ), MessageDialog.QUESTION, new String[] //$NON-NLS-1$
{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0 );
int result = dialog.open();
if ( result == 0 )
{
// Saving the modifications
EntryEditorInput eei = editor.getEntryEditorInput();
IStatus status = eei.saveSharedWorkingCopy( true, editor );
if ( ( status == null ) || !status.isOK() )
{
// If save failed, let's keep the modifications in the editor and return false
return false;
}
}
return true;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.entryeditors;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
/**
* An Entry Editor is used to display and edit an LDAP entry.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface IEntryEditor
{
/**
* This method indicates if the editor can handle the given entry.
*
* @param entry the entry.
*
* @return true if this editor can handle the entry, false otherwise.
*/
boolean canHandle( IEntry entry );
/**
* Informs the entry editor that the working copy was modified.
*
* @param source the source of the modification, may be null
*/
void workingCopyModified( Object source );
/**
* Gets the entry editor input.
*
* @return the entry editor input, null if no input was set
*/
EntryEditorInput getEntryEditorInput();
/**
* Checks if the editor uses auto save, i.e. if each modification is
* automatically committed to the directory server.
*
* @return true, if the editor uses auto save
*/
boolean isAutoSave();
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIConstants.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui;
/**
* This class contains all the constants used by the Browser UI Plugin
* Final reference -> class shouldn't be extended
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public final class BrowserUIConstants
{
/**
* Ensures no construction of this class, also ensures there is no need for final keyword above
* (Implicit super constructor is not visible for default constructor),
* but is still self documenting.
*/
private BrowserUIConstants()
{
}
/** The plug-in ID */
public static final String PLUGIN_ID = BrowserUIConstants.class.getPackage().getName();
public static final String ENTRY_EDITOR_EXTENSION_POINT = "org.apache.directory.studio.entryeditors"; //$NON-NLS-1$
public static final String DN = "Dn"; //$NON-NLS-1$
public static final String PREFERENCE_BROWSER_LINK_WITH_EDITOR = "browserLinkWithEditor"; //$NON-NLS-1$
public static final String PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN = "searchResultEditorShowDn"; //$NON-NLS-1$
public static final String PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS = "searchResultEditorShowLinks"; //$NON-NLS-1$
public static final String PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT = "searchResultEditorSortFilterLimit"; //$NON-NLS-1$
public static final String PREFERENCEPAGEID_MAIN = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "PrefPage_MainPreferencePage_id" ); //$NON-NLS-1$
public static final String PREFERENCEPAGEID_ATTRIBUTES = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "PrefPage_AttributesPreferencePage_id" ); //$NON-NLS-1$
public static final String PREFERENCEPAGEID_BINARYATTRIBUTES =
"org.apache.directory.studio.ldapbrowser.preferences.BinaryAttributesAndSyntaxesPreferencePage"; //$NON-NLS-1$
public static final String PREFERENCEPAGEID_BROWSER =
"org.apache.directory.studio.ldapbrowser.preferences.BrowserPreferencePage"; //$NON-NLS-1$
public static final String PREFERENCEPAGEID_ENTRYEDITOR =
"org.apache.directory.studio.ldapbrowser.preferences.EntryEditorPreferencePage"; //$NON-NLS-1$
public static final String PREFERENCEPAGEID_ENTRYEDITORS =
"org.apache.directory.studio.ldapbrowser.preferences.EntryEditorsPreferencePage"; //$NON-NLS-1$
public static final String PREFERENCEPAGEID_SEARCHRESULTEDITOR = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "PrefPage_SearchResultEditorPreferencePage_id" ); //$NON-NLS-1$
public static final String PREFERENCEPAGEID_MODIFICATIONLOGS = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "PrefPage_ModificationLogsPreferencePage_id" ); //$NON-NLS-1$
public static final String PREFERENCEPAGEID_SEARCHLOGS = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "PrefPage_SearchLogsPreferencePage_id" ); //$NON-NLS-1$
public static final String PREFERENCEPAGEID_TEXTFORMATS =
"org.apache.directory.studio.ldapbrowser.preferences.TextFormatsPreferencePage"; //$NON-NLS-1$
/** The constant used to identify the "user user priorities" preference */
public static final String PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES = "useUserPriorities"; //$NON-NLS-1$
/** The constant used to identify the "user user priorities" preference */
public static final String PREFERENCE_ENTRYEDITORS_USER_PRIORITIES = "userPriorities"; //$NON-NLS-1$
/** The constant used to identify the "open mode" preference */
public static final String PREFERENCE_ENTRYEDITORS_OPEN_MODE = "openMode"; //$NON-NLS-1$
public static final int PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR = 0; //$NON-NLS-1$
public static final int PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE = 1; //$NON-NLS-1$
public static final String IMG_LINK_WITH_EDITOR = "resources/icons/link_with_editor.gif"; //$NON-NLS-1$
public static final String IMG_BATCH = "resources/icons/batch.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT = "resources/icons/import.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT = "resources/icons/export.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_DSML_WIZARD = "resources/icons/import_dsml_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_DSML_WIZARD = "resources/icons/export_dsml_wizard.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_LDIF_WIZARD = "resources/icons/import_ldif_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_LDIF_WIZARD = "resources/icons/export_ldif_wizard.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_CONNECTIONS_WIZARD = "resources/icons/import_connections_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_CONNECTIONS_WIZARD = "resources/icons/export_connections_wizard.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_CSV_WIZARD = "resources/icons/import_csv_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_CSV_WIZARD = "resources/icons/export_csv_wizard.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_XLS_WIZARD = "resources/icons/import_xls_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_XLS_WIZARD = "resources/icons/export_xls_wizard.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_ODF_WIZARD = "resources/icons/export_odf_wizard.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_DSML = "resources/icons/import_dsml.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_DSML = "resources/icons/export_dsml.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_LDIF = "resources/icons/import_ldif.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_LDIF = "resources/icons/export_ldif.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_CONNECTIONS = "resources/icons/import_connections.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_CONNECTIONS = "resources/icons/export_connections.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_CSV = "resources/icons/import_csv.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_CSV = "resources/icons/export_csv.gif"; //$NON-NLS-1$
public static final String IMG_IMPORT_XLS = "resources/icons/import_xls.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_XLS = "resources/icons/export_xls.gif"; //$NON-NLS-1$
public static final String IMG_EXPORT_ODF = "resources/icons/export_odf.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_CONNECTIONVIEW = "resources/icons/browser_connectionview.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_BROWSERVIEW = "resources/icons/browser_browserview.gif"; //$NON-NLS-1$
public static final String IMG_DIT = "resources/icons/dit.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY = "resources/icons/entry_default.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_ROOT = "resources/icons/entry_root.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_DC = "resources/icons/entry_dc.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_ORG = "resources/icons/entry_org.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_PERSON = "resources/icons/entry_person.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_GROUP = "resources/icons/entry_group.gif"; //$NON-NLS-1$
public static final String IMG_ENTRY_REF = "resources/icons/entry_ref.png"; //$NON-NLS-1$
public static final String IMG_ENTRY_ALIAS = "resources/icons/entry_alias.png"; //$NON-NLS-1$
public static final String IMG_ENTRY_ADD = "resources/icons/entry_add.gif"; //$NON-NLS-1$
public static final String IMG_LOCATE_DN_IN_DIT = "resources/icons/locate_dn_in_dit.gif"; //$NON-NLS-1$
public static final String IMG_LOCATE_SEARCHRESULT_IN_DIT = "resources/icons/locate_searchresult_in_dit.gif"; //$NON-NLS-1$
public static final String IMG_LOCATE_BOOKMARK_IN_DIT = "resources/icons/locate_bookmark_in_dit.gif"; //$NON-NLS-1$
public static final String IMG_LOCATE_ENTRY_IN_DIT = "resources/icons/locate_entry_in_dit.gif"; //$NON-NLS-1$
public static final String IMG_OPEN_SEARCHRESULT = "resources/icons/open_searchresult.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_SINGLETAB_ENTRYEDITOR = "resources/icons/browser_singletab_entry_editor.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_MULTITAB_ENTRYEDITOR = "resources/icons/browser_multitab_entry_editor.gif"; //$NON-NLS-1$
public static final String IMG_ATTRIBUTE = "resources/icons/attribute.gif"; //$NON-NLS-1$
public static final String IMG_VALUE = "resources/icons/value.gif"; //$NON-NLS-1$
public static final String IMG_COPY_LDIF = "resources/icons/copy_ldif.gif"; //$NON-NLS-1$
public static final String IMG_COPY_LDIF_USER = "resources/icons/copy_ldif_user.gif"; //$NON-NLS-1$
public static final String IMG_COPY_LDIF_OPERATIONAL = "resources/icons/copy_ldif_operational.gif"; //$NON-NLS-1$
public static final String IMG_COPY_LDIF_SEARCHRESULT = "resources/icons/copy_ldif_searchresult.gif"; //$NON-NLS-1$
public static final String IMG_COPY_CSV = "resources/icons/copy_csv.gif"; //$NON-NLS-1$
public static final String IMG_COPY_CSV_USER = "resources/icons/copy_csv_user.gif"; //$NON-NLS-1$
public static final String IMG_COPY_CSV_OPERATIONAL = "resources/icons/copy_csv_operational.gif"; //$NON-NLS-1$
public static final String IMG_COPY_CSV_SEARCHRESULT = "resources/icons/copy_csv_searchresult.gif"; //$NON-NLS-1$
public static final String IMG_COPY_BASE64 = "resources/icons/copy_base64.gif"; //$NON-NLS-1$
public static final String IMG_COPY_HEX = "resources/icons/copy_hex.gif"; //$NON-NLS-1$
public static final String IMG_COPY_UTF8 = "resources/icons/copy_raw.gif"; //$NON-NLS-1$
public static final String IMG_COPY_DISPLAY = "resources/icons/copy_display.gif"; //$NON-NLS-1$
public static final String IMG_COPY_DN = "resources/icons/copy_dn.gif"; //$NON-NLS-1$
public static final String IMG_COPY_URL = "resources/icons/copy_url.gif"; //$NON-NLS-1$
public static final String IMG_COPY_ATT = "resources/icons/copy_att.gif"; //$NON-NLS-1$
public static final String IMG_COPY_TABLE = "resources/icons/copy_table.gif"; //$NON-NLS-1$
public static final String IMG_TABLE = "resources/icons/table.gif"; //$NON-NLS-1$
public static final String IMG_SORT_NONE = "resources/icons/sort_none.gif"; //$NON-NLS-1$
public static final String IMG_FILTER_EQUALS = "resources/icons/filter_equals.gif"; //$NON-NLS-1$
public static final String IMG_FILTER_AND = "resources/icons/filter_and.gif"; //$NON-NLS-1$
public static final String IMG_FILTER_OR = "resources/icons/filter_or.gif"; //$NON-NLS-1$
public static final String IMG_FILTER_NOT = "resources/icons/filter_not.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_SEARCHRESULTEDITOR = "resources/icons/browser_searchresulteditor.gif"; //$NON-NLS-1$
public static final String IMG_SEARCHES = "resources/icons/searches.gif"; //$NON-NLS-1$
public static final String IMG_SEARCH = "resources/icons/search.gif"; //$NON-NLS-1$
public static final String IMG_SEARCH_NEW = "resources/icons/search_new.gif"; //$NON-NLS-1$
public static final String IMG_SEARCH_UNPERFORMED = "resources/icons/search_unperformed.gif"; //$NON-NLS-1$
public static final String IMG_BOOKMARKS = "resources/icons/bookmarks.gif"; //$NON-NLS-1$
public static final String IMG_BOOKMARK = "resources/icons/bookmark.gif"; //$NON-NLS-1$
public static final String IMG_BOOKMARK_ADD = "resources/icons/bookmark_add.gif"; //$NON-NLS-1$
public static final String IMG_MARK = "resources/icons/mark.gif"; //$NON-NLS-1$
public static final String IMG_BROWSER_SCHEMABROWSEREDITOR = "resources/icons/browser_schemabrowsereditor.gif"; //$NON-NLS-1$
public static final String IMG_DEFAULT_SCHEMA = "resources/icons/defaultschema.gif"; //$NON-NLS-1$
public static final String IMG_ATD = "resources/icons/atd.png"; //$NON-NLS-1$
public static final String IMG_OCD = "resources/icons/ocd.png"; //$NON-NLS-1$
public static final String IMG_MRD = "resources/icons/mrd.png"; //$NON-NLS-1$
public static final String IMG_MRUD = "resources/icons/mrud.png"; //$NON-NLS-1$
public static final String IMG_LSD = "resources/icons/lsd.png"; //$NON-NLS-1$
public static final String IMG_MRD_EQUALITY = "resources/icons/mrd_equality.png"; //$NON-NLS-1$
public static final String IMG_MRD_SUBSTRING = "resources/icons/mrd_substring.png"; //$NON-NLS-1$
public static final String IMG_MRD_ORDERING = "resources/icons/mrd_ordering.png"; //$NON-NLS-1$
public static final String IMG_OVR_FILTERED = "resources/icons/ovr16/filtered.gif"; //$NON-NLS-1$
public static final String IMG_OVR_REF = "resources/icons/ovr16/ref.gif"; //$NON-NLS-1$
public static final String IMG_OVR_SEARCHRESULT = "resources/icons/ovr16/searchresult.gif"; //$NON-NLS-1$
public static final String IMG_OVR_ERROR = "resources/icons/ovr16/error.gif"; //$NON-NLS-1$
public static final String IMG_OVR_WARNING = "resources/icons/ovr16/warning.gif"; //$NON-NLS-1$
public static final String IMG_OVR_MARK = "resources/icons/ovr16/mark.gif"; //$NON-NLS-1$
public static final String IMG_NEXT = "resources/icons/next.gif"; //$NON-NLS-1$
public static final String IMG_PREVIOUS = "resources/icons/previous.gif"; //$NON-NLS-1$
public static final String IMG_REFRESH = "resources/icons/refresh.gif"; //$NON-NLS-1$
public static final String IMG_CLEAR = "resources/icons/clear.gif"; //$NON-NLS-1$
public static final String CMD_LOCATE_IN_DIT = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Cmd_LocateInDit_id" ); //$NON-NLS-1$
public static final String CMD_OPEN_SEARCH_RESULT = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Cmd_OpenSearchResult_id" ); //$NON-NLS-1$
public static final String PERSPECTIVE_LDAP = "org.apache.directory.studio.ldapbrowser.ui.perspective.BrowserPerspective"; //$NON-NLS-1$
public static final String PERSPECTIVE_SCHEMA_EDITOR = "org.apache.directory.studio.schemaeditor.perspective"; //$NON-NLS-1$
public static final String EDITOR_SINGLE_TAB_ENTRY_EDITOR = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_SingleTabEntryEditor_id" ); //$NON-NLS-1$
public static final String EDITOR_MULTI_TAB_ENTRY_EDITOR = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_MultiTabEntryEditor_id" ); //$NON-NLS-1$
public static final String EDITOR_SINGLE_TAB_LDIF_ENTRY_EDITOR = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_SingleTabLdifEntryEditor_id" ); //$NON-NLS-1$
public static final String EDITOR_MULTI_TAB_LDIF_ENTRY_EDITOR = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_MultiTabLdifEntryEditor_id" ); //$NON-NLS-1$
public static final String EDITOR_SCHEMA_BROWSER = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_SchemaBrowser_id" ); //$NON-NLS-1$
public static final String EDITOR_SEARCH_RESULT = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "Editor_SearchResultEditor_id" ); //$NON-NLS-1$
public static final String SEARCH_PAGE_LDAP_SEARCH = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "SearchPage_LdapSearch_id" ); //$NON-NLS-1$
public static final String VIEW_BROWSER_VIEW = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "View_BrowserView_id" ); //$NON-NLS-1$
public static final String VIEW_CONNECTION_VIEW = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "View_ConnectionView_id" ); //$NON-NLS-1$
public static final String VIEW_MODIFICATION_LOGS_VIEW = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "View_ModificationLogsView_id" ); //$NON-NLS-1$
public static final String VIEW_SEARCH_LOGS_VIEW = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "View_SearchLogsView_id" ); //$NON-NLS-1$
public static final String WIZARD_BATCH_OPERATION = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "NewWizard_BatchOperationWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_EXPORT_CONNECTIONS = "org.apache.directory.studio.ldapbrowser.ui.wizards.ImportConnectionsWizard"; //$NON-NLS-1$
public static final String WIZARD_EXPORT_CSV = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ExportWizard_ExportCsvWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_EXPORT_DSML = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ExportWizard_ExportDdsmlWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_EXPORT_EXCEL = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ExportWizard_ExportExcelWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_EXPORT_ODF = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ExportWizard_ExportOdfWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_EXPORT_LDIF = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ExportWizard_ExportLdifWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_IMPORT_CONNECTIONS = "org.apache.directory.studio.ldapbrowser.ui.wizards.ExportConnectionsWizard"; //$NON-NLS-1$
public static final String WIZARD_IMPORT_DSML = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ImportWizard_ImportDsmlWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_IMPORT_LDIF = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "ImportWizard_ImportLdifWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_NEW_BOOKMARK = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "NewWizard_NewBookmarkWizard_id" ); //$NON-NLS-1$
public static final String WIZARD_NEW_SEARCH = BrowserUIPlugin.getDefault().getPluginProperties()
.getString( "NewWizard_NewSearchWizard_id" ); //$NON-NLS-1$
public static final int INPUT_CHANGED = 1342730831;
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/Messages.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/Messages.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class get messages from the resources file.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Messages
{
/** The resource name */
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
/**
* Get back a message from the resource file given a key
*
* @param key The key associated with the message
* @return The found message
*/
public static String getString( String key )
{
try
{
return RESOURCE_BUNDLE.getString( key );
}
catch ( MissingResourceException e )
{
return '!' + key + '!';
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui;
import java.io.IOException;
import java.net.URL;
import java.util.PropertyResourceBundle;
import org.apache.directory.studio.entryeditors.EntryEditorManager;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The main plugin class to be used in the desktop.
*/
public class BrowserUIPlugin extends AbstractUIPlugin
{
/** The shared instance */
private static BrowserUIPlugin plugin;
/** The entry editor manager */
private EntryEditorManager entryEditorManager;
/** The plugin properties */
private PropertyResourceBundle properties;
/**
* The constructor.
*/
public BrowserUIPlugin()
{
plugin = this;
}
/**
* This method is called upon plug-in activation
*/
public void start( BundleContext context ) throws Exception
{
super.start( context );
if ( entryEditorManager == null )
{
entryEditorManager = new EntryEditorManager();
}
}
/**
* This method is called when the plug-in is stopped
*/
public void stop( BundleContext context ) throws Exception
{
super.stop( context );
if ( entryEditorManager != null )
{
entryEditorManager.dispose();
entryEditorManager = null;
}
plugin = null;
}
/**
* Returns the shared instance.
*/
public static BrowserUIPlugin getDefault()
{
return plugin;
}
// public static String getResourceString( String key )
// {
// ResourceBundle bundle = getDefault().getResourceBundle();
// try
// {
// return ( bundle != null ) ? bundle.getString( key ) : key;
// }
// catch ( MissingResourceException e )
// {
// return key;
// }
// }
/**
* Use this method to get SWT images. Use the IMG_ constants from
* BrowserUIConstants for the key.
*
* @param key
* The key (relative path to the image im filesystem)
* @return The image discriptor or null
*/
public ImageDescriptor getImageDescriptor( String key )
{
if ( key != null )
{
URL url = this.find( new Path( key ) );
if ( url != null )
return ImageDescriptor.createFromURL( url );
else
return null;
}
else
{
return null;
}
}
/**
* Use this method to get SWT images. Use the IMG_ constants from
* BrowserUIConstants for the key. A ImageRegistry is used to manage the
* the key->Image mapping.
* <p>
* Note: Don't dispose the returned SWT Image. It is disposed
* automatically when the plugin is stopped.
*
* @param key
* The key (relative path to the image im filesystem)
* @return The SWT Image or null
* @see BrowserUIConstants
*/
public Image getImage( String key )
{
Image image = getImageRegistry().get( key );
if ( image == null )
{
ImageDescriptor id = this.getImageDescriptor( key );
if ( id != null )
{
image = id.createImage();
getImageRegistry().put( key, image );
}
}
return image;
}
/**
* Gets the entry editor manager
*
* @return
* the entry editor manager
*/
public EntryEditorManager getEntryEditorManager()
{
return entryEditorManager;
}
/**
* Gets the plugin properties.
*
* @return
* the plugin properties
*/
public PropertyResourceBundle getPluginProperties()
{
if ( properties == null )
{
try
{
properties = new PropertyResourceBundle( FileLocator.openStream( this.getBundle(), new Path(
"plugin.properties" ), false ) ); //$NON-NLS-1$
}
catch ( IOException e )
{
// We can't use the PLUGIN_ID constant since loading the plugin.properties file has failed,
// So we're using a default plugin id.
getLog().log( new Status( Status.ERROR, "org.apache.directory.studio.ldapbrowser.ui", Status.OK, //$NON-NLS-1$
Messages.getString( "BrowserUIPlugin.UnableGetPluginProperties" ), e ) ); //$NON-NLS-1$
}
}
return properties;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPreferencesInitializer.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPreferencesInitializer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* This class is used to set default preference values.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class BrowserUIPreferencesInitializer extends AbstractPreferenceInitializer
{
/**
* {@inheritDoc}
*/
public void initializeDefaultPreferences()
{
IPreferenceStore store = BrowserUIPlugin.getDefault().getPreferenceStore();
// Browser
store.setDefault( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR, true );
// Search Result Editor
store.setDefault( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN, true );
store.setDefault( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS, true );
store.setDefault( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT, 10000 );
// Entry Editors
store.setDefault( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES, false );
store.setDefault( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USER_PRIORITIES, "" ); //$NON-NLS-1$
store.setDefault( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE,
BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
import org.apache.directory.studio.ldapbrowser.core.model.IValue;
import org.apache.directory.studio.ldapbrowser.core.utils.LdapFilterUtils;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
/**
* This Action copies the Search Filter
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class CopySearchFilterAction extends BrowserAction
{
/**
* Equals Mode.
*/
public static final int MODE_EQUALS = 0;
/**
* Not Mode.
*/
public static final int MODE_NOT = 1;
/**
* And Mode.
*/
public static final int MODE_AND = 2;
/**
* Or Mode.
*/
public static final int MODE_OR = 3;
private int mode;
/**
* Creates a new instance of CopySearchFilterAction.
*
* @param mode
* the copy Mode
*/
public CopySearchFilterAction( int mode )
{
this.mode = mode;
}
/**
* {@inheritDoc}
*/
public String getText()
{
if ( mode == MODE_EQUALS )
{
return Messages.getString( "CopySearchFilterAction.CopySearchFilter" ); //$NON-NLS-1$
}
else if ( mode == MODE_NOT )
{
return Messages.getString( "CopySearchFilterAction.CopyNotSearchFilter" ); //$NON-NLS-1$
}
else if ( mode == MODE_AND )
{
return Messages.getString( "CopySearchFilterAction.CopyAndSearchFilter" ); //$NON-NLS-1$
}
else if ( mode == MODE_OR )
{
return Messages.getString( "CopySearchFilterAction.CopyOrSearchFilter" ); //$NON-NLS-1$
}
else
{
return Messages.getString( "CopySearchFilterAction.CopySearchFilter" ); //$NON-NLS-1$
}
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
if ( mode == MODE_EQUALS )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_EQUALS );
}
else if ( mode == MODE_NOT )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_NOT );
}
else if ( mode == MODE_AND )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_AND );
}
else if ( mode == MODE_OR )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_OR );
}
else
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_EQUALS );
}
}
/**
* {@inheritDoc}
*/
public String getCommandId()
{
return null;
}
/**
* {@inheritDoc}
*/
public boolean isEnabled()
{
if ( mode == MODE_EQUALS || mode == MODE_NOT )
{
return getSelectedAttributeHierarchies().length + getSelectedAttributes().length
+ getSelectedValues().length == 1
&& ( getSelectedValues().length == 1
|| ( getSelectedAttributes().length == 1 && getSelectedAttributes()[0].getValueSize() == 1 ) || ( getSelectedAttributeHierarchies().length == 1
&& getSelectedAttributeHierarchies()[0].size() == 1 && getSelectedAttributeHierarchies()[0]
.getAttribute().getValueSize() == 1 ) );
}
else if ( mode == MODE_AND || mode == MODE_OR )
{
return getSelectedAttributeHierarchies().length + getSelectedAttributes().length
+ getSelectedValues().length > 0;
}
else
{
return false;
}
}
/**
* {@inheritDoc}
*/
public void run()
{
String filter = null;
if ( mode == MODE_EQUALS )
{
filter = getFilter( null );
}
else if ( mode == MODE_NOT )
{
filter = getFilter( "!" ); //$NON-NLS-1$
}
else if ( mode == MODE_AND )
{
filter = getFilter( "&" ); //$NON-NLS-1$
}
else if ( mode == MODE_OR )
{
filter = getFilter( "|" ); //$NON-NLS-1$
}
if ( filter != null && filter.length() > 0 )
{
CopyAction.copyToClipboard( new Object[]
{ filter }, new Transfer[]
{ TextTransfer.getInstance() } );
}
}
/**
* Gets the filter
*
* @param filterType
* the filter type
* @return
* the filter
*/
private String getFilter( String filterType )
{
Set filterSet = new LinkedHashSet();
for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
{
for ( Iterator it = getSelectedAttributeHierarchies()[i].iterator(); it.hasNext(); )
{
IAttribute att = ( IAttribute ) it.next();
IValue[] values = att.getValues();
for ( int v = 0; v < values.length; v++ )
{
filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
}
}
}
for ( int a = 0; a < getSelectedAttributes().length; a++ )
{
IValue[] values = getSelectedAttributes()[a].getValues();
for ( int v = 0; v < values.length; v++ )
{
filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
}
}
for ( int v = 0; v < getSelectedValues().length; v++ )
{
filterSet.add( LdapFilterUtils.getFilter( getSelectedValues()[v] ) );
}
StringBuffer filter = new StringBuffer();
if ( filterType != null )
{
filter.append( "(" ); //$NON-NLS-1$
filter.append( filterType );
for ( Iterator filterIterator = filterSet.iterator(); filterIterator.hasNext(); )
{
filter.append( filterIterator.next() );
}
filter.append( ")" ); //$NON-NLS-1$
}
else if ( filterSet.size() == 1 )
{
filter.append( filterSet.toArray()[0] );
}
return filter.toString();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateEntryInDitAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
/**
* This action is used within the browser view to locate and open the selected
* search result or bookmark in DIT.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LocateEntryInDitAction extends LocateInDitAction
{
/**
* Creates a new instance of LocateEntryInDitAction.
*/
public LocateEntryInDitAction()
{
}
/**
* {@inheritDoc}
*/
public String getText()
{
if ( getSelectedSearchResults().length == 1
&& getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length == 0 )
{
return Messages.getString( "LocateEntryInDitAction.ShowSearchResult" ); //$NON-NLS-1$
}
else if ( getSelectedBookmarks().length == 1
&& getSelectedSearchResults().length + getSelectedEntries().length
+ getSelectedBrowserViewCategories().length == 0 )
{
return Messages.getString( "LocateEntryInDitAction.ShowBookmark" ); //$NON-NLS-1$
}
else
{
return Messages.getString( "LocateEntryInDitAction.ShowInDit" ); //$NON-NLS-1$
}
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
if ( getSelectedSearchResults().length == 1
&& getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length == 0 )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_SEARCHRESULT_IN_DIT );
}
else if ( getSelectedBookmarks().length == 1
&& getSelectedSearchResults().length + getSelectedEntries().length
+ getSelectedBrowserViewCategories().length == 0 )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_BOOKMARK_IN_DIT );
}
else
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_ENTRY_IN_DIT );
}
}
/**
* This implementation returns a connection and Dn if the a search result or bookmark
* is selected.
*/
protected ConnectionAndDn getConnectionAndDn()
{
if ( getSelectedSearchResults().length == 1
&& getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length == 0 )
{
return new ConnectionAndDn( getSelectedSearchResults()[0].getEntry().getBrowserConnection(),
getSelectedSearchResults()[0].getEntry().getDn() );
}
else if ( getSelectedBookmarks().length == 1
&& getSelectedSearchResults().length + getSelectedEntries().length
+ getSelectedBrowserViewCategories().length == 0 )
{
return new ConnectionAndDn( getSelectedBookmarks()[0].getBrowserConnection(), getSelectedBookmarks()[0]
.getDn() );
}
else
{
return null;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSearchResultAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSearchResultAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* This Action opens the Search Result View.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenSearchResultAction extends BrowserAction
{
/**
* Creates a new instance of OpenSearchResultAction.
*/
public OpenSearchResultAction()
{
super();
}
/**
* {@inheritDoc}
*/
public void run()
{
if ( getSelectedSearchResults().length == 1 )
{
String targetId = BrowserView.getId();
IViewPart targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
targetId );
if ( targetView == null )
{
try
{
targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
targetId, null, IWorkbenchPage.VIEW_ACTIVATE );
}
catch ( PartInitException e )
{
}
}
if ( targetView instanceof BrowserView )
{
( ( BrowserView ) targetView ).select( getSelectedSearchResults()[0] );
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate( targetView );
}
}
}
/**
* {@inheritDoc}
*/
public String getText()
{
return Messages.getString( "OpenSearchResultAction.OpenResult" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OPEN_SEARCHRESULT );
}
/**
* {@inheritDoc}
*/
public String getCommandId()
{
return BrowserUIConstants.CMD_OPEN_SEARCH_RESULT;
}
/**
* {@inheritDoc}
*/
public boolean isEnabled()
{
return getSelectedSearchResults().length == 1;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ReloadSchemaAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ReloadSchemaAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.jobs.ReloadSchemaRunnable;
import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
/**
* This Action launches the schema reload.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ReloadSchemaAction extends BrowserAction
{
/**
* Creates a new instance of ReloadSchemaAction.
*/
public ReloadSchemaAction()
{
super();
}
/**
* {@inheritDoc}
*/
public void run()
{
IBrowserConnection connection = getConnectionToRefresh();
if ( connection != null )
{
new StudioBrowserJob( new ReloadSchemaRunnable( connection ) ).execute();
}
}
/**
* {@inheritDoc}
*/
public String getText()
{
return Messages.getString( "ReloadSchemaAction.ReloadSchema" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH );
}
/**
* {@inheritDoc}
*/
public String getCommandId()
{
return null;
}
/**
* {@inheritDoc}
*/
public boolean isEnabled()
{
return getConnectionToRefresh() != null;
}
private IBrowserConnection getConnectionToRefresh()
{
Connection[] connections = getSelectedConnections();
if ( connections.length != 1 )
{
return null;
}
Connection connection = connections[0];
if ( !connection.getConnectionWrapper().isConnected() )
{
return null;
}
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( connection );
return browserConnection;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSearchAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSearchAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.apache.directory.studio.ldapbrowser.ui.search.SearchPage;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
/**
* This Action opens the Search Dialog.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenSearchAction extends Action implements IWorkbenchWindowActionDelegate
{
/**
* Creates a new instance of OpenSearchAction.
*/
public OpenSearchAction()
{
super( Messages.getString( "OpenSearchAction.Search" ), Action.AS_PUSH_BUTTON ); //$NON-NLS-1$
super.setText( Messages.getString( "OpenSearchAction.Search" ) ); //$NON-NLS-1$
super.setToolTipText( Messages.getString( "OpenSearchAction.Search" ) ); //$NON-NLS-1$
super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_SEARCH ) );
super.setEnabled( true );
}
/**
* {@inheritDoc}
*/
public void run()
{
NewSearchUI.openSearchDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), SearchPage.getId() );
}
/**
* {@inheritDoc}
*/
public void init( IWorkbenchWindow window )
{
}
/**
* {@inheritDoc}
*/
public void run( IAction action )
{
this.run();
}
/**
* {@inheritDoc}
*/
public void selectionChanged( IAction action, ISelection selection )
{
}
/**
* {@inheritDoc}
*/
public void dispose()
{
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSchemaBrowserAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenSchemaBrowserAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.LdapSyntax;
import org.apache.directory.api.ldap.model.schema.MatchingRule;
import org.apache.directory.api.ldap.model.schema.ObjectClass;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.apache.directory.studio.ldapbrowser.ui.editors.schemabrowser.SchemaBrowserManager;
import org.eclipse.jface.resource.ImageDescriptor;
/**
* This Action opens the Schema Browser
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpenSchemaBrowserAction extends BrowserAction
{
/**
* None Mode
*/
public static final int MODE_NONE = 0;
/**
* Object Class Mode
*/
public static final int MODE_OBJECTCLASS = 10;
/**
* Attribute Type Mode
*/
public static final int MODE_ATTRIBUTETYPE = 20;
/**
* Equality Matching Rule Mode
*/
public static final int MODE_EQUALITYMATCHINGRULE = 30;
/**
* Substring Matching Rule Mode
*/
public static final int MODE_SUBSTRINGMATCHINGRULE = 31;
/**
* Ordering Matching Rule Mode
*/
public static final int MODE_ORDERINGMATCHINGRULE = 32;
/**
* Syntax Mode
*/
public static final int MODE_SYNTAX = 40;
protected int mode;
/**
* Creates a new instance of OpenSchemaBrowserAction.
*/
public OpenSchemaBrowserAction()
{
super();
this.mode = MODE_NONE;
}
/**
* Creates a new instance of OpenSchemaBrowserAction.
*
* @param mode
* the display mode
*/
public OpenSchemaBrowserAction( int mode )
{
super();
this.mode = mode;
}
/**
* {@inheritDoc}
*/
public void run()
{
if ( mode == MODE_NONE )
{
SchemaBrowserManager.setInput( getConnection(), null );
}
else if ( mode == MODE_OBJECTCLASS )
{
SchemaBrowserManager.setInput( getConnection(), getOcd() );
}
else if ( mode == MODE_ATTRIBUTETYPE )
{
SchemaBrowserManager.setInput( getConnection(), getAtd() );
}
else if ( mode == MODE_EQUALITYMATCHINGRULE )
{
SchemaBrowserManager.setInput( getConnection(), getEmrd() );
}
else if ( mode == MODE_SUBSTRINGMATCHINGRULE )
{
SchemaBrowserManager.setInput( getConnection(), getSmrd() );
}
else if ( mode == MODE_ORDERINGMATCHINGRULE )
{
SchemaBrowserManager.setInput( getConnection(), getOmrd() );
}
else if ( mode == MODE_SYNTAX )
{
SchemaBrowserManager.setInput( getConnection(), getLsd() );
}
else
{
SchemaBrowserManager.setInput( getConnection(), null );
}
}
/**
* {@inheritDoc}
*/
public String getText()
{
if ( mode == MODE_NONE )
{
return Messages.getString( "OpenSchemaBrowserAction.OpenSchemaBrowser" ); //$NON-NLS-1$
}
else if ( mode == MODE_OBJECTCLASS )
{
return Messages.getString( "OpenSchemaBrowserAction.ObjectDescription" ); //$NON-NLS-1$
}
else if ( mode == MODE_ATTRIBUTETYPE )
{
return Messages.getString( "OpenSchemaBrowserAction.AttributeDescription" ); //$NON-NLS-1$
}
else if ( mode == MODE_EQUALITYMATCHINGRULE )
{
return Messages.getString( "OpenSchemaBrowserAction.EqualityDescription" ); //$NON-NLS-1$
}
else if ( mode == MODE_SUBSTRINGMATCHINGRULE )
{
return Messages.getString( "OpenSchemaBrowserAction.SubstringDescription" ); //$NON-NLS-1$
}
else if ( mode == MODE_ORDERINGMATCHINGRULE )
{
return Messages.getString( "OpenSchemaBrowserAction.OrderingDescription" ); //$NON-NLS-1$
}
else if ( mode == MODE_SYNTAX )
{
return Messages.getString( "OpenSchemaBrowserAction.SyntaxDescription" ); //$NON-NLS-1$
}
else
{
return Messages.getString( "OpenSchemaBrowserAction.OpenSchemaBrowser" ); //$NON-NLS-1$
}
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
if ( mode == MODE_NONE )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
}
else if ( mode == MODE_OBJECTCLASS )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OCD );
}
else if ( mode == MODE_ATTRIBUTETYPE )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ATD );
}
else if ( mode == MODE_EQUALITYMATCHINGRULE )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_MRD_EQUALITY );
}
else if ( mode == MODE_SUBSTRINGMATCHINGRULE )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_MRD_SUBSTRING );
}
else if ( mode == MODE_ORDERINGMATCHINGRULE )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_MRD_ORDERING );
}
else if ( mode == MODE_SYNTAX )
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LSD );
}
else
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
}
}
/**
* {@inheritDoc}
*/
public String getCommandId()
{
return null;
}
/**
* {@inheritDoc}
*/
public boolean isEnabled()
{
if ( mode == MODE_NONE )
{
return getConnection() != null;
}
else if ( mode == MODE_OBJECTCLASS )
{
return getOcd() != null;
}
else if ( mode == MODE_ATTRIBUTETYPE )
{
return getAtd() != null;
}
else if ( mode == MODE_EQUALITYMATCHINGRULE )
{
return getEmrd() != null;
}
else if ( mode == MODE_SUBSTRINGMATCHINGRULE )
{
return getSmrd() != null;
}
else if ( mode == MODE_ORDERINGMATCHINGRULE )
{
return getOmrd() != null;
}
else if ( mode == MODE_SYNTAX )
{
return getLsd() != null;
}
else
{
return false;
}
}
/**
* Gets the LDAP Syntax Description.
*
* @return
* the LDAP Syntax Description
*/
private LdapSyntax getLsd()
{
if ( getConnection() != null )
{
Schema schema = getConnection().getSchema();
AttributeType atd = getAtd();
if ( atd != null && SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) != null
&& schema.hasLdapSyntaxDescription( SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) ) )
{
return schema.getLdapSyntaxDescription( SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) );
}
}
return null;
}
/**
* Gets the Object Class Description.
*
* @return
* the Object Class Description
*/
private ObjectClass getOcd()
{
if ( getSelectedAttributes().length == 0 && getSelectedValues().length == 1
&& getSelectedValues()[0].getAttribute().isObjectClassAttribute() )
{
String ocdName = getSelectedValues()[0].getStringValue();
if ( ocdName != null
&& getSelectedValues()[0].getAttribute().getEntry().getBrowserConnection().getSchema()
.hasObjectClassDescription( ocdName ) )
{
return getSelectedValues()[0].getAttribute().getEntry().getBrowserConnection().getSchema()
.getObjectClassDescription( ocdName );
}
}
return null;
}
/**
* Gets the Attribute Type Description.
*
* @return
* the Attribute Type Description
*/
private AttributeType getAtd()
{
if ( ( getSelectedValues().length + getSelectedAttributes().length ) + getSelectedAttributeHierarchies().length == 1 )
{
AttributeType atd = null;
if ( getSelectedValues().length == 1 )
{
atd = getSelectedValues()[0].getAttribute().getAttributeTypeDescription();
}
else if ( getSelectedAttributes().length == 1 )
{
atd = getSelectedAttributes()[0].getAttributeTypeDescription();
}
else if ( getSelectedAttributeHierarchies().length == 1 && getSelectedAttributeHierarchies()[0].size() == 1 )
{
atd = getSelectedAttributeHierarchies()[0].getAttribute().getAttributeTypeDescription();
}
return atd;
}
return null;
}
/**
* Gets the connection.
*
* @return the connection
*/
private IBrowserConnection getConnection()
{
if ( ( getSelectedValues().length + getSelectedAttributes().length ) + getSelectedAttributeHierarchies().length == 1 )
{
IBrowserConnection connection = null;
if ( getSelectedValues().length == 1 )
{
connection = getSelectedValues()[0].getAttribute().getEntry().getBrowserConnection();
}
else if ( getSelectedAttributes().length == 1 )
{
connection = getSelectedAttributes()[0].getEntry().getBrowserConnection();
}
else if ( getSelectedAttributeHierarchies().length == 1 && getSelectedAttributeHierarchies()[0].size() == 1 )
{
connection = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getBrowserConnection();
}
return connection;
}
else if ( getSelectedConnections().length == 1 )
{
Connection connection = getSelectedConnections()[0];
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( connection );
return browserConnection;
}
else if ( getSelectedEntries().length == 1 )
{
return getSelectedEntries()[0].getBrowserConnection();
}
else if ( getSelectedSearchResults().length == 1 )
{
return getSelectedSearchResults()[0].getEntry().getBrowserConnection();
}
else if ( getSelectedBookmarks().length == 1 )
{
return getSelectedBookmarks()[0].getBrowserConnection();
}
else if ( getSelectedSearches().length == 1 )
{
return getSelectedSearches()[0].getBrowserConnection();
}
return null;
}
/**
* Gets the Equality Matching Rule Description.
*
* @return
* the Equality Matching Rule Description
*/
private MatchingRule getEmrd()
{
if ( getConnection() != null )
{
Schema schema = getConnection().getSchema();
AttributeType atd = getAtd();
if ( atd != null
&& SchemaUtils.getEqualityMatchingRuleNameOrNumericOidTransitive( atd, schema ) != null
&& schema.hasLdapSyntaxDescription( SchemaUtils.getEqualityMatchingRuleNameOrNumericOidTransitive( atd,
schema ) ) )
{
return schema.getMatchingRuleDescription( SchemaUtils
.getEqualityMatchingRuleNameOrNumericOidTransitive( atd, schema ) );
}
}
return null;
}
/**
* Gets the Substring Matching Rule Description.
*
* @return
* the Substring Matching Rule Description
*/
private MatchingRule getSmrd()
{
if ( getConnection() != null )
{
Schema schema = getConnection().getSchema();
AttributeType atd = getAtd();
if ( atd != null
&& SchemaUtils.getSubstringMatchingRuleNameOrNumericOidTransitive( atd, schema ) != null
&& schema.hasLdapSyntaxDescription( SchemaUtils.getSubstringMatchingRuleNameOrNumericOidTransitive(
atd, schema ) ) )
{
return schema.getMatchingRuleDescription( SchemaUtils
.getSubstringMatchingRuleNameOrNumericOidTransitive( atd, schema ) );
}
}
return null;
}
/**
* Gets the Ordering Matching Rule Description.
*
* @return
* the Ordering Matching Rule Description
*/
private MatchingRule getOmrd()
{
if ( getConnection() != null )
{
Schema schema = getConnection().getSchema();
AttributeType atd = getAtd();
if ( atd != null
&& SchemaUtils.getOrderingMatchingRuleNameOrNumericOidTransitive( atd, schema ) != null
&& schema.hasLdapSyntaxDescription( SchemaUtils.getOrderingMatchingRuleNameOrNumericOidTransitive( atd,
schema ) ) )
{
return schema.getMatchingRuleDescription( SchemaUtils
.getOrderingMatchingRuleNameOrNumericOidTransitive( atd, schema ) );
}
}
return null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportConnectionsAction.java | plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportConnectionsAction.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.studio.ldapbrowser.ui.actions;
import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
import org.apache.directory.studio.ldapbrowser.ui.wizards.ImportConnectionsWizard;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
* This Action launches the Import Connections Wizard.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ImportConnectionsAction extends BrowserAction
{
/**
* Creates a new instance of ImportConnectionsAction.
*/
public ImportConnectionsAction()
{
super();
}
/**
* {@inheritDoc}
*/
public void run()
{
ImportConnectionsWizard wizard = new ImportConnectionsWizard();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
wizard.init( window.getWorkbench(), ( IStructuredSelection ) window.getSelectionService().getSelection() );
WizardDialog dialog = new WizardDialog( getShell(), wizard );
dialog.setBlockOnOpen( true );
dialog.create();
dialog.open();
}
/**
* {@inheritDoc}
*/
public String getText()
{
return Messages.getString( "ImportConnectionsAction.ImportConnections" ); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public ImageDescriptor getImageDescriptor()
{
return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_CONNECTIONS );
}
/**
* {@inheritDoc}
*/
public String getCommandId()
{
return null;
}
/**
* {@inheritDoc}
*/
public boolean isEnabled()
{
return true;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.