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 [3/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/model/AclWhatClauseStar.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/AclWhatClauseStar.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseStar.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseStar.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,32 @@
+/*
+ * 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 AclWhatClauseStar
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "*";
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClause.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/AclWhoClause.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClause.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClause.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,55 @@
+/*
+ * 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 interface AclWhoClause
+{
+ /**
+ * Gets the access level.
+ *
+ * @return the access level
+ */
+ public AclAccessLevel getAccessLevel();
+
+
+ /**
+ * Gets the control.
+ *
+ * @return the control
+ */
+ public AclControlEnum getControl();
+
+
+ /**
+ * Sets access level.
+ *
+ * @param accessLevel the access level
+ */
+ public void setAccessLevel( AclAccessLevel accessLevel );
+
+
+ /**
+ * Sets control.
+ *
+ * @param accessLevel the control
+ */
+ public void setControl( AclControlEnum control );
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseAnonymous.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/AclWhoClauseAnonymous.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseAnonymous.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseAnonymous.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseAnonymous extends AbstractAclWhoClause
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "anonymous" );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDn.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/AclWhoClauseDn.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDn.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDn.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,133 @@
+/*
+ * 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 AclWhoClauseDn extends AbstractAclWhoClause
+{
+ /** The type */
+ private AclWhoClauseDnTypeEnum type = AclWhoClauseDnTypeEnum.BASE;
+
+ /** The modifier */
+ private AclWhoClauseDnModifierEnum modifier;
+
+ /** The pattern */
+ private String pattern;
+
+
+ /**
+ * Gets the modifier.
+ *
+ * @return the modifier
+ */
+ public AclWhoClauseDnModifierEnum getModifier()
+ {
+ return modifier;
+ }
+
+
+ /**
+ * Gets the pattern.
+ *
+ * @return the pattern
+ */
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public AclWhoClauseDnTypeEnum getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Sets the modifier.
+ *
+ * @param modifier the modifier
+ */
+ public void setModifier( AclWhoClauseDnModifierEnum modifier )
+ {
+ this.modifier = modifier;
+ }
+
+
+ /**
+ * Sets the pattern
+ *
+ * @param pattern the pattern to set
+ */
+ public void setPattern( String pattern )
+ {
+ this.pattern = pattern;
+ }
+
+
+ /**
+ * Sets the type.
+ *
+ * @param type the type to set
+ */
+ public void setType( AclWhoClauseDnTypeEnum type )
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // DN
+ sb.append( "dn" );
+
+ // Type
+ if ( type != null )
+ {
+ sb.append( "." );
+ sb.append( type );
+ }
+
+ // Modifier
+ if ( modifier != null )
+ {
+ sb.append( "," );
+ sb.append( modifier );
+ }
+
+ // 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/AclWhoClauseDnAttr.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/AclWhoClauseDnAttr.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnAttr.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnAttr.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 AclWhoClauseDnAttr extends AbstractAclWhoClause
+{
+ /** The attribute */
+ private String attribute;
+
+
+ /**
+ * Gets the attribute.
+ *
+ * @return the attribute
+ */
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+
+ /**
+ * Sets the attribute.
+ *
+ * @param attribute the attribute
+ */
+ public void setAttribute( String attribute )
+ {
+ this.attribute = attribute;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "dnattr=" );
+ sb.append( attribute );
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnModifierEnum.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/AclWhoClauseDnModifierEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnModifierEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnModifierEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,44 @@
+/*
+ * 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 modifier of a DN Who Clause.
+ */
+public enum AclWhoClauseDnModifierEnum
+{
+ EXPAND;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case EXPAND:
+ return "expand";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnTypeEnum.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/AclWhoClauseDnTypeEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnTypeEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseDnTypeEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,91 @@
+/*
+ * 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 Who Clause.
+ */
+public enum AclWhoClauseDnTypeEnum
+{
+ REGEX,
+ BASE,
+ EXACT,
+ ONE,
+ SUBTREE,
+ CHILDREN,
+ LEVEL;
+
+ /** The level*/
+ private int level = -1;
+
+
+ /**
+ * Gets the level.
+ * <p>
+ * Only useful for the 'LEVEL' enum type.
+ *
+ * @return the level
+ */
+ public int getLevel()
+ {
+ return level;
+ }
+
+
+ /**
+ * Sets the level.
+ * <p>
+ * Only useful for the 'LEVEL' enum type.
+ *
+ * @param level the level
+ */
+ public void setLevel( int level )
+ {
+ this.level = level;
+ }
+
+
+ /**
+ * {@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";
+ case LEVEL:
+ return "level{" + level + "}";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseEnum.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/AclWhoClauseEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,92 @@
+/*
+ * 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 AclWhoClauseEnum
+{
+ STAR,
+ ANONYMOUS,
+ USERS,
+ SELF,
+ DN,
+ DNATTR,
+ GROUP,
+ SASL_SSF,
+ SSF,
+ TLS_SSF,
+ TRANSPORT_SSF;
+
+ /**
+ * Gets the enum value associated with the given clause.
+ *
+ * @param clause the clause
+ * @return the enum value associated with the given clause.
+ */
+ public static AclWhoClauseEnum get( AclWhoClause clause )
+ {
+ if ( clause instanceof AclWhoClauseStar )
+ {
+ return STAR;
+ }
+ else if ( clause instanceof AclWhoClauseAnonymous )
+ {
+ return ANONYMOUS;
+ }
+ else if ( clause instanceof AclWhoClauseUsers )
+ {
+ return USERS;
+ }
+ else if ( clause instanceof AclWhoClauseSelf )
+ {
+ return SELF;
+ }
+ else if ( clause instanceof AclWhoClauseDn )
+ {
+ return DN;
+ }
+ else if ( clause instanceof AclWhoClauseDnAttr )
+ {
+ return DNATTR;
+ }
+ else if ( clause instanceof AclWhoClauseGroup )
+ {
+ return GROUP;
+ }
+ else if ( clause instanceof AclWhoClauseSaslSsf )
+ {
+ return SASL_SSF;
+ }
+ else if ( clause instanceof AclWhoClauseSsf )
+ {
+ return SSF;
+ }
+ else if ( clause instanceof AclWhoClauseTlsSsf )
+ {
+ return TLS_SSF;
+ }
+ else if ( clause instanceof AclWhoClauseSaslSsf )
+ {
+ return SASL_SSF;
+ }
+
+ return null;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseGroup.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/AclWhoClauseGroup.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseGroup.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseGroup.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,165 @@
+/*
+ * 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 AclWhoClauseGroup extends AbstractAclWhoClause
+{
+ /** The object class */
+ private String objectclass;
+
+ /** The attribute */
+ private String attribute;
+
+ /** The type */
+ private AclWhoClauseGroupTypeEnum type;
+
+ /** The pattern */
+ private String pattern;
+
+
+ /**
+ * Gets the attribute.
+ *
+ * @return the attribute
+ */
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+
+ /**
+ * Gets the objectclass.
+ *
+ * @return the objectclass
+ */
+ public String getObjectclass()
+ {
+ return objectclass;
+ }
+
+
+ /**
+ * Gets the pattern.
+ *
+ * @return the pattern
+ */
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public AclWhoClauseGroupTypeEnum getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Sets the attribute.
+ *
+ * @param attribute the attribute
+ */
+ public void setAttribute( String attribute )
+ {
+ this.attribute = attribute;
+ }
+
+
+ /**
+ * Sets the objectclass.
+ *
+ * @param objectclass the objectclass
+ */
+ public void setObjectclass( String objectclass )
+ {
+ this.objectclass = objectclass;
+ }
+
+
+ /**
+ * Sets the pattern
+ *
+ * @param pattern the pattern to set
+ */
+ public void setPattern( String pattern )
+ {
+ this.pattern = pattern;
+ }
+
+
+ /**
+ * Sets the type.
+ *
+ * @param type the type to set
+ */
+ public void setType( AclWhoClauseGroupTypeEnum type )
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // DN
+ sb.append( "group" );
+
+ // Object Class
+ if ( objectclass != null )
+ {
+ sb.append( "/" );
+ sb.append( objectclass );
+
+ // Attribute Name
+ if ( attribute != null )
+ {
+ sb.append( "/" );
+ sb.append( attribute );
+ }
+ }
+
+ // 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/AclWhoClauseGroupTypeEnum.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/AclWhoClauseGroupTypeEnum.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseGroupTypeEnum.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseGroupTypeEnum.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,46 @@
+/*
+ * 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 AclWhoClauseGroupTypeEnum.
+ */
+public enum AclWhoClauseGroupTypeEnum
+{
+ EXACT,
+ EXPAND;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case EXACT:
+ return "exact";
+ case EXPAND:
+ return "expand";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSaslSsf.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/AclWhoClauseSaslSsf.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSaslSsf.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSaslSsf.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseSaslSsf extends AbstractAclWhoClauseCryptoStrength
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "sasl_ssf=" + strength );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSelf.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/AclWhoClauseSelf.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSelf.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSelf.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseSelf extends AbstractAclWhoClause
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "self" );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSsf.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/AclWhoClauseSsf.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSsf.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseSsf.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,42 @@
+/*
+ * 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 AclWhoClauseSsf extends AbstractAclWhoClauseCryptoStrength
+{ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "ssf=" + strength );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseStar.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/AclWhoClauseStar.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseStar.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseStar.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseStar extends AbstractAclWhoClause
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "*" );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTlsSsf.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/AclWhoClauseTlsSsf.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTlsSsf.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTlsSsf.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseTlsSsf extends AbstractAclWhoClauseCryptoStrength
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "tls_ssf=" + strength );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTransportSsf.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/AclWhoClauseTransportSsf.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTransportSsf.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseTransportSsf.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseTransportSsf extends AbstractAclWhoClauseCryptoStrength
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "transport_ssf=" + strength );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseUsers.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/AclWhoClauseUsers.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseUsers.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhoClauseUsers.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,43 @@
+/*
+ * 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 AclWhoClauseUsers extends AbstractAclWhoClause
+{
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "users" );
+
+ String whoClauseToString = super.toString();
+ if ( whoClauseToString.length() > 0 )
+ {
+ sb.append( " " );
+ sb.append( whoClauseToString );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParser.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/OpenLdapAclParser.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParser.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParser.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,84 @@
+/*
+ * 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.io.StringReader;
+import java.text.ParseException;
+
+import antlr.CharBuffer;
+import antlr.LexerSharedInputState;
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A reusable wrapper around the antlr generated parser for an OpenLDAP ACL.
+ */
+public class OpenLdapAclParser
+{
+ /** the antlr generated parser being wrapped */
+ private AntlrAclParser parser;
+
+ /** the antlr generated lexer being wrapped */
+ private AntlrAclLexer lexer;
+
+
+ /**
+ * Creates an OpenLDAP ACL parser.
+ */
+ public OpenLdapAclParser()
+ {
+ this.lexer = new AntlrAclLexer( new StringReader( "" ) );
+ this.parser = new AntlrAclParser( lexer );
+ }
+
+
+ /**
+ * Parses an OpenLDAP ACL.
+ *
+ * @param s
+ * the string to be parsed
+ * @return the specification bean
+ * @throws ParseException
+ * if there are any recognition errors (bad syntax)
+ */
+ public synchronized AclItem parse( String s ) throws ParseException
+ {
+ try
+ {
+ LexerSharedInputState state = new LexerSharedInputState( new CharBuffer( new StringReader( s ) ) );
+ this.lexer.setInputState( state );
+ this.parser.getInputState().reset();
+
+ parser.parse();
+ return parser.getAclItem();
+ }
+ catch ( TokenStreamException e )
+ {
+ throw new ParseException( "Unable to read ACL: " + e.getMessage(), -1 );
+ }
+ catch ( RecognitionException e )
+ {
+ throw new ParseException( "Unable to read ACL: " + e.getMessage() + " - [Line:" + e.getLine()
+ + " - Column:" + e.getColumn() + "]", e.getColumn() );
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/AbstractRule.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/AbstractRule.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/AbstractRule.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/AbstractRule.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,179 @@
+/*
+ * 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.sourceeditor;
+
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+
+
+/**
+ * Rule to detect a "dn[.type[,modifier]]=" clause.
+ */
+public abstract class AbstractRule implements IPredicateRule
+{
+ /** The token */
+ protected IToken token;
+
+
+ /**
+ * Creates a new instance of AbstractRule.
+ *
+ * @param token the associated token
+ */
+ public AbstractRule( IToken token )
+ {
+ this.token = token;
+ }
+
+
+ public IToken getSuccessToken()
+ {
+ return token;
+ }
+
+
+ /**
+ * Checks if the given char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @param sequence the char sequence
+ * @return <code>true</code> if the scanner input matches the char sequence,
+ * <code>false</code> if not.
+ */
+ boolean matchCharSequence( ICharacterScanner scanner, char[] sequence )
+ {
+ for ( int i = 0; i < sequence.length; i++ )
+ {
+ int c = scanner.read();
+
+ if ( c != sequence[i] )
+ {
+ while ( i >= 0 )
+ {
+ scanner.unread();
+ i--;
+ }
+
+ return false;
+ }
+
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Checks if the given char sequence does not match the scanner input.
+ *
+ * @param scanner the scanner input
+ * @param sequence the char sequence
+ * @return <code>true</code> if the scanner input does not match the char sequence,
+ * <code>false</code> if it does.
+ */
+ boolean doesNotMatchCharSequence( ICharacterScanner scanner, char[] sequence )
+ {
+ return !matchCharSequence( scanner, sequence );
+ }
+
+
+ /**
+ * Checks if the char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the char,
+ * <code>false</code> if not.
+ */
+ boolean matchChar( ICharacterScanner scanner, char character )
+ {
+ int c = scanner.read();
+
+ if ( c == character )
+ {
+ return true;
+ }
+ else
+ {
+ scanner.unread();
+ return false;
+ }
+ }
+
+
+ /**
+ * Checks if EOF matches the scanner input.
+ *
+ * @return <code>true</code> if the scanner input matches EOF,
+ * <code>false</code> if not.
+ */
+ boolean matchEOF( ICharacterScanner scanner )
+ {
+ int c = scanner.read();
+
+ if ( c == ICharacterScanner.EOF )
+ {
+ return true;
+ }
+ else
+ {
+ scanner.unread();
+ return false;
+ }
+ }
+
+
+ /**
+ * Checks if the char does not match the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input does not match the char,
+ * <code>false</code> if it does.
+ */
+ boolean doesNotMatchChar( ICharacterScanner scanner, char character )
+ {
+ return !matchChar( scanner, character );
+ }
+
+
+ /**
+ * Checks if the '}' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '}' char,
+ * <code>false</code> if not.
+ */
+ boolean matchDigit( ICharacterScanner scanner )
+ {
+ int c = scanner.read();
+
+ if ( ( c >= '0' ) && ( c <= '9' ) )
+ {
+ return true;
+ }
+ else
+ {
+ scanner.unread();
+ return false;
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DialogContentAssistant.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DialogContentAssistant.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DialogContentAssistant.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DialogContentAssistant.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.sourceeditor;
+
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.contentassist.ComboContentAssistSubjectAdapter;
+import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
+import org.eclipse.jface.contentassist.TextContentAssistSubjectAdapter;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+
+/**
+ * This class implements the Content Assistant Dialog used in the ACI Item
+ * Source Editor for displaying proposals
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DialogContentAssistant extends SubjectControlContentAssistant implements FocusListener
+{
+ private Control control;
+
+ private IHandlerActivation handlerActivation;
+
+ private boolean possibleCompletionsVisible;
+
+
+ /**
+ * Creates a new instance of DialogContentAssistant.
+ */
+ public DialogContentAssistant()
+ {
+ super();
+ this.possibleCompletionsVisible = false;
+ }
+
+
+ /**
+ * Installs content assist support on the given subject.
+ *
+ * @param text
+ * the one who requests content assist
+ */
+ public void install( Text text )
+ {
+ this.control = text;
+ this.control.addFocusListener( this );
+ super.install( new TextContentAssistSubjectAdapter( text ) );
+ }
+
+
+ /**
+ * Installs content assist support on the given subject.
+ *
+ * @param combo
+ * the one who requests content assist
+ */
+ public void install( Combo combo )
+ {
+ this.control = combo;
+ this.control.addFocusListener( this );
+ super.install( new ComboContentAssistSubjectAdapter( combo ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void install( ITextViewer viewer )
+ {
+ this.control = viewer.getTextWidget();
+ this.control.addFocusListener( this );
+
+ // stop traversal (ESC) if popup is shown
+ this.control.addTraverseListener( new TraverseListener()
+ {
+ public void keyTraversed( TraverseEvent e )
+ {
+ if ( possibleCompletionsVisible )
+ {
+ e.doit = false;
+ }
+ }
+ } );
+
+ super.install( viewer );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void uninstall()
+ {
+ if ( this.handlerActivation != null )
+ {
+ IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+ IHandlerService.class );
+ handlerService.deactivateHandler( this.handlerActivation );
+ this.handlerActivation = null;
+ }
+
+ if ( this.control != null )
+ {
+ this.control.removeFocusListener( this );
+ }
+
+ super.uninstall();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Point restoreCompletionProposalPopupSize()
+ {
+ possibleCompletionsVisible = true;
+ return super.restoreCompletionProposalPopupSize();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String showPossibleCompletions()
+ {
+ possibleCompletionsVisible = true;
+ return super.showPossibleCompletions();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void possibleCompletionsClosed()
+ {
+ this.possibleCompletionsVisible = false;
+ super.possibleCompletionsClosed();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void focusGained( FocusEvent e )
+ {
+ IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+ IHandlerService.class );
+ if ( handlerService != null )
+ {
+ IHandler handler = new org.eclipse.core.commands.AbstractHandler()
+ {
+ public Object execute( ExecutionEvent event ) throws org.eclipse.core.commands.ExecutionException
+ {
+ showPossibleCompletions();
+ return null;
+ }
+ };
+ this.handlerActivation = handlerService.activateHandler(
+ ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void focusLost( FocusEvent e )
+ {
+ if ( this.handlerActivation != null )
+ {
+ IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+ IHandlerService.class );
+ handlerService.deactivateHandler( this.handlerActivation );
+ this.handlerActivation = null;
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DnRule.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DnRule.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DnRule.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/DnRule.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,290 @@
+/*
+ * 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.sourceeditor;
+
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * Rule to detect a "dn[.type[,modifier]]=" clause.
+ */
+public class DnRule extends AbstractRule
+{
+
+ /**
+ * The "dn" char sequence.
+ */
+ private static char[] DN_SEQUENCE = new char[]
+ { 'd', 'n' };
+
+ /**
+ * The array of the types char sequences
+ */
+ private static char[][] TYPES_SEQUENCES = new char[][]
+ {
+ new char[]
+ { 'r', 'e', 'g', 'e', 'x' },
+ new char[]
+ { 'b', 'a', 's', 'e' },
+ new char[]
+ { 'e', 'x', 'a', 'c', 't' },
+ new char[]
+ { 'o', 'n', 'e' },
+ new char[]
+ { 's', 'u', 'b', 't', 'r', 'e', 'e' },
+ new char[]
+ { 'c', 'h', 'i', 'l', 'd', 'r', 'e', 'n' }
+ };
+
+ /**
+ * The "expand" char sequence.
+ */
+ private static char[] EXPAND_SEQUENCE = new char[]
+ { 'e', 'x', 'p', 'a', 'n', 'd' };
+
+ /**
+ * The "level" char sequence.
+ */
+ private static char[] LEVEL_SEQUENCE = new char[]
+ { 'l', 'e', 'v', 'e', 'l' };
+
+
+ /**
+ * Creates a new instance of DnRule.
+ *
+ * @param token the associated token
+ */
+ public DnRule( IToken token )
+ {
+ super( token );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner, boolean resume )
+ {
+ // Looking for "dn"
+ if ( matchDn( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ // Looking for '.'
+ else if ( matchDot( scanner ) )
+ {
+ // Looking for one of the types
+ if ( matchType( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ // Looking for ','
+ else if ( matchComma( scanner ) )
+ {
+ // Looking for "expand"
+ if ( matchExpand( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+ }
+ }
+ // Looking for "level"
+ else if ( matchLevel( scanner ) )
+ {
+ // Looking for '{'
+ if ( matchOpenCurlyBracket( scanner ) )
+ {
+ // Looking for digits
+ boolean atLeastFoundOneDigit = false;
+ while ( matchDigit( scanner ) )
+ {
+ atLeastFoundOneDigit = true;
+ }
+
+ // Checking if we found at least one digit
+ // and the next char is '}'
+ if ( atLeastFoundOneDigit && ( matchCloseCurlyBracket( scanner ) ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return Token.UNDEFINED;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner )
+ {
+ return this.evaluate( scanner, false );
+ }
+
+
+ /**
+ * Checks if the "dn" char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the "dn" char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchDn( ICharacterScanner scanner )
+ {
+ return matchCharSequence( scanner, DN_SEQUENCE );
+ }
+
+
+ /**
+ * Checks if one of the types char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches one of the types char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchType( ICharacterScanner scanner )
+ {
+ for ( char[] typeSequence : TYPES_SEQUENCES )
+ {
+ if ( matchCharSequence( scanner, typeSequence ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Checks if the "expand" char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the "expand" char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchExpand( ICharacterScanner scanner )
+ {
+ return matchCharSequence( scanner, EXPAND_SEQUENCE );
+ }
+
+
+ /**
+ * Checks if the "level" char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the "level" char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchLevel( ICharacterScanner scanner )
+ {
+ return matchCharSequence( scanner, LEVEL_SEQUENCE );
+ }
+
+
+ /**
+ * Checks if the '.' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '.' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchDot( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '.' );
+ }
+
+
+ /**
+ * Checks if the ',' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the ',' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchComma( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, ',' );
+ }
+
+
+ /**
+ * Checks if the '=' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '=' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchEqual( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '=' );
+ }
+
+
+ /**
+ * Checks if the '{' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '{' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchOpenCurlyBracket( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '{' );
+ }
+
+
+ /**
+ * Checks if the '}' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '}' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchCloseCurlyBracket( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '}' );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/GroupRule.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/GroupRule.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/GroupRule.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/GroupRule.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,327 @@
+/*
+ * 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.sourceeditor;
+
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * Rule to detect a "group[/objectclass[/attrname]][.type]=" clause.
+ */
+public class GroupRule extends AbstractRule
+{
+
+ /**
+ * The "dn" char sequence.
+ */
+ private static char[] GROUP_SEQUENCE = new char[]
+ { 'g', 'r', 'o', 'u', 'p' };
+
+ /**
+ * The array of the types char sequences
+ */
+ private static char[][] TYPES_SEQUENCES = new char[][]
+ {
+ new char[]
+ { 'e', 'x', 'p', 'a', 'n', 'd' },
+ new char[]
+ { 'e', 'x', 'a', 'c', 't' }
+ };
+
+
+ /**
+ * Creates a new instance of GroupRule.
+ *
+ * @param token the associated token
+ */
+ public GroupRule( IToken token )
+ {
+ super( token );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner, boolean resume )
+ {
+ // Looking for "group"
+ if ( matchGroup( scanner ) )
+ {
+
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ // Looking for '/'
+ else if ( matchSlash( scanner ) )
+ {
+ // Going forward until we find a '=', '/' or '.' char
+ boolean atLeastFoundOneChar = false;
+ while ( doesNotMatchEqualSlashOrDot( scanner ) )
+ {
+ atLeastFoundOneChar = true;
+ }
+
+ // Checking if we found at least one char
+ if ( atLeastFoundOneChar )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ // Looking for '/'
+ else if ( matchSlash( scanner ) )
+ {
+ // Going forward until we find a '=' or '.' char
+ boolean atLeastFoundOneChar2 = false;
+ while ( doesNotMatchEqualOrDot( scanner ) )
+ {
+ atLeastFoundOneChar2 = true;
+ }
+
+ // Checking if we found at least one char
+ if ( atLeastFoundOneChar2 )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ // Looking for '.'
+ else if ( matchDot( scanner ) )
+ {
+ // Looking for one of the types
+ if ( matchType( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+ }
+ }
+ }
+ // Looking for '.'
+ else if ( matchDot( scanner ) )
+ {
+ // Looking for one of the types
+ if ( matchType( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+ }
+ }
+ }
+ // Looking for '.'
+ else if ( matchDot( scanner ) )
+ {
+ // Looking for one of the types
+ if ( matchType( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+ }
+ }
+
+ return Token.UNDEFINED;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner )
+ {
+ return this.evaluate( scanner, false );
+ }
+
+
+ /**
+ * Checks if the "group" char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the "group" char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchGroup( ICharacterScanner scanner )
+ {
+ return matchCharSequence( scanner, GROUP_SEQUENCE );
+ }
+
+
+ /**
+ * Checks if one of the types char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches one of the types char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchType( ICharacterScanner scanner )
+ {
+ for ( char[] typeSequence : TYPES_SEQUENCES )
+ {
+ if ( matchCharSequence( scanner, typeSequence ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Checks if the '{' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '{' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchSlash( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '/' );
+ }
+
+
+ /**
+ * Checks if the '.' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '.' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchDot( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '.' );
+ }
+
+
+ /**
+ * Checks if the '=' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '=' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchEqual( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '=' );
+ }
+
+
+ /**
+ * Checks if the '=', '/' or '.' chars don't match the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input don't match the '=', '/' or '.' char,
+ * <code>false</code> if it does.
+ */
+ private boolean doesNotMatchEqualSlashOrDot( ICharacterScanner scanner )
+ {
+ if ( matchEOF( scanner ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else if ( matchChar( scanner, '=' ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else if ( matchChar( scanner, '/' ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else if ( matchChar( scanner, '.' ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else
+ {
+ scanner.read();
+
+ return true;
+ }
+ }
+
+
+ /**
+ * Checks if the '=' or '.' chars don't match the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input don't match the '=' or '.' char,
+ * <code>false</code> if it does.
+ */
+ private boolean doesNotMatchEqualOrDot( ICharacterScanner scanner )
+ {
+ if ( matchEOF( scanner ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else if ( matchChar( scanner, '=' ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else if ( matchChar( scanner, '.' ) )
+ {
+ scanner.unread();
+
+ return false;
+ }
+ else
+ {
+ scanner.read();
+
+ return true;
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/KeywordEqualRule.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/KeywordEqualRule.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/KeywordEqualRule.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/KeywordEqualRule.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,132 @@
+/*
+ * 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.sourceeditor;
+
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * Rule to detect a "dn[.type[,modifier]]=" clause.
+ */
+public class KeywordEqualRule extends AbstractRule
+{
+ /**
+ * The array of the types char sequences
+ */
+ private static char[][] KEYWORDS_SEQUENCES = new char[][]
+ {
+ new char[]
+ { 'a', 't', 't', 'r', 's' },
+ new char[]
+ { 'a', 't', 't', 'r' },
+ new char[]
+ { 'd', 'n', 'a', 't', 't', 'r' },
+ new char[]
+ { 'f', 'i', 'l', 't', 'e', 'r' },
+ new char[]
+ { 's', 's', 'f' },
+ new char[]
+ { 's', 'a', 's', 'l', '_', 's', 's', 'f' },
+ new char[]
+ { 't', 'l', 's', '_', 's', 's', 'f' },
+ new char[]
+ { 't', 'r', 'a', 'n', 's', 'p', 'o', 'r', 't', '_', 's', 's', 'f' },
+ new char[]
+ { 's', 'a', 's', 's', '_', 's', 's', 'f' }
+ };
+
+
+ /**
+ * Creates a new instance of DnRule.
+ *
+ * @param token the associated token
+ */
+ public KeywordEqualRule( IToken token )
+ {
+ super( token );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner, boolean resume )
+ {
+ // Looking for any keyword
+ if ( matchKeyword( scanner ) )
+ {
+ // Looking for '='
+ if ( matchEqual( scanner ) )
+ {
+ // Token evaluation complete
+ return token;
+ }
+ }
+
+ return Token.UNDEFINED;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public IToken evaluate( ICharacterScanner scanner )
+ {
+ return this.evaluate( scanner, false );
+ }
+
+
+ /**
+ * Checks if one of the types char sequence matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches one of the types char sequence,
+ * <code>false</code> if not.
+ */
+ private boolean matchKeyword( ICharacterScanner scanner )
+ {
+ for ( char[] typeSequence : KEYWORDS_SEQUENCES )
+ {
+ if ( matchCharSequence( scanner, typeSequence ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Checks if the '=' char matches the scanner input.
+ *
+ * @param scanner the scanner input
+ * @return <code>true</code> if the scanner input matches the '=' char,
+ * <code>false</code> if not.
+ */
+ private boolean matchEqual( ICharacterScanner scanner )
+ {
+ return matchChar( scanner, '=' );
+ }
+}
Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/OpenLdapAclCodeScanner.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/OpenLdapAclCodeScanner.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/OpenLdapAclCodeScanner.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/sourceeditor/OpenLdapAclCodeScanner.java Thu Apr 2 16:14:26 2015
@@ -0,0 +1,147 @@
+/*
+ * 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.sourceeditor;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+import org.eclipse.jface.text.rules.WordRule;
+
+
+/**
+ * Scanner used to analyse ACI code. Allows syntax coloring.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OpenLdapAclCodeScanner extends RuleBasedScanner
+{
+ /** Keywords */
+ public static final String[] aclKeywords = new String[]
+ { "anonymous", //$NON-NLS-1$
+ "auth", //$NON-NLS-1$
+ "break", //$NON-NLS-1$
+ "by", //$NON-NLS-1$
+ "c", //$NON-NLS-1$
+ "compare", //$NON-NLS-1$
+ "continue", //$NON-NLS-1$
+ "disclose", //$NON-NLS-1$
+ "dnattr=", //$NON-NLS-1$
+ "entry", //$NON-NLS-1$
+ "m", //$NON-NLS-1$
+ "manage", //$NON-NLS-1$
+ "none", //$NON-NLS-1$
+ "one", //$NON-NLS-1$
+ "r", //$NON-NLS-1$
+ "read", //$NON-NLS-1$
+ "s", //$NON-NLS-1$
+ "search", //$NON-NLS-1$
+ "self", //$NON-NLS-1$
+ "ssf=", //$NON-NLS-1$
+ "stop", //$NON-NLS-1$
+ "to", //$NON-NLS-1$
+ "users", //$NON-NLS-1$
+ "x", //$NON-NLS-1$
+ "w", //$NON-NLS-1$
+ "write" }; //$NON-NLS-1$
+
+
+ /**
+ * Creates a new instance of AciCodeScanner.
+ *
+ * @param provider
+ * the provider
+ */
+ public OpenLdapAclCodeScanner( OpenLdapAclTextAttributeProvider provider )
+ {
+ List<IRule> rules = new ArrayList<IRule>();
+
+ IToken keyword = new Token( provider.getAttribute( OpenLdapAclTextAttributeProvider.KEYWORD_ATTRIBUTE ) );
+ IToken string = new Token( provider.getAttribute( OpenLdapAclTextAttributeProvider.STRING_ATTRIBUTE ) );
+ IToken undefined = new Token( provider.getAttribute( OpenLdapAclTextAttributeProvider.DEFAULT_ATTRIBUTE ) );
+
+ // Rules for Strings
+ rules.add( new SingleLineRule( "\"", "\"", string, '\0', true ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ rules.add( new SingleLineRule( "'", "'", string, '\0', true ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Generic rule for whitespaces
+ rules.add( new WhitespaceRule( new IWhitespaceDetector()
+ {
+ public boolean isWhitespace( char c )
+ {
+ return Character.isWhitespace( c );
+ }
+ } ) );
+
+ // Rules for specific not simple keywords
+ rules.add( new DnRule( keyword ) );
+ rules.add( new GroupRule( keyword ) );
+ rules.add( new KeywordEqualRule( keyword ) );
+ rules.add( new StarRule( keyword ) );
+
+ // If the word isn't in the List, returns undefined
+ WordRule wr = new WordRule( new OpenLdapAclWordDetector(), undefined );
+ rules.add( wr );
+
+ // Adding keywords
+ for ( String aclKeyword : aclKeywords )
+ {
+ wr.addWord( aclKeyword, keyword );
+ }
+
+ IRule[] param = new IRule[rules.size()];
+ rules.toArray( param );
+ setRules( param );
+ }
+
+ /**
+ * This class implements a word detector for ACI Items
+ *
+ * @author <a href="mailto:$dev@directory.apache.org">Apache Directory Project</a>
+ */
+ static class OpenLdapAclWordDetector implements IWordDetector
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isWordPart( char c )
+ {
+ return ( Character.isLetterOrDigit( c ) || c == '_' || c == '$' || c == '#' || c == '@' || c == '~'
+ || c == '.' || c == '?' || c == '*' || c == '!' );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isWordStart( char c )
+ {
+ return ( Character.isLetter( c ) || c == '.' || c == '_' || c == '?' || c == '$' );
+ }
+ }
+}