You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/02 18:14:28 UTC
svn commit: r1670931 [2/8] - in /directory/studio/trunk:
features/openldap.feature/ plugins/ plugins/openldap.acl.editor/
plugins/openldap.acl.editor/resources/
plugins/openldap.acl.editor/resources/icons/
plugins/openldap.acl.editor/resources/template...
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAccessLevelDialog.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,574 @@
+/*
+ * 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;
+
+
+/**
+ * TODO
+ */
+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 != null ) && ( 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
+ {
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/dialogs/OpenLdapAclDialog.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,297 @@
+/*
+ * 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.
+ */
+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 precendence flag */
+ private boolean hasPrecedence;
+
+ /** The precedence spinner */
+ private Spinner precedenceSpinner;
+
+ /** The precendence flag */
+ private int precedenceValue;
+
+ /** The tab folder composite */
+ private OpenLdapAclTabFolderComposite tabFolderComposite;
+
+
+ /**
+ * 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;
+ }
+
+
+ /**
+ * @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 );
+ }
+ }
+
+
+ /**
+ * @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
+ createPrecedenceGroup( composite );
+ createTabFolderComposite( composite );
+
+ // Setting default focus on the composite
+ composite.setFocus();
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Creates the precedence group.
+ *
+ * @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
+ hasPrecedence = context.isHasPrecedence();
+ precedenceValue = context.getPrecedenceValue();
+ if ( precedenceValue <= 0 )
+ {
+ precedenceValue = 1;
+ }
+
+ // Precedence checkbox
+ precedenceCheckbox = new Button( precendenceGroup, SWT.CHECK );
+ precedenceCheckbox.setText( "Precedence:" ); //$NON-NLS-1$
+ precedenceCheckbox.setSelection( hasPrecedence );
+ precedenceCheckbox.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ hasPrecedence = precedenceCheckbox.getSelection();
+ precedenceSpinner.setEnabled( hasPrecedence );
+ }
+ } );
+
+ // Precedence spinner
+ precedenceSpinner = new Spinner( precendenceGroup, SWT.BORDER );
+ precedenceSpinner.setMinimum( 1 );
+ precedenceSpinner.setDigits( 0 );
+ precedenceSpinner.setEnabled( hasPrecedence );
+ precedenceSpinner.setSelection( precedenceValue );
+ precedenceSpinner.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, true, false ) );
+ precedenceSpinner.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ precedenceValue = precedenceSpinner.getSelection();
+ }
+ } );
+ }
+
+
+ /**
+ * Creates the tab folder composite.
+ *
+ * @param parent the parent composite
+ */
+ private void createTabFolderComposite( Composite parent )
+ {
+ // Creating the tab folder composite
+ tabFolderComposite = new OpenLdapAclTabFolderComposite( parent, SWT.NONE );
+ tabFolderComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
+
+ // Setting context and initial value
+ if ( context != null )
+ {
+ tabFolderComposite.setContext( context );
+ tabFolderComposite.setInput( context.getAclValue() );
+ }
+ }
+
+
+ /**
+ * Gets the ACL value.
+ *
+ * @return the ACL value
+ */
+ public String getAclValue()
+ {
+ return aclValue;
+ }
+
+
+ /**
+ * @return the precedence value
+ */
+ public int getPrecedenceValue()
+ {
+ return precedenceValue;
+ }
+
+
+ /**
+ * @return whether precedence is used or not
+ */
+ public boolean isHasPrecedence()
+ {
+ return hasPrecedence;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/editor/OpenLdapAclValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/editor/OpenLdapAclValueEditor.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/editor/OpenLdapAclValueEditor.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/editor/OpenLdapAclValueEditor.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,194 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+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.IValue;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+import org.apache.directory.studio.openldap.config.acl.OpenLdapAclValueWithContext;
+import org.apache.directory.studio.openldap.config.acl.dialogs.OpenLdapAclDialog;
+
+
+/**
+ * This class implements a value editor that handle OpenLDAP ACL string values
+ * in a dialog.
+ */
+public class OpenLdapAclValueEditor extends AbstractDialogStringValueEditor
+{
+ /** The pattern used to match a precedence prefix ("{int}") */
+ private static final String PRECEDENCE_PATTERN = "^\\{[0-9]+\\}.*$";
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+
+ if ( value != null && value instanceof OpenLdapAclValueWithContext )
+ {
+ OpenLdapAclValueWithContext context = ( OpenLdapAclValueWithContext ) value;
+
+ OpenLdapAclDialog dialog = new OpenLdapAclDialog( shell, context );
+ if ( dialog.open() == OpenLdapAclDialog.OK && !"".equals( dialog.getAclValue() ) ) //$NON-NLS-1$
+ {
+ if ( dialog.isHasPrecedence() )
+ {
+ String aclValue = "{" + dialog.getPrecedenceValue() + "}" + dialog.getAclValue();
+ setValue( aclValue );
+ }
+ else
+ {
+ String aclValue = dialog.getAclValue();
+ setValue( aclValue );
+ }
+
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Returns a ACIItemValueContext with the connection
+ * and entry of the attribute hierarchy and an empty value if there
+ * are no values in attributeHierarchy.
+ *
+ * Returns a ACIItemValueContext with the connection
+ * and entry of the attribute hierarchy and a value if there is
+ * one value in attributeHierarchy.
+ *
+ * @param attributeHierarchy the attribute hierarchy
+ *
+ * @return the raw value
+ */
+ public Object getRawValue( AttributeHierarchy attributeHierarchy )
+ {
+ if ( attributeHierarchy == null )
+ {
+ return null;
+ }
+ else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
+ {
+ IEntry entry = attributeHierarchy.getAttribute().getEntry();
+ IBrowserConnection connection = entry.getBrowserConnection();
+ return new OpenLdapAclValueWithContext( connection, entry, false, -1, "" ); //$NON-NLS-1$
+ }
+ else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 )
+ {
+ IEntry entry = attributeHierarchy.getAttribute().getEntry();
+ IBrowserConnection connection = entry.getBrowserConnection();
+ String value = getDisplayValue( attributeHierarchy );
+ int precedence = getPrecedence( value );
+ boolean hasPrecedence = ( precedence != -1 );
+ String aclValue = getStrippedAclValue( value );
+ return new OpenLdapAclValueWithContext( connection, entry, hasPrecedence, precedence, aclValue );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Returns a ACIItemValueContext with the connection,
+ * entry and string value of the given value.
+ *
+ * @param value the value
+ *
+ * @return the raw value
+ */
+ public Object getRawValue( IValue value )
+ {
+ Object o = super.getRawValue( value );
+ if ( o != null && o instanceof String )
+ {
+ IEntry entry = value.getAttribute().getEntry();
+ IBrowserConnection connection = entry.getBrowserConnection();
+ String v = ( String ) o;
+ int precedence = getPrecedence( v );
+ boolean hasPrecedence = ( precedence != -1 );
+ String aclValue = getStrippedAclValue( v );
+ return new OpenLdapAclValueWithContext( connection, entry, hasPrecedence, precedence, aclValue );
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets the precedence value (or -1 if none is found).
+ *
+ * @param s the string
+ * @return the precedence value (or -1 if none is found).
+ */
+ public int getPrecedence( String s )
+ {
+ // Checking if the acl contains precedence information ("{int}")
+ if ( s.matches( PRECEDENCE_PATTERN ) )
+ {
+ // Getting the index of the starting and closing curly brackets
+ int indexOfStartingCurlyBracket = s.indexOf( '{' );
+ int indexOfClosingCurlyBracket = s.indexOf( '}' );
+
+ try
+ {
+ // Returning the precedence string as an int
+ return Integer.parseInt( s.substring( indexOfStartingCurlyBracket + 1, indexOfClosingCurlyBracket ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ return -1;
+ }
+ }
+
+ return -1;
+ }
+
+
+ /**
+ * Gets the stripped ACL value (without precedence).
+ *
+ * @param s the string
+ * @return the stripped ACL value (without precedence).
+ */
+ public String getStrippedAclValue( String s )
+ {
+ // Checking if the acl contains precedence information ("{int}")
+ if ( s.matches( PRECEDENCE_PATTERN ) )
+ {
+ // Getting the index of the closing curly bracket
+ int indexOfClosingCurlyBracket = s.indexOf( '}' );
+
+ // Returning the ACL value
+ return s.substring( indexOfClosingCurlyBracket + 1 );
+ }
+
+ return s;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages.properties?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages.properties (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages.properties Thu Apr 2 16:14:26 2015
@@ -0,0 +1,18 @@
+# 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.
+
+OpenLdapAclEditorPlugin.UnableGetPluginProperties=Unable to get the plugin properties.
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_de.properties?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_de.properties (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_de.properties Thu Apr 2 16:14:26 2015
@@ -0,0 +1,18 @@
+# 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.
+
+OpenLdapAclEditorPlugin.UnableGetPluginProperties=Plugin Eigenschaften k\u00F6nnen nicht gefunden werden.
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_fr.properties?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_fr.properties (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/messages_fr.properties Thu Apr 2 16:14:26 2015
@@ -0,0 +1,18 @@
+# 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.
+
+OpenLdapAclEditorPlugin.UnableGetPluginProperties=Impossible de r\u00E9cup\u00E9rer les propri\u00E9t\u00E9s du plugin
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClause.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClause.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClause.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClause.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,94 @@
+/*
+ * 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.model;
+
+
+public abstract class AbstractAclWhoClause implements AclWhoClause
+{
+ /** The access level */
+ protected AclAccessLevel accessLevel;
+
+ /** The control */
+ protected AclControlEnum control;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AclAccessLevel getAccessLevel()
+ {
+ return accessLevel;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AclControlEnum getControl()
+ {
+ return control;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setAccessLevel( AclAccessLevel accessLevel )
+ {
+ this.accessLevel = accessLevel;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setControl( AclControlEnum control )
+ {
+ this.control = control;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Access Level
+ if ( accessLevel != null )
+ {
+ sb.append( accessLevel );
+ }
+
+ // Control
+ if ( control != null )
+ {
+ if ( sb.length() > 0 )
+ {
+ sb.append( " " );
+ }
+
+ sb.append( control );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClauseCryptoStrength.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClauseCryptoStrength.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClauseCryptoStrength.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AbstractAclWhoClauseCryptoStrength.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,52 @@
+/*
+ * 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.model;
+
+
+/**
+ * An abstract class for all Cryptographic Strength subclasses.
+ */
+public abstract class AbstractAclWhoClauseCryptoStrength extends AbstractAclWhoClause
+{
+ /** The strength */
+ protected int strength;
+
+
+ /**
+ * Sets the cryptographic strength.
+ *
+ * @return the strength.
+ */
+ public int getStrength()
+ {
+ return strength;
+ }
+
+
+ /**
+ * Sets the cryptographic strength.
+ *
+ * @param strength the strength
+ */
+ public void setStrength( int strength )
+ {
+ this.strength = strength;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevel.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevel.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevel.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevel.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,187 @@
+/*
+ * 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.model;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class AclAccessLevel
+{
+ /** The 'self' modifier' flag */
+ private boolean isSelf = false;
+
+ /** The level */
+ private AclAccessLevelLevelEnum level;
+
+ /** The privileges modifier */
+ private AclAccessLevelPrivModifierEnum privilegesModifier;
+
+ /** The privileges */
+ private List<AclAccessLevelPrivilegeEnum> privileges = new ArrayList<AclAccessLevelPrivilegeEnum>();
+
+
+ /**
+ * Adds a privilege.
+ *
+ * @param p the privilege to add
+ */
+ public void addPrivilege( AclAccessLevelPrivilegeEnum p )
+ {
+ privileges.add( p );
+ }
+
+
+ /**
+ * Adds a {@link Collection} of privileges.
+ *
+ * @param arg0 the privileges to add
+ */
+ public void addPrivileges( Collection<? extends AclAccessLevelPrivilegeEnum> c )
+ {
+ privileges.addAll( c );
+ }
+
+
+ /**
+ * Clears the list of privileges.
+ */
+ public void clearPrivileges()
+ {
+ privileges.clear();
+ }
+
+
+ /**
+ * Gets the level.
+ *
+ * @return the level
+ */
+ public AclAccessLevelLevelEnum getLevel()
+ {
+ return level;
+ }
+
+
+ /**
+ * Gets the privileges modifier.
+ *
+ * @return the privilegeModifier the privilege modifier
+ */
+ public AclAccessLevelPrivModifierEnum getPrivilegeModifier()
+ {
+ return privilegesModifier;
+ }
+
+
+ /**
+ * Gets the privileges.
+ *
+ * @return the privileges
+ */
+ public List<AclAccessLevelPrivilegeEnum> getPrivileges()
+ {
+ return privileges;
+ }
+
+
+ /**
+ * Gets the 'self' modifier' flag.
+ *
+ * @return the isSelf the 'self' modifier' flag
+ */
+ public boolean isSelf()
+ {
+ return isSelf;
+ }
+
+
+ /**
+ * Sets the level.
+ *
+ * @param level the level to set
+ */
+ public void setLevel( AclAccessLevelLevelEnum level )
+ {
+ this.level = level;
+ }
+
+
+ /**
+ * Sets the privileges modifier.
+ *
+ * @param privilegeModifier the privilegeModifier to set
+ */
+ public void setPrivilegeModifier( AclAccessLevelPrivModifierEnum privilegeModifier )
+ {
+ this.privilegesModifier = privilegeModifier;
+ }
+
+
+ /**
+ * Sets the 'self' modifier' flag.
+ *
+ * @param isSelf the 'self' modifier' flag to set
+ */
+ public void setSelf( boolean isSelf )
+ {
+ this.isSelf = isSelf;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Self
+ if ( isSelf )
+ {
+ sb.append( "self " );
+ }
+
+ // Level
+ if ( level != null )
+ {
+ sb.append( level.toString() );
+ }
+
+ // Privilege Modifier
+ if ( privilegesModifier != null )
+ {
+ sb.append( privilegesModifier.toString() );
+ }
+
+ // Privileges
+ if ( ( privileges != null ) && ( privileges.size() > 0 ) )
+ {
+ for ( AclAccessLevelPrivilegeEnum privlege : privileges )
+ {
+ sb.append( privlege );
+ }
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelLevelEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelLevelEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelLevelEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelLevelEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,64 @@
+/*
+ * 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.model;
+
+
+/**
+ * TODO AclAccessLevelLevelEnum.
+ */
+public enum AclAccessLevelLevelEnum
+{
+ MANAGE,
+ WRITE,
+ READ,
+ SEARCH,
+ COMPARE,
+ AUTH,
+ DISCLOSE,
+ NONE;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ 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.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivModifierEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivModifierEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivModifierEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivModifierEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,49 @@
+/*
+ * 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.model;
+
+
+/**
+ * TODO AclAccessLevelPrivModifierEnum.
+ */
+public enum AclAccessLevelPrivModifierEnum
+{
+ EQUAL,
+ PLUS,
+ MINUS;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case EQUAL:
+ return "=";
+ case PLUS:
+ return "+";
+ case MINUS:
+ return "-";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivilegeEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivilegeEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivilegeEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAccessLevelPrivilegeEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,61 @@
+/*
+ * 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.model;
+
+
+/**
+ * TODO AclAccessLevelPrivilegeEnum.
+ */
+public enum AclAccessLevelPrivilegeEnum
+{
+ MANAGE,
+ WRITE,
+ READ,
+ SEARCH,
+ DISCLOSE,
+ COMPARE,
+ AUTHENTICATION;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case MANAGE:
+ return "m";
+ case WRITE:
+ return "w";
+ case READ:
+ return "r";
+ case SEARCH:
+ return "s";
+ case DISCLOSE:
+ return "d";
+ case COMPARE:
+ return "c";
+ case AUTHENTICATION:
+ return "x";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclControlEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclControlEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclControlEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclControlEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,49 @@
+/*
+ * 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.model;
+
+
+/**
+ * TODO AclControlEnum.
+ */
+public enum AclControlEnum
+{
+ STOP,
+ CONTINUE,
+ BREAK;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case STOP:
+ return "stop";
+ case CONTINUE:
+ return "continue";
+ case BREAK:
+ return "break";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclItem.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclItem.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclItem.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclItem.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,181 @@
+/*
+ * 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.model;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * This class represents an ACL (Access Control List) Item for OpenLDAP.
+ */
+public class AclItem
+{
+ /** The {@link AclWhatClause} element */
+ private AclWhatClause whatClause;
+
+ /** The {@link AclWhoClause} elements */
+ private List<AclWhoClause> whoClauses = new ArrayList<AclWhoClause>();
+
+
+ /**
+ * Creates a new instance of AclItem.
+ */
+ public AclItem()
+ {
+ whatClause = new AclWhatClause();
+ }
+
+
+ /**
+ * Creates a new instance of AclItem.
+ *
+ * @param whatClause the {@link AclWhatClause} element
+ * @param whoClauses the {@link AclWhoClause} elements
+ */
+ public AclItem( AclWhatClause whatClause, List<AclWhoClause> whoClauses )
+ {
+ this.whatClause = whatClause;
+ this.whoClauses = whoClauses;
+ }
+
+
+ /**
+ * Gets the {@link AclWhatClause} element.
+ *
+ * @return the whatClauses the {@link AclWhatClause} element
+ */
+ public AclWhatClause getWhatClause()
+ {
+ return whatClause;
+ }
+
+
+ /**
+ * Gets the {@link AclWhoClause} elements.
+ *
+ * @return the whoClauses the {@link AclWhoClause} elements
+ */
+ public List<AclWhoClause> getWhoClauses()
+ {
+ return whoClauses;
+ }
+
+
+ /**
+ * Sets the {@link AclWhatClause} element.
+ *
+ * @param whatClause the {@link AclWhatClause} element to set
+ */
+ public void setWhatClause( AclWhatClause whatClause )
+ {
+ this.whatClause = whatClause;
+ }
+
+
+ /**
+ * Adds an {@link AclWhoClause} element.
+ *
+ * @param c the {@link AclWhoClause} element to add
+ */
+ public void addWhoClause( AclWhoClause c )
+ {
+ whoClauses.add( c );
+ }
+
+
+ /**
+ * Adds a {@link Collection} of {@link AclWhoClause} element.
+ *
+ * @param c the {@link Collection} of {@link AclWhoClause}
+ */
+ public void addAllWhoClause( Collection<? extends AclWhoClause> c )
+ {
+ whoClauses.addAll( c );
+ }
+
+
+ /**
+ * Clears all {@link AclWhoClause} elements.
+ */
+ public void clearWhoClause()
+ {
+ whoClauses.clear();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return toString( false );
+ }
+
+
+ public String toString( boolean prependAccess )
+ {
+ return toString( prependAccess, false );
+ }
+
+
+ public String toString( boolean prependAccess, boolean prettyPrint )
+ {
+
+ StringBuilder sb = new StringBuilder();
+
+ // Access (if needed)
+ if ( prependAccess )
+ {
+ sb.append( "access " );
+ }
+
+ // To
+ sb.append( "to " );
+
+ // What Clause
+ if ( whatClause != null )
+ {
+ sb.append( whatClause.toString() );
+ }
+
+ // Who Clauses
+ if ( ( whoClauses != null ) && ( whoClauses.size() > 0 ) )
+ {
+ for ( AclWhoClause whoClause : whoClauses )
+ {
+ if ( prettyPrint )
+ {
+ sb.append( "\n" );
+ }
+ else
+ {
+ sb.append( " " );
+ }
+ sb.append( "by " );
+ sb.append( whoClause.toString() );
+ }
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClause.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClause.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClause.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClause.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,208 @@
+/*
+ * 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.model;
+
+
+public class AclWhatClause
+{
+ /** The star (*) clause */
+ private AclWhatClauseStar starClause;
+
+ /** The DN clause */
+ private AclWhatClauseDn dnClause;
+
+ /** The filter clause */
+ private AclWhatClauseFilter filterClause;
+
+ /** The attributes clause */
+ private AclWhatClauseAttributes attributesClause;
+
+
+ public AclWhatClause()
+ {
+ }
+
+
+ public AclWhatClause( AclWhatClauseStar starClause, AclWhatClauseDn dnClause, AclWhatClauseFilter filterClause,
+ AclWhatClauseAttributes attributesClause )
+ {
+ this.starClause = starClause;
+ this.dnClause = dnClause;
+ this.filterClause = filterClause;
+ this.attributesClause = attributesClause;
+ }
+
+
+ public AclWhatClause( AclWhatClauseStar starClause )
+ {
+ this.starClause = starClause;
+ }
+
+
+ public AclWhatClause( AclWhatClauseDn dnClause )
+ {
+ this.dnClause = dnClause;
+ }
+
+
+ public AclWhatClause( AclWhatClauseFilter filterClause )
+ {
+ this.filterClause = filterClause;
+ }
+
+
+ public AclWhatClause( AclWhatClauseAttributes attributesClause )
+ {
+ this.attributesClause = attributesClause;
+ }
+
+
+ /**
+ * @return the attributesClause
+ */
+ public AclWhatClauseAttributes getAttributesClause()
+ {
+ return attributesClause;
+ }
+
+
+ /**
+ * @return the dnClause
+ */
+ public AclWhatClauseDn getDnClause()
+ {
+ return dnClause;
+ }
+
+
+ /**
+ * @return the filterClause
+ */
+ public AclWhatClauseFilter getFilterClause()
+ {
+ return filterClause;
+ }
+
+
+ /**
+ * @return the starClause
+ */
+ public AclWhatClauseStar getStarClause()
+ {
+ return starClause;
+ }
+
+
+ /**
+ * @param attributesClause the attributesClause to set
+ */
+ public void setAttributesClause( AclWhatClauseAttributes attributesClause )
+ {
+ this.attributesClause = attributesClause;
+ }
+
+
+ /**
+ * @param dnClause the dnClause to set
+ */
+ public void setDnClause( AclWhatClauseDn dnClause )
+ {
+ this.dnClause = dnClause;
+ }
+
+
+ /**
+ * @param filterClause the filterClause to set
+ */
+ public void setFilterClause( AclWhatClauseFilter filterClause )
+ {
+ this.filterClause = filterClause;
+ }
+
+
+ /**
+ * @param starClause the starClause to set
+ */
+ public void setStarClause( AclWhatClauseStar starClause )
+ {
+ this.starClause = starClause;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ boolean isFirst = true;
+
+ // Star (*) clause
+ if ( starClause != null )
+ {
+ if ( !isFirst )
+ {
+ sb.append( " " );
+ }
+
+ isFirst = false;
+ sb.append( starClause.toString() );
+ }
+
+ // DN clause
+ if ( dnClause != null )
+ {
+ if ( !isFirst )
+ {
+ sb.append( " " );
+ }
+
+ isFirst = false;
+ sb.append( dnClause.toString() );
+ }
+
+ // Filter clause
+ if ( filterClause != null )
+ {
+ if ( !isFirst )
+ {
+ sb.append( " " );
+ }
+
+ isFirst = false;
+ sb.append( filterClause.toString() );
+ }
+
+ // Attributes clause
+ if ( attributesClause != null )
+ {
+ if ( !isFirst )
+ {
+ sb.append( " " );
+ }
+
+ isFirst = false;
+ sb.append( attributesClause.toString() );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,100 @@
+/*
+ * 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.model;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class AclWhatClauseAttributes
+{
+ /** The attributes list */
+ private List<String> attributes = new ArrayList<String>();
+
+
+ /**
+ * Gets the attributes list.
+ *
+ * @return the attributes list
+ */
+ public List<String> getAttributes()
+ {
+ return attributes;
+ }
+
+
+ /**
+ * Adds an attribute.
+ *
+ * @param attribute the attribute to add
+ */
+ public void addAttribute( String attribute )
+ {
+ attributes.add( attribute );
+ }
+
+
+ /**
+ * Adds a {@link Collection} of attributes.
+ *
+ * @param c the {@link Collection} of attributes
+ */
+ public void addAllAttributes( Collection<String> c )
+ {
+ attributes.addAll( c );
+ }
+
+
+ /**
+ * Clears attributes.
+ */
+ public void clearAttributes()
+ {
+ attributes.clear();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Attrs
+ sb.append( "attrs=" );
+
+ // Attributes
+ if ( ( attributes != null ) && ( attributes.size() > 0 ) )
+ {
+ for ( String attribute : attributes )
+ {
+ sb.append( attribute );
+ sb.append( "," );
+ }
+
+ sb.deleteCharAt( sb.length() - 1 );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDn.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDn.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDn.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDn.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,104 @@
+/*
+ * 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.model;
+
+
+/**
+ * TODO AclWhatClauseDn.
+ */
+public class AclWhatClauseDn
+{
+ /** The type */
+ private AclWhatClauseDnTypeEnum type;
+
+ /** The pattern */
+ private String pattern;
+
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public AclWhatClauseDnTypeEnum getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Sets the type.
+ *
+ * @param type the type to set
+ */
+ public void setType( AclWhatClauseDnTypeEnum type )
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * Gets the pattern.
+ *
+ * @return the pattern
+ */
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+
+ /**
+ * Sets the pattern
+ *
+ * @param pattern the pattern to set
+ */
+ public void setPattern( String pattern )
+ {
+ this.pattern = pattern;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // DN
+ sb.append( "dn" );
+
+ // Type
+ if ( type != null )
+ {
+ sb.append( "." );
+ sb.append( type );
+ }
+
+ // Pattern
+ sb.append( '=' );
+ sb.append( '"' );
+ sb.append( pattern );
+ sb.append( '"' );
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDnTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDnTypeEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDnTypeEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseDnTypeEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,58 @@
+/*
+ * 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.model;
+
+
+/**
+ * This enum contains all possible values for the type of a DN What Clause.
+ */
+public enum AclWhatClauseDnTypeEnum
+{
+ REGEX,
+ BASE,
+ EXACT,
+ ONE,
+ SUBTREE,
+ CHILDREN;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case REGEX:
+ return "regex";
+ case BASE:
+ return "base";
+ case EXACT:
+ return "exact";
+ case ONE:
+ return "one";
+ case SUBTREE:
+ return "subtree";
+ case CHILDREN:
+ return "children";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,29 @@
+/*
+ * 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.model;
+
+
+public enum AclWhatClauseEnum
+{
+ STAR,
+ DN,
+ ATTRIBUTES,
+ FILTER
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseFilter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseFilter.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseFilter.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseFilter.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,63 @@
+/*
+ * 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.model;
+
+
+public class AclWhatClauseFilter
+{
+ /** The filter */
+ private String filter;
+
+
+ /**
+ * Gets the filter.
+ *
+ * @return the filter
+ */
+ public String getFilter()
+ {
+ return filter;
+ }
+
+
+ /**
+ * Sets the filter.
+ *
+ * @param filter the filter to set
+ */
+ public void setFilter( String filter )
+ {
+ this.filter = filter;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "filter=" );
+ sb.append( filter );
+
+ return sb.toString();
+ }
+}