repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcAuditlogConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcAuditlogConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcAuditlogConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcAuditlogConfig extends OlcOverlayConfig { /** * Field for the 'olcAuditlogFile' attribute. */ @ConfigurationElement(attributeType = "olcAuditlogFile", version="2.4.0") private List<String> olcAuditlogFile = new ArrayList<>(); /** * Creates a new instance of OlcAuditlogConfig. */ public OlcAuditlogConfig() { super(); olcOverlay = "auditlog"; } /** * Creates a copy instance of OlcAuditlogConfig. * * @param o the initial object */ public OlcAuditlogConfig( OlcAuditlogConfig o ) { super( o ); olcAuditlogFile = new ArrayList<>( olcAuditlogFile ); } /** * @param strings */ public void addOlcAuditlogFile( String... strings ) { for ( String string : strings ) { olcAuditlogFile.add( string ); } } public void clearOlcAuditlogFile() { olcAuditlogFile.clear(); } /** * @return the olcAuditlogFile */ public List<String> getOlcAuditlogFile() { return olcAuditlogFile; } /** * @param olcAuditlogFile the olcAuditlogFile to set */ public void setOlcAuditlogFile( List<String> olcAuditlogFile ) { this.olcAuditlogFile = olcAuditlogFile; } /** * {@inheritDoc} */ @Override public OlcAuditlogConfig copy() { return new OlcAuditlogConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortMethodEnum.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortMethodEnum.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; /** * This enum represents the various values for the 'OlcValSortOverlay' sort method. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum OlcValSortMethodEnum { /** Enum value for 'alpha-ascend' */ ALPHA_ASCEND, /** Enum value for 'alpha-descend' */ ALPHA_DESCEND, /** Enum value for 'numeric-ascend' */ NUMERIC_ASCEND, /** Enum value for 'numeric-descend' */ NUMERIC_DESCEND; /** The constant string for 'alpha-ascend' */ private static final String ALPHA_ASCEND_STRING = "alpha-ascend"; /** The constant string for 'alpha-descend' */ private static final String ALPHA_DESCEND_STRING = "alpha-descend"; /** The constant string for 'numeric-ascend' */ private static final String NUMERIC_ASCEND_STRING = "numeric-ascend"; /** The constant string for 'numeric-descend' */ private static final String NUMERIC_DESCEND_STRING = "numeric-descend"; /** * Gets the associated enum element. * * @param s the string * @return the associated enum element */ public static OlcValSortMethodEnum fromString( String s ) { if ( ALPHA_ASCEND_STRING.equalsIgnoreCase( s ) ) { return ALPHA_ASCEND; } else if ( ALPHA_DESCEND_STRING.equalsIgnoreCase( s ) ) { return ALPHA_DESCEND; } else if ( NUMERIC_ASCEND_STRING.equalsIgnoreCase( s ) ) { return NUMERIC_ASCEND; } else if ( NUMERIC_DESCEND_STRING.equalsIgnoreCase( s ) ) { return NUMERIC_DESCEND; } return null; } /** * {@inheritDoc} */ @Override public String toString() { switch ( this ) { case ALPHA_ASCEND: return ALPHA_ASCEND_STRING; case ALPHA_DESCEND: return ALPHA_DESCEND_STRING; case NUMERIC_ASCEND: return NUMERIC_ASCEND_STRING; case NUMERIC_DESCEND: return NUMERIC_DESCEND_STRING; } return super.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortValue.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortValue.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.text.ParseException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.util.Position; import org.apache.directory.api.util.Strings; /** * This class represents 'OlcValSortOverlay' value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcValSortValue { /** The 'weighted' constant string */ private static final String WEIGHTED_STRING = "weighted"; /** The attribute */ private String attribute; /** The base DN */ private Dn baseDn; /** The sort method */ private OlcValSortMethodEnum sortMethod; private boolean isWeighted = false; /** * Gets the attribute. * * @return the attribute */ public String getAttribute() { return attribute; } /** * Gets the base DN. * * @return the base DN */ public Dn getBaseDn() { return baseDn; } /** * Gets the sort method. * * @return the sort method */ public OlcValSortMethodEnum getSortMethod() { return sortMethod; } /** * Return whether or the selected sort method is weighted. * * @return <code>true</code> if the sort method is weighted, * <code>false</code> if not */ public boolean isWeighted() { return isWeighted; } /** * Sets the attribute. * * @param attribute the attribute */ public void setAttribute( String attribute ) { this.attribute = attribute; } /** * Sets the base DN. * * @param baseDn the base DN */ public void setBaseDn( Dn baseDn ) { this.baseDn = baseDn; } /** * Sets the sort method. * * @param sortMethod the sort method */ public void setSortMethod( OlcValSortMethodEnum sortMethod ) { this.sortMethod = sortMethod; } /** * Sets whether or the selected sort method is weighted.. * * @param isWeighted the value */ public void setWeighted( boolean isWeighted ) { this.isWeighted = isWeighted; } /** * {@inheritDoc} */ public String toString() { StringBuilder sb = new StringBuilder(); // Attribute sb.append( attribute ); sb.append( ' ' ); // Base DN boolean baseDnNeedsEscaping = false; if ( baseDn != null ) { baseDnNeedsEscaping = needsEscaping( baseDn.toString() ); } if ( baseDnNeedsEscaping ) { sb.append( '"' ); } sb.append( baseDn ); if ( baseDnNeedsEscaping ) { sb.append( '"' ); } sb.append( ' ' ); // Weighted if ( isWeighted ) { sb.append( WEIGHTED_STRING ); // Sort method if ( sortMethod != null ) { // Sort method sb.append( ' ' ); sb.append( sortMethod ); } } else { // Sort method sb.append( sortMethod ); } return sb.toString(); } /** * Indicates if the given string needs escaping. * * @param s the string * @return <code>true</code> if the given string needs escaping * <code>false</code> if not. */ private boolean needsEscaping( String s ) { if ( s != null ) { return s.contains( " " ); } return false; } /** * Parses a OlcValSortValue value. * * @param s the string to be parsed * @return the associated OlcValSortValue object * @throws ParseException if there are any recognition errors (bad syntax) */ public static synchronized OlcValSortValue parse( String s ) throws ParseException { if ( s == null ) { return null; } // Trimming the value s = Strings.trim( s ); // Getting the chars of the string char[] chars = s.toCharArray(); // Creating the position Position pos = new Position(); pos.start = 0; pos.end = 0; pos.length = chars.length; return parseInternal( chars, pos ); } /** * Parses the given string. * * @param chars the characters * @param pos the position * @return the associated OlcValSortValue object * @throws ParseException */ private static OlcValSortValue parseInternal( char[] chars, Position pos ) throws ParseException { OlcValSortValue olcValSortValue = new OlcValSortValue(); // Empty (trimmed) string? if ( chars.length == 0 ) { return null; } do { // Attribute String attribute = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( attribute != null ) && ( !attribute.isEmpty() ) ) { olcValSortValue.setAttribute( attribute ); } else { throw new ParseException( "Could not find the 'Attribute' value", pos.start ); } // Base DN String baseDn = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( baseDn != null ) && ( !baseDn.isEmpty() ) ) { try { olcValSortValue.setBaseDn( new Dn( baseDn ) ); } catch ( LdapInvalidDnException e ) { throw new ParseException( "Could not convert '" + baseDn + "' to a valid DN.", pos.start ); } } else { throw new ParseException( "Could not find the 'Base DN value", pos.start ); } // Getting the next item // It can either "weighted" or a sort method String weightedOrSortMethod = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( weightedOrSortMethod != null ) && ( !weightedOrSortMethod.isEmpty() ) ) { // Weighted if ( isWeighted( weightedOrSortMethod ) ) { olcValSortValue.setWeighted( true ); } // Sort Method else if ( isSortMethod( weightedOrSortMethod ) ) { olcValSortValue.setSortMethod( OlcValSortMethodEnum.fromString( weightedOrSortMethod ) ); } else { throw new ParseException( "Could not identify keyword '" + weightedOrSortMethod + "' as a valid sort method.", pos.start ); } } // Getting the next item // It should not exist if the previous item was "weighted" and // must a sort method it the previous item was "weighted" String sortMethod = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( sortMethod != null ) && ( !sortMethod.isEmpty() ) ) { if ( olcValSortValue.isWeighted() ) { if ( isSortMethod( sortMethod ) ) { olcValSortValue.setSortMethod( OlcValSortMethodEnum.fromString( sortMethod ) ); } else { throw new ParseException( "Could not identify keyword '" + sortMethod + "' as a valid sort method.", pos.start ); } } else { throw new ParseException( "Keyword '" + sortMethod + "' is not allowed after sort method.", pos.start ); } } } while ( ( pos.start != pos.length ) && ( ( Strings.charAt( chars, pos.start ) ) != '\0' ) ); return olcValSortValue; } /** * Indicates if the given string is "weighted". * * @param s the string to test * @return <code>true</code> if the given string is "weighted", * <code>false</code> if not. */ private static boolean isWeighted( String s ) { return WEIGHTED_STRING.equalsIgnoreCase( s ); } /** * Indicates if the given string is one of the sort methods. * * @param s the string to test * @return <code>true</code> if the given string is one of the sort methods, * <code>false</code> if not. */ private static boolean isSortMethod( String s ) { return ( OlcValSortMethodEnum.fromString( s ) != null ); } private static String getQuotedOrNotQuotedOptionValue( char[] chars, Position pos ) throws ParseException { if ( pos.start != pos.length ) { char quoteChar = '\0'; boolean isInQuotes = false; char c = Strings.charAt( chars, pos.start ); char[] v = new char[chars.length - pos.start]; int current = 0; do { if ( ( current == 0 ) && !isInQuotes ) { // Whitespace if ( Character.isWhitespace( c ) ) { // We ignore all whitespaces until we find the start of the value pos.start++; continue; } // Double quotes (") or single quotes (') else if ( ( c == '"' ) || ( c == '\'' ) ) { isInQuotes = true; quoteChar = c; pos.start++; continue; } // Any other char is part of a value else { v[current++] = c; pos.start++; } } else { if ( isInQuotes ) { // Double quotes (") or single quotes (') if ( quoteChar == c ) { isInQuotes = false; pos.start++; continue; } // Checking for escaped quotes else if ( c == '\\' ) { // Double quotes (") if ( ( quoteChar == '"' ) && ( Strings.areEquals( chars, pos.start, "\\\"" ) >= 0 ) ) { v[current++] = '"'; pos.start += 2; continue; } // Single quotes (') else if ( ( quoteChar == '\'' ) && ( Strings.areEquals( chars, pos.start, "\\'" ) >= 0 ) ) { v[current++] = '\''; pos.start += 2; continue; } } // Any other char is part of a value else { v[current++] = c; pos.start++; } } else { // Whitespace if ( Character.isWhitespace( c ) ) { // Once we have found the start of the value, the first whitespace is the exit break; } // Any other char is part of a value else { v[current++] = c; pos.start++; } } } } while ( ( c = Strings.charAt( chars, pos.start ) ) != '\0' ); // Checking the resulting value if ( current == 0 ) { throw new ParseException( "Couldn't find a value.", pos.start ); } char[] value = new char[current]; System.arraycopy( v, 0, value, 0, current ); // Getting the value as a String return new String( value ); } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRefintConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRefintConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcRefintConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcRefintConfig extends OlcOverlayConfig { /** * Field for the 'olcRefintAttribute' attribute. */ @ConfigurationElement(attributeType = "olcRefintAttribute", version="2.4.0") private List<String> olcRefintAttribute = new ArrayList<>(); /** * Field for the 'olcRefintNothing' attribute. */ @ConfigurationElement(attributeType = "olcRefintNothing", version="2.4.0") private Dn olcRefintNothing; /** * Field for the 'olcRefintModifiersName' attribute. */ @ConfigurationElement(attributeType = "olcRefintModifiersName", version="2.4.10") private Dn olcRefintModifiersName; /** * Creates a new instance of OlcRefintConfig. */ public OlcRefintConfig() { super(); olcOverlay = "refint"; } /** * Creates a copy instance of OlcRefintConfig. * * @param o the initial object */ public OlcRefintConfig( OlcRefintConfig o ) { super(); olcRefintAttribute = o.olcRefintAttribute; olcRefintNothing = o.olcRefintNothing; olcRefintModifiersName = o.olcRefintModifiersName; } /** * @param strings */ public void addOlcRefintAttribute( String... strings ) { for ( String string : strings ) { olcRefintAttribute.add( string ); } } /** * @return */ public List<String> getOlcRefintAttribute() { return olcRefintAttribute; } /** * @return */ public Dn getOlcRefintNothing() { return olcRefintNothing; } /** * @return */ public Dn getOlcRefintModifiersName() { return olcRefintModifiersName; } /** * @param olcRefintAttribute */ public void setOlcRefintAttribute( List<String> olcRefintAttribute ) { this.olcRefintAttribute = olcRefintAttribute; } /** * @param olcRefintNothing */ public void setOlcRefintNothing( Dn olcRefintNothing ) { this.olcRefintNothing = olcRefintNothing; } /** * @param olcRefintModifiersName */ public void setOlcRefintModifiersName( Dn olcRefintModifiersName ) { this.olcRefintModifiersName = olcRefintModifiersName; } /** * {@inheritDoc} */ @Override public OlcRefintConfig copy() { return new OlcRefintConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcMemberOfDanglingReferenceBehaviorEnum.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcMemberOfDanglingReferenceBehaviorEnum.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; /** * This enum represents the various values for the 'olcMemberOfDangling' attribute. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum OlcMemberOfDanglingReferenceBehaviorEnum { /** Enum value for 'ignore' */ IGNORE, /** Enum value for 'drop' */ DROP, /** Enum value for 'error' */ ERROR; /** The constant string for 'ignore' */ private static final String IGNORE_STRING = "ignore"; /** The constant string for 'drop' */ private static final String DROP_STRING = "drop"; /** The constant string for 'error' */ private static final String ERROR_STRING = "error"; /** * Gets the associated enum element. * * @param s the string * @return the associated enum element */ public static OlcMemberOfDanglingReferenceBehaviorEnum fromString( String s ) { if ( IGNORE_STRING.equalsIgnoreCase( s ) ) { return IGNORE; } else if ( DROP_STRING.equalsIgnoreCase( s ) ) { return DROP; } else if ( ERROR_STRING.equalsIgnoreCase( s ) ) { return ERROR; } return null; } /** * {@inheritDoc} */ @Override public String toString() { switch ( this ) { case IGNORE: return IGNORE_STRING; case DROP: return DROP_STRING; case ERROR: return ERROR_STRING; } return super.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmMapValue.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmMapValue.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.text.ParseException; import org.apache.directory.api.util.Position; import org.apache.directory.api.util.Strings; /** * This class represents 'olcRwmMap' value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcRwmMapValue { /** The constant string for '*' */ private static final String STAR_STRING = "*"; /** The type */ private OlcRwmMapValueTypeEnum type; /** The local name */ private String localName; /** The foreign name */ private String foreignName; /** * Gets the type. * * @return the type */ public OlcRwmMapValueTypeEnum getType() { return type; } /** * Gets the local name. * * @return the local name */ public String getLocalName() { return localName; } /** * Gets the foreign name. * * @return the foreign name */ public String getForeignName() { return foreignName; } /** * Indicates if the local name is the '*' constant. * * @return <code>true</code> if the local name is the '*' constant, * <code>false</code> if not. */ public boolean isLocalNameStart() { return STAR_STRING.equals( localName ); } /** * Indicates if the foreign name is the '*' constant. * * @return <code>true</code> if the foreign name is the '*' constant, * <code>false</code> if not. */ public boolean isLocalForeignStart() { return STAR_STRING.equals( foreignName ); } /** * Sets the type. * * @param type the type */ public void setType( OlcRwmMapValueTypeEnum type ) { this.type = type; } /** * Sets the local name. * * @param localName the local name */ public void setLocalName( String localName ) { this.localName = localName; } /** * Sets the foreign name. * * @param foreignName the foreign name */ public void setForeignName( String foreignName ) { this.foreignName = foreignName; } /** * {@inheritDoc} */ public String toString() { StringBuilder sb = new StringBuilder(); // Type sb.append( type ); // Local Name if ( ( localName != null ) && ( localName.length() > 0 ) ) { sb.append( ' ' ); sb.append( localName ); } // Foreign Name if ( ( foreignName != null ) && ( foreignName.length() > 0 ) ) { sb.append( ' ' ); sb.append( foreignName ); } return sb.toString(); } /** * Parses a OlcValSortValue value. * * @param s * the string to be parsed * @return the associated OlcValSortValue object * @throws ParseException * if there are any recognition errors (bad syntax) */ public static synchronized OlcRwmMapValue parse( String s ) throws ParseException { if ( s == null ) { return null; } // Trimming the value s = Strings.trim( s ); // Getting the chars of the string char[] chars = new char[s.length()]; s.getChars( 0, s.length(), chars, 0 ); // Creating the position Position pos = new Position(); pos.start = 0; pos.end = 0; pos.length = chars.length; return parseInternal( chars, pos ); } /** * Parses the given string. * * @param chars the characters * @param pos the position * @return the associated OlcValSortValue object * @throws ParseException */ private static OlcRwmMapValue parseInternal( char[] chars, Position pos ) throws ParseException { OlcRwmMapValue value = new OlcRwmMapValue(); // Empty (trimmed) string? if ( chars.length == 0 ) { return null; } do { // Type String typeString = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( typeString != null ) && ( !typeString.isEmpty() ) ) { OlcRwmMapValueTypeEnum type = OlcRwmMapValueTypeEnum.fromString( typeString ); if ( type != null ) { value.setType( type ); } else { throw new ParseException( "Could not identify keyword '" + typeString + "' as a valid type.", pos.start ); } } else { throw new ParseException( "Could not find the 'type' value", pos.start ); } // First Name String firstName = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( firstName == null ) || ( firstName.isEmpty() ) ) { throw new ParseException( "Could not find any 'localName' or 'foreignName' value", pos.start ); } // Second Name String secondName = getQuotedOrNotQuotedOptionValue( chars, pos ); if ( ( secondName == null ) || ( secondName.isEmpty() ) ) { // Local Name is optional // If we got only one name, it's the foreign name value.setForeignName( firstName ); } else { value.setLocalName( firstName ); value.setForeignName( secondName ); } } while ( ( pos.start != pos.length ) && ( ( Strings.charAt( chars, pos.start ) ) != '\0' ) ); return value; } private static String getQuotedOrNotQuotedOptionValue( char[] chars, Position pos ) throws ParseException { if ( pos.start != pos.length ) { char quoteChar = '\0'; boolean isInQuotes = false; char c = Strings.charAt( chars, pos.start ); char[] v = new char[chars.length - pos.start]; int current = 0; do { if ( ( current == 0 ) && !isInQuotes ) { // Whitespace if ( Character.isWhitespace( c ) ) { // We ignore all whitespaces until we find the start of the value pos.start++; continue; } // Double quotes (") or single quotes (') else if ( ( c == '"' ) || ( c == '\'' ) ) { isInQuotes = true; quoteChar = c; pos.start++; continue; } // Any other char is part of a value else { v[current++] = c; pos.start++; } } else { if ( isInQuotes ) { // Double quotes (") or single quotes (') if ( quoteChar == c ) { isInQuotes = false; pos.start++; continue; } // Checking for escaped quotes else if ( c == '\\' ) { // Double quotes (") if ( ( quoteChar == '"' ) && ( Strings.areEquals( chars, pos.start, "\\\"" ) >= 0 ) ) { v[current++] = '"'; pos.start += 2; continue; } // Single quotes (') else if ( ( quoteChar == '\'' ) && ( Strings.areEquals( chars, pos.start, "\\'" ) >= 0 ) ) { v[current++] = '\''; pos.start += 2; continue; } } // Any other char is part of a value else { v[current++] = c; pos.start++; } } else { // Whitespace if ( Character.isWhitespace( c ) ) { // Once we have found the start of the value, the first whitespace is the exit break; } // Any other char is part of a value else { v[current++] = c; pos.start++; } } } } while ( ( c = Strings.charAt( chars, pos.start ) ) != '\0' ); // Checking the resulting value if ( current == 0 ) { throw new ParseException( "Couldn't find a value.", pos.start ); } char[] value = new char[current]; System.arraycopy( v, 0, value, 0, current ); // Getting the value as a String return new String( value ); } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcPPolicyConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcPPolicyConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcPPolicyConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcPPolicyConfig extends OlcOverlayConfig { /** * Field for the 'olcPPolicyDefault' attribute. */ @ConfigurationElement(attributeType = "olcPPolicyDefault", version="2.4.0") private Dn olcPPolicyDefault; /** * Field for the 'olcPPolicyForwardUpdates' attribute. */ @ConfigurationElement(attributeType = "olcPPolicyForwardUpdates", version="2.4.17") private Boolean olcPPolicyForwardUpdates; /** * Field for the 'olcPPolicyHashCleartext' attribute. */ @ConfigurationElement(attributeType = "olcPPolicyHashCleartext", version="2.4.0") private Boolean olcPPolicyHashCleartext; /** * Field for the 'olcPPolicyUseLockout' attribute. */ @ConfigurationElement(attributeType = "olcPPolicyUseLockout", version="2.4.0") private Boolean olcPPolicyUseLockout; /** * Creates a new instance of OlcPPolicyConfig. */ public OlcPPolicyConfig() { super(); olcOverlay = "ppolicy"; } /** * Creates a copy instance of OlcPPolicyConfig. * * @param o the initial object */ public OlcPPolicyConfig( OlcPPolicyConfig o ) { super( o ); olcPPolicyDefault = o.olcPPolicyDefault; olcPPolicyForwardUpdates = o.olcPPolicyForwardUpdates; olcPPolicyHashCleartext = o.olcPPolicyHashCleartext; olcPPolicyUseLockout = o.olcPPolicyUseLockout; } /** * @return the olcPPolicyDefault */ public Dn getOlcPPolicyDefault() { return olcPPolicyDefault; } /** * @return the olcPPolicyForwardUpdates */ public Boolean getOlcPPolicyForwardUpdates() { return olcPPolicyForwardUpdates; } /** * @return the olcPPolicyHashCleartext */ public Boolean getOlcPPolicyHashCleartext() { return olcPPolicyHashCleartext; } /** * @return the olcPPolicyUseLockout */ public Boolean getOlcPPolicyUseLockout() { return olcPPolicyUseLockout; } /** * @param olcPPolicyDefault the olcPPolicyDefault to set */ public void setOlcPPolicyDefault( Dn olcPPolicyDefault ) { this.olcPPolicyDefault = olcPPolicyDefault; } /** * @param olcPPolicyForwardUpdates the olcPPolicyForwardUpdates to set */ public void setOlcPPolicyForwardUpdates( Boolean olcPPolicyForwardUpdates ) { this.olcPPolicyForwardUpdates = olcPPolicyForwardUpdates; } /** * @param olcPPolicyHashCleartext the olcPPolicyHashCleartext to set */ public void setOlcPPolicyHashCleartext( Boolean olcPPolicyHashCleartext ) { this.olcPPolicyHashCleartext = olcPPolicyHashCleartext; } /** * @param olcPPolicyUseLockout the olcPPolicyUseLockout to set */ public void setOlcPPolicyUseLockout( Boolean olcPPolicyUseLockout ) { this.olcPPolicyUseLockout = olcPPolicyUseLockout; } /** * {@inheritDoc} */ @Override public OlcPPolicyConfig copy() { return new OlcPPolicyConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmMapValueTypeEnum.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmMapValueTypeEnum.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; /** * This enum represents the various values of part of a 'olcRwmMap' attribute. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum OlcRwmMapValueTypeEnum { /** Enum value for 'attribute' */ ATTRIBUTE, /** Enum value for 'objectclass' */ OBJECTCLASS; /** The constant string for 'attribute' */ private static final String ATTRIBUTE_STRING = "attribute"; /** The constant string for 'objectclass' */ private static final String OBJECTCLASS_STRING = "objectclass"; /** * Gets the associated enum element. * * @param s the string * @return the associated enum element */ public static OlcRwmMapValueTypeEnum fromString( String s ) { if ( ATTRIBUTE_STRING.equalsIgnoreCase( s ) ) { return ATTRIBUTE; } else if ( OBJECTCLASS_STRING.equalsIgnoreCase( s ) ) { return OBJECTCLASS; } return null; } /** * {@inheritDoc} */ @Override public String toString() { switch ( this ) { case ATTRIBUTE: return ATTRIBUTE_STRING; case OBJECTCLASS: return OBJECTCLASS_STRING; } return super.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcSyncProvConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcSyncProvConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcSyncProvConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcSyncProvConfig extends OlcOverlayConfig { /** * Field for the 'olcSpCheckpoint' attribute. */ @ConfigurationElement(attributeType = "olcSpCheckpoint", version="2.4.0") private String olcSpCheckpoint; /** * Field for the 'olcSpNoPresent' attribute. */ @ConfigurationElement(attributeType = "olcSpNoPresent", defaultValue = "FALSE", version="2.4.0") private Boolean olcSpNoPresent = false; /** * Field for the 'olcSpReloadHint' attribute. */ @ConfigurationElement(attributeType = "olcSpReloadHint", defaultValue = "FALSE", version="2.4.0") private Boolean olcSpReloadHint = false; /** * Field for the 'olcSpSessionlog' attribute. */ @ConfigurationElement(attributeType = "olcSpSessionlog", version="2.4.0") private Integer olcSpSessionlog; /** * Creates a new instance of OlcSyncProvConfig. */ public OlcSyncProvConfig() { super(); olcOverlay = "syncprov"; } /** * Creates a copy instance of OlcSyncProvConfig. * * @param o the initial object */ public OlcSyncProvConfig( OlcSyncProvConfig o ) { super(); olcSpCheckpoint = o.olcSpCheckpoint; olcSpNoPresent = o.olcSpNoPresent; olcSpReloadHint = o.olcSpReloadHint; olcSpSessionlog = o.olcSpSessionlog; } /** * @return the olcSpCheckpoint */ public String getOlcSpCheckpoint() { return olcSpCheckpoint; } /** * @return the olcSpNoPresent */ public Boolean getOlcSpNoPresent() { return olcSpNoPresent; } /** * @return the olcSpReloadHint */ public Boolean getOlcSpReloadHint() { return olcSpReloadHint; } /** * @return the olcSpSessionlog */ public Integer getOlcSpSessionlog() { return olcSpSessionlog; } /** * @param olcSpCheckpoint the olcSpCheckpoint to set */ public void setOlcSpCheckpoint( String olcSpCheckpoint ) { this.olcSpCheckpoint = olcSpCheckpoint; } /** * @param olcSpNoPresent the olcSpNoPresent to set */ public void setOlcSpNoPresent( Boolean olcSpNoPresent ) { this.olcSpNoPresent = olcSpNoPresent; } /** * @param olcSpReloadHint the olcSpReloadHint to set */ public void setOlcSpReloadHint( Boolean olcSpReloadHint ) { this.olcSpReloadHint = olcSpReloadHint; } /** * @param olcSpSessionlog the olcSpSessionlog to set */ public void setOlcSpSessionlog( Integer olcSpSessionlog ) { this.olcSpSessionlog = olcSpSessionlog; } /** * {@inheritDoc} */ @Override public OlcSyncProvConfig copy() { return new OlcSyncProvConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcRwmConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcPPolicyConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcRwmConfig extends OlcOverlayConfig { /** * Field for the 'olcRwmMap' attribute. */ @ConfigurationElement(attributeType = "olcRwmMap", version="2.4.0") private List<String> olcRwmMap = new ArrayList<>(); /** * Field for the 'olcRwmNormalizeMapped' attribute. */ @ConfigurationElement(attributeType = "olcRwmNormalizeMapped", version="2.4.0") private Boolean olcRwmNormalizeMapped; /** * Field for the 'olcRwmRewrite' attribute. */ @ConfigurationElement(attributeType = "olcRwmRewrite", version="2.4.0") private List<String> olcRwmRewrite = new ArrayList<>(); /** * Field for the 'olcRwmTFSupport' attribute. */ @ConfigurationElement(attributeType = "olcRwmTFSupport", version="2.4.0") private String olcRwmTFSupport; /** * Creates a new instance of OlcPPolicyConfig. */ public OlcRwmConfig() { super(); olcOverlay = "rwm"; } /** * Creates a copy instance of OlcPPolicyConfig. * * @param o the initial object */ public OlcRwmConfig( OlcRwmConfig o ) { super( o ); olcRwmMap = o.olcRwmMap; olcRwmNormalizeMapped = o.olcRwmNormalizeMapped; olcRwmRewrite = o.olcRwmRewrite; olcRwmTFSupport = o.olcRwmTFSupport; } /** * @param strings */ public void addOlcRwmMap( String... strings ) { for ( String string : strings ) { olcRwmMap.add( string ); } } /** * @param strings */ public void addOlcRwmRewrite( String... strings ) { for ( String string : strings ) { olcRwmRewrite.add( string ); } } /** */ public void clearOlcRwmMap() { olcRwmMap.clear(); } /** */ public void clearOlcRwmRewrite() { olcRwmRewrite.clear(); } /** * @return */ public List<String> getOlcRwmMap() { return olcRwmMap; } /** * @return */ public Boolean getOlcRwmNormalizeMapped() { return olcRwmNormalizeMapped; } /** * @return */ public List<String> getOlcRwmRewrite() { return olcRwmRewrite; } /** * @return */ public String getOlcRwmTFSupport() { return olcRwmTFSupport; } /** * @param olcRwmMap */ public void setOlcRwmMap( List<String> olcRwmMap ) { this.olcRwmMap = olcRwmMap; } /** * @param olcRwmNormalizeMapped */ public void setOlcRwmNormalizeMapped( Boolean olcRwmNormalizeMapped ) { this.olcRwmNormalizeMapped = olcRwmNormalizeMapped; } /** * @param olcRwmRewrite */ public void setOlcRwmRewrite( List<String> olcRwmRewrite ) { this.olcRwmRewrite = olcRwmRewrite; } /** * @param olcRwmTFSupport */ public void setOlcRwmTFSupport( String olcRwmTFSupport ) { this.olcRwmTFSupport = olcRwmTFSupport; } /** * {@inheritDoc} */ @Override public OlcRwmConfig copy() { return new OlcRwmConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcAccessLogConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcAccessLogConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcAccessLogConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcAccessLogConfig extends OlcOverlayConfig { /** * Field for the 'olcAccessLogDB' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogDB", isOptional = false, version="2.4.0") private Dn olcAccessLogDB; /** * Field for the 'olcAccessLogOld' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogOld", version="2.4.0") private String olcAccessLogOld; /** * Field for the 'olcAccessLogOldAttr' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogOldAttr", version="2.4.0") private List<String> olcAccessLogOldAttr = new ArrayList<>(); /** * Field for the 'olcAccessLogOps' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogOps", version="2.4.0") private List<String> olcAccessLogOps = new ArrayList<>(); /** * Field for the 'olcAccessLogPurge' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogPurge", version="2.4.0") private String olcAccessLogPurge; /** * Field for the 'olcAccessLogSuccess' attribute. */ @ConfigurationElement(attributeType = "olcAccessLogSuccess", version="2.4.0") private Boolean olcAccessLogSuccess; /** * Creates a new instance of OlcAccessLogConfig. */ public OlcAccessLogConfig() { super(); olcOverlay = "accesslog"; } /** * Creates a copy instance of OlcAccessLogConfig. * * @param o the initial object */ public OlcAccessLogConfig( OlcAccessLogConfig o ) { super( o ); olcAccessLogDB = o.olcAccessLogDB; olcAccessLogOld = o.olcAccessLogOld; olcAccessLogOldAttr = new ArrayList<>( olcAccessLogOldAttr ); olcAccessLogOps = new ArrayList<>( o.olcAccessLogOps ); olcAccessLogPurge = o.olcAccessLogPurge; olcAccessLogSuccess = o.olcAccessLogSuccess; } /** * @param strings */ public void addOlcAccessLogOldAttr( String... strings ) { for ( String string : strings ) { olcAccessLogOldAttr.add( string ); } } /** * @param strings */ public void addOlcAccessLogOps( String... strings ) { for ( String string : strings ) { olcAccessLogOps.add( string ); } } public void clearOlcAccessLogOldAttr() { olcAccessLogOldAttr.clear(); } public void clearOlcAccessLogOps() { olcAccessLogOps.clear(); } /** * @return the olcAccessLogDB */ public Dn getOlcAccessLogDB() { return olcAccessLogDB; } /** * @return the olcAccessLogOld */ public String getOlcAccessLogOld() { return olcAccessLogOld; } /** * @return the olcAccessLogOldAttr */ public List<String> getOlcAccessLogOldAttr() { return olcAccessLogOldAttr; } /** * @return the olcAccessLogOps */ public List<String> getOlcAccessLogOps() { return olcAccessLogOps; } /** * @return the olcAccessLogPurge */ public String getOlcAccessLogPurge() { return olcAccessLogPurge; } /** * @return the olcAccessLogSuccess */ public Boolean getOlcAccessLogSuccess() { return olcAccessLogSuccess; } /** * @param olcAccessLogDB the olcAccessLogDB to set */ public void setOlcAccessLogDB( Dn olcAccessLogDB ) { this.olcAccessLogDB = olcAccessLogDB; } /** * @param olcAccessLogOld the olcAccessLogOld to set */ public void setOlcAccessLogOld( String olcAccessLogOld ) { this.olcAccessLogOld = olcAccessLogOld; } /** * @param olcAccessLogOldAttr the olcAccessLogOldAttr to set */ public void setOlcAccessLogOldAttr( List<String> olcAccessLogOldAttr ) { this.olcAccessLogOldAttr = olcAccessLogOldAttr; } /** * @param olcAccessLogOps the olcAccessLogOps to set */ public void setOlcAccessLogOps( List<String> olcAccessLogOps ) { this.olcAccessLogOps = olcAccessLogOps; } /** * @param olcAccessLogPurge the olcAccessLogPurge to set */ public void setOlcAccessLogPurge( String olcAccessLogPurge ) { this.olcAccessLogPurge = olcAccessLogPurge; } /** * @param olcAccessLogSuccess the olcAccessLogSuccess to set */ public void setOlcAccessLogSuccess( Boolean olcAccessLogSuccess ) { this.olcAccessLogSuccess = olcAccessLogSuccess; } /** * {@inheritDoc} */ @Override public OlcAccessLogConfig copy() { return new OlcAccessLogConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/overlay/OlcValSortConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.overlay; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcRefintConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcValSortConfig extends OlcOverlayConfig { /** * Field for the 'olcValSortAttr' attribute. */ @ConfigurationElement(attributeType = "olcValSortAttr", isOptional = false, version="2.4.0") private List<String> olcValSortAttr = new ArrayList<>(); /** * Creates a new instance of OlcValSortConfig. */ public OlcValSortConfig() { super(); olcOverlay = "valsort"; } /** * Creates a copy instance of OlcValSortConfig. * * @param o the initial object */ public OlcValSortConfig( OlcValSortConfig o ) { super(); olcValSortAttr = o.olcValSortAttr; } /** * @param strings */ public void addOlcValSortAttr( String... strings ) { for ( String string : strings ) { olcValSortAttr.add( string ); } } /** */ public void clearOlcValSortAttr() { olcValSortAttr.clear(); } /** * @return */ public List<String> getOlcValSortAttr() { return olcValSortAttr; } /** * @param olcValSortAttr */ public void setOlcValSortAttr( List<String> olcValSortAttr ) { this.olcValSortAttr = olcValSortAttr; } /** * {@inheritDoc} */ @Override public OlcValSortConfig copy() { return new OlcValSortConfig( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/widgets/LockDetectWidget.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/widgets/LockDetectWidget.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.widgets; import org.apache.directory.studio.common.ui.widgets.AbstractWidget; 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.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.config.model.database.OlcBdbConfigLockDetectEnum; /** * The LockDetectWidget provides a combo to select the Lock Detect value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LockDetectWidget extends AbstractWidget { /** The combo viewer's values */ private Object[] comboViewerValues = new Object[] { new NoneObject(), OlcBdbConfigLockDetectEnum.DEFAULT, OlcBdbConfigLockDetectEnum.RANDOM, OlcBdbConfigLockDetectEnum.OLDEST, OlcBdbConfigLockDetectEnum.YOUNGEST, OlcBdbConfigLockDetectEnum.FEWEST }; /** The selected value */ private OlcBdbConfigLockDetectEnum value; // UI widgets private ComboViewer comboViewer; /** * Creates a new instance of LockDetectWidget. */ public LockDetectWidget() { } /** * Creates the widget. * * @param parent the parent */ public void createWidget( Composite parent ) { createWidget( parent, null ); } /** * Creates the widget. * * @param parent the parent * @param toolkit the toolkit */ public void createWidget( Composite parent, FormToolkit toolkit ) { // Combo comboViewer = new ComboViewer( parent ); comboViewer.setContentProvider( new ArrayContentProvider() ); comboViewer.setLabelProvider( new LabelProvider() { @Override public String getText( Object element ) { if ( element instanceof NoneObject ) { return "(No value)"; } else if ( element instanceof OlcBdbConfigLockDetectEnum ) { OlcBdbConfigLockDetectEnum lockDetect = ( OlcBdbConfigLockDetectEnum ) element; switch ( lockDetect ) { case OLDEST: return "Oldest"; case YOUNGEST: return "Youngest"; case FEWEST: return "Fewest"; case RANDOM: return "Random"; case DEFAULT: return "Default"; } } return super.getText( element ); } } ); comboViewer.addSelectionChangedListener( event -> { value = null; StructuredSelection selection = ( StructuredSelection ) comboViewer.getSelection(); if ( !selection.isEmpty() ) { Object selectedObject = selection.getFirstElement(); if ( selectedObject instanceof OlcBdbConfigLockDetectEnum ) { value = ( OlcBdbConfigLockDetectEnum ) selectedObject; } } notifyListeners(); } ); comboViewer.setInput( comboViewerValues ); comboViewer.setSelection( new StructuredSelection( comboViewerValues[0] ) ); } /** * Sets the value. * * @param value the value */ public void setValue( OlcBdbConfigLockDetectEnum value ) { this.value = value; if ( value == null ) { comboViewer.setSelection( new StructuredSelection( comboViewerValues[0] ) ); } else { comboViewer.setSelection( new StructuredSelection( value ) ); } } /** * Gets the value. * * @return the value */ public OlcBdbConfigLockDetectEnum getValue() { return value; } /** * Returns the primary control associated with this widget. * * @return the primary control associated with this widget. */ public Control getControl() { return comboViewer.getControl(); } class NoneObject { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/widgets/IndicesWidget.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/widgets/IndicesWidget.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.widgets; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.config.editor.wrappers.DbIndexDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.DbIndexWrapper; /** * The IndicesWidget provides a table viewer to add/edit/remove an index : * <pre> * Attributes * +----------------------------+ * | Index 1 | (Add...) * | Index 2 | (Edit...) * | | (Delete) * +----------------------------+ * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class IndicesWidget extends TableWidget<DbIndexWrapper> { /** * Creates a new instance of IndicesWidget. * * @param connection the browserConnection */ public IndicesWidget( IBrowserConnection browserConnection ) { super( new DbIndexDecorator( null, browserConnection ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMonitorConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMonitorConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcMonitorConfig extends OlcDatabaseConfig { // No other fields than those inherited from the 'OlcDatabaseConfig' class /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.MONITOR.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcConfig; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; /** * Java bean for the 'olcDatabaseConfig' object class. It stores the common parameters * for any DB : * <ul> * <li>olcAccess</li> * <li>olcAddContentAcl</li> * <li>olcDatabase (MUST)</li> * <li>olcDisabled</li> * <li>olcExtraAttrs</li> * <li>olcHidden</li> * <li>olcLastMod</li> * <li>olcLimits</li> * <li>olcMaxDerefDepth</li> * <li>olcMirrorMode</li> * <li>olcMonitoring</li> * <li>olcPlugin</li> * <li>olcReadOnly</li> * <li>olcReplica</li> * <li>olcReplicaArgsFile</li> * <li>olcReplicaPidFile</li> * <li>olcReplicationInterval</li> * <li>olcReplogFile</li> * <li>olcRequires</li> * <li>olcRestrict</li> * <li>olcRootDN</li> * <li>olcRootPW</li> * <li>olcSchemaDN</li> * <li>olcSecurity</li> * <li>olcSizeLimit</li> * <li>olcSubordinate</li> * <li>olcSuffix</li> * <li>olcSyncrepl</li> * <li>olcSyncUseSubentry</li> * <li>olcTimeLimit</li> * <li>olcUpdateDN</li> * <li>olcUpdateRef</li> * </ul> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcDatabaseConfig extends OlcConfig { /** * Field for the 'olcAccess' attribute, which is an ordered multi-value String attribute */ @ConfigurationElement(attributeType = "olcAccess", version="2.4.0") private List<String> olcAccess = new ArrayList<>(); /** * Field for the 'olcAddContentAcl' attribute. */ @ConfigurationElement(attributeType = "olcAddContentAcl", version="2.4.13") private Boolean olcAddContentAcl; /** * Field for the 'olcDatabase' attribute. */ @ConfigurationElement(attributeType = "olcDatabase", isOptional = false, isRdn = true, version="2.4.0") private String olcDatabase; /** * Field for the 'olcDisabled' attribute. (Added in OpenLDAP 2.4.36) */ @ConfigurationElement(attributeType = "olcDisabled", version="2.4.36") private Boolean olcDisabled; /** * Field for the 'olcExtraAttrs' attribute. (Added in OpenLDAP 2.4.22) */ @ConfigurationElement(attributeType = "olcExtraAttrs", version="2.4.22") private List<String> olcExtraAttrs; /** * Field for the 'olcHidden' attribute. */ @ConfigurationElement(attributeType = "olcHidden", version="2.4.0") private Boolean olcHidden; /** * Field for the 'olcLastMod' attribute. */ @ConfigurationElement(attributeType = "olcLastMod", version="2.4.0") private Boolean olcLastMod; /** * Field for the 'olcLimits' attribute. */ @ConfigurationElement(attributeType = "olcLimits", version="2.4.0") private List<String> olcLimits = new ArrayList<>(); /** * Field for the 'olcMaxDerefDepth' attribute. */ @ConfigurationElement(attributeType = "olcMaxDerefDepth", version="2.4.0") private Integer olcMaxDerefDepth; /** * Field for the 'olcMirrorMode' attribute. */ @ConfigurationElement(attributeType = "olcMirrorMode", version="2.4.0") private Boolean olcMirrorMode; /** * Field for the 'olcMonitoring' attribute. */ @ConfigurationElement(attributeType = "olcMonitoring", version="2.4.0") private Boolean olcMonitoring; /** * Field for the 'olcPlugin' attribute. */ @ConfigurationElement(attributeType = "olcPlugin", version="2.4.0") private List<String> olcPlugin = new ArrayList<>(); /** * Field for the 'olcReadOnly' attribute. */ @ConfigurationElement(attributeType = "olcReadOnly", version="2.4.0") private Boolean olcReadOnly; /** * Field for the 'olcReplica' attribute. */ @ConfigurationElement(attributeType = "olcReplica", version="2.4.0") private List<String> olcReplica = new ArrayList<>(); /** * Field for the 'olcReplicaArgsFile' attribute. */ @ConfigurationElement(attributeType = "olcReplicaArgsFile", version="2.4.0") private String olcReplicaArgsFile; /** * Field for the 'olcReplicaPidFile' attribute. */ @ConfigurationElement(attributeType = "olcReplicaPidFile", version="2.4.0") private String olcReplicaPidFile; /** * Field for the 'olcReplicationInterval' attribute. */ @ConfigurationElement(attributeType = "olcReplicationInterval", version="2.4.0") private Integer olcReplicationInterval; /** * Field for the 'olcReplogFile' attribute. */ @ConfigurationElement(attributeType = "olcReplogFile", version="2.4.0") private String olcReplogFile; /** * Field for the 'olcRequires' attribute. */ @ConfigurationElement(attributeType = "olcRequires", version="2.4.0") private List<String> olcRequires = new ArrayList<>(); /** * Field for the 'olcRestrict' attribute. */ @ConfigurationElement(attributeType = "olcRestrict", version="2.4.0") private List<String> olcRestrict = new ArrayList<>(); /** * Field for the 'olcRootDN' attribute. */ @ConfigurationElement(attributeType = "olcRootDN", version="2.4.0") private Dn olcRootDN; /** * Field for the 'olcRootPW' attribute. */ @ConfigurationElement(attributeType = "olcRootPW", version="2.4.0") private String olcRootPW; /** * Field for the 'olcSchemaDN' attribute. */ @ConfigurationElement(attributeType = "olcSchemaDN", version="2.4.0") private Dn olcSchemaDN; /** * Field for the 'olcSecurity' attribute. */ @ConfigurationElement(attributeType = "olcSecurity", version="2.4.0") private List<String> olcSecurity = new ArrayList<>(); /** * Field for the 'olcSizeLimit' attribute. */ @ConfigurationElement(attributeType = "olcSizeLimit", version="2.4.0") private String olcSizeLimit; /** * Field for the 'olcSubordinate' attribute. */ @ConfigurationElement(attributeType = "olcSubordinate", version="2.4.0") private String olcSubordinate; /** * Field for the 'olcSuffix' attribute. */ @ConfigurationElement(attributeType = "olcSuffix", version="2.4.0") private List<Dn> olcSuffix = new ArrayList<>(); /** * Field for the 'olcSyncrepl' attribute. */ @ConfigurationElement(attributeType = "olcSyncrepl", version="2.4.0") private List<String> olcSyncrepl = new ArrayList<>(); /** * Field for the 'olcSyncUseSubentry' attribute. (Added in OpenLDAP 2.4.20) */ @ConfigurationElement(attributeType = "olcSyncUseSubentry", version="2.4.20") private Boolean olcSyncUseSubentry; /** * Field for the 'olcTimeLimit' attribute. */ @ConfigurationElement(attributeType = "olcTimeLimit", version="2.4.0") private List<String> olcTimeLimit = new ArrayList<>(); /** * Field for the 'olcUpdateDN' attribute. */ @ConfigurationElement(attributeType = "olcUpdateDN", version="2.4.0") private Dn olcUpdateDN; /** * Field for the 'olcUpdateRef' attribute. */ @ConfigurationElement(attributeType = "olcUpdateRef", version="2.4.0") private List<String> olcUpdateRef = new ArrayList<>(); /** * The overlays list */ private List<OlcOverlayConfig> overlays = new ArrayList<>(); /** * @param strings */ public void addOlcAccess( String... strings ) { for ( String string : strings ) { olcAccess.add( string ); } } /** * @param strings The olcExtraAttrs to add */ public void addOlcExtraAttrs( String... strings ) { for ( String string : strings ) { olcExtraAttrs.add( string ); } } /** * @param strings */ public void addOlcLimits( String... strings ) { for ( String string : strings ) { olcLimits.add( string ); } } /** * @param strings */ public void addOlcPlugin( String... strings ) { for ( String string : strings ) { olcPlugin.add( string ); } } /** * @param strings */ public void addOlcReplica( String... strings ) { for ( String string : strings ) { olcReplica.add( string ); } } /** * @param strings */ public void addOlcRequires( String... strings ) { for ( String string : strings ) { olcRequires.add( string ); } } /** * @param strings */ public void addOlcRestrict( String... strings ) { for ( String string : strings ) { olcRestrict.add( string ); } } /** * @param strings */ public void addOlcSecurity( String... strings ) { for ( String string : strings ) { olcSecurity.add( string ); } } /** * @param strings */ public void addOlcSuffix( Dn... dns ) { for ( Dn dn : dns ) { olcSuffix.add( dn ); } } /** * @param strings */ public void addOlcSyncrepl( String... strings ) { for ( String string : strings ) { olcSyncrepl.add( string ); } } /** * @param strings */ public void addOlcTimeLimit( String... strings ) { for ( String string : strings ) { olcTimeLimit.add( string ); } } /** * @param strings */ public void addOlcUpdateRef( String... strings ) { for ( String string : strings ) { olcUpdateRef.add( string ); } } public void clearOlcAccess() { olcAccess.clear(); } public void clearOlcExtraAttrs() { olcExtraAttrs.clear(); } public void clearOlcLimits() { olcLimits.clear(); } public void clearOlcPlugin() { olcPlugin.clear(); } public void clearOlcReplica() { olcReplica.clear(); } public void clearOlcRequires() { olcRequires.clear(); } public void clearOlcRestrict() { olcRestrict.clear(); } public void clearOlcSecurity() { olcSecurity.clear(); } public void clearOlcSuffix() { olcSuffix.clear(); } public void clearOlcSyncrepl() { olcSyncrepl.clear(); } public void clearOlcTimeLimit() { olcTimeLimit.clear(); } public void clearOlcUpdateRef() { olcUpdateRef.clear(); } /** * @return the olcAccess */ public List<String> getOlcAccess() { return copyListString( olcAccess ); } /** * @return the olcAddContentAcl */ public Boolean getOlcAddContentAcl() { return olcAddContentAcl; } /** * @return the olcDatabase */ public String getOlcDatabase() { return olcDatabase; } /** * @return the olcDisabled */ public Boolean getOlcDisabled() { return olcDisabled; } /** * @return the olcExtraAttrs */ public List<String> getOlcExtraAttrs() { return copyListString( olcExtraAttrs ); } /** * @return the olcHidden */ public Boolean getOlcHidden() { return olcHidden; } /** * @return the olcLastMod */ public Boolean getOlcLastMod() { return olcLastMod; } /** * @return the olcLimits */ public List<String> getOlcLimits() { return copyListString( olcLimits ); } /** * @return the olcMaxDerefDepth */ public Integer getOlcMaxDerefDepth() { return olcMaxDerefDepth; } /** * @return the olcMirrorMode */ public Boolean getOlcMirrorMode() { return olcMirrorMode; } /** * @return the olcMonitoring */ public Boolean getOlcMonitoring() { return olcMonitoring; } /** * @return the olcPlugin */ public List<String> getOlcPlugin() { return copyListString( olcPlugin ); } /** * @return the olcReadOnly */ public Boolean getOlcReadOnly() { return olcReadOnly; } /** * @return the olcReplica */ public List<String> getOlcReplica() { return copyListString( olcReplica ); } /** * @return the olcReplicaArgsFile */ public String getOlcReplicaArgsFile() { return olcReplicaArgsFile; } /** * @return the olcReplicaPidFile */ public String getOlcReplicaPidFile() { return olcReplicaPidFile; } /** * @return the olcReplicationInterval */ public Integer getOlcReplicationInterval() { return olcReplicationInterval; } /** * @return the olcReplogFile */ public String getOlcReplogFile() { return olcReplogFile; } /** * @return the olcRequires */ public List<String> getOlcRequires() { return copyListString( olcRequires ); } /** * @return the olcRestrict */ public List<String> getOlcRestrict() { return copyListString( olcRestrict ); } /** * @return the olcRootDN */ public Dn getOlcRootDN() { return olcRootDN; } /** * @return the olcRootPW */ public String getOlcRootPW() { return olcRootPW; } /** * @return the olcSchemaDN */ public Dn getOlcSchemaDN() { return olcSchemaDN; } /** * @return the olcSecurity */ public List<String> getOlcSecurity() { return copyListString( olcSecurity ); } /** * @return the olcSizeLimit */ public String getOlcSizeLimit() { return olcSizeLimit; } /** * @return the olcSubordinate */ public String getOlcSubordinate() { return olcSubordinate; } /** * @return the olcSuffix */ public List<Dn> getOlcSuffix() { return olcSuffix; } /** * @return the olcSyncrepl */ public List<String> getOlcSyncrepl() { return copyListString( olcSyncrepl ); } /** * @return the olcSyncUseSubentry */ public Boolean getOlcSyncUseSubentry() { return olcSyncUseSubentry; } /** * @return the olcTimeLimit */ public List<String> getOlcTimeLimit() { return copyListString( olcTimeLimit ); } /** * @return the olcUpdateDN */ public Dn getOlcUpdateDN() { return olcUpdateDN; } /** * @return the olcUpdateRef */ public List<String> getOlcUpdateRef() { return copyListString( olcUpdateRef ); } /** * @return the overlays */ public List<OlcOverlayConfig> getOverlays() { return overlays; } /** * @param overlays */ public void setOverlays( List<OlcOverlayConfig> overlays ) { this.overlays = overlays; } public void clearOverlays() { overlays.clear(); } /** * @param o * @return * @see java.util.List#add(java.lang.Object) */ public boolean addOverlay( OlcOverlayConfig o ) { return overlays.add( o ); } /** * @param o * @return * @see java.util.List#remove(java.lang.Object) */ public boolean removeOverlay( OlcOverlayConfig o ) { return overlays.remove( o ); } /** * @param olcAccess the olcAccess to set */ public void setOlcAccess( List<String> olcAccess ) { this.olcAccess = copyListString( olcAccess ); } /** * @param olcAddContentAcl the olcAddContentAcl to set */ public void setOlcAddContentAcl( Boolean olcAddContentAcl ) { this.olcAddContentAcl = olcAddContentAcl; } /** * @param olcDatabase the olcDatabase to set */ public void setOlcDatabase( String olcDatabase ) { this.olcDatabase = olcDatabase; } /** * @param oldDisabled the olcDisabled to set */ public void setOlcDisabled( Boolean olcDisabled ) { this.olcDisabled = olcDisabled; } /** * @param olcExtraAttrs the olcExtraAttrs to set */ public void setOlcExtraAttrs( List<String> olcExtraAttrs ) { this.olcExtraAttrs = copyListString( olcExtraAttrs ); } /** * @param olcHidden the olcHidden to set */ public void setOlcHidden( Boolean olcHidden ) { this.olcHidden = olcHidden; } /** * @param olcLastMod the olcLastMod to set */ public void setOlcLastMod( Boolean olcLastMod ) { this.olcLastMod = olcLastMod; } /** * @param olcLimits the olcLimits to set */ public void setOlcLimits( List<String> olcLimits ) { this.olcLimits = copyListString( olcLimits ); } /** * @param olcMaxDerefDepth the olcMaxDerefDepth to set */ public void setOlcMaxDerefDepth( Integer olcMaxDerefDepth ) { this.olcMaxDerefDepth = olcMaxDerefDepth; } /** * @param olcMirrorMode the olcMirrorMode to set */ public void setOlcMirrorMode( Boolean olcMirrorMode ) { this.olcMirrorMode = olcMirrorMode; } /** * @param olcMonitoring the olcMonitoring to set */ public void setOlcMonitoring( Boolean olcMonitoring ) { this.olcMonitoring = olcMonitoring; } /** * @param olcPlugin the olcPlugin to set */ public void setOlcPlugin( List<String> olcPlugin ) { this.olcPlugin = copyListString( olcPlugin ); } /** * @param olcReadOnly the olcReadOnly to set */ public void setOlcReadOnly( Boolean olcReadOnly ) { this.olcReadOnly = olcReadOnly; } /** * @param olcReplica the olcReplica to set */ public void setOlcReplica( List<String> olcReplica ) { this.olcReplica = copyListString( olcReplica ); } /** * @param olcReplicaArgsFile the olcReplicaArgsFile to set */ public void setOlcReplicaArgsFile( String olcReplicaArgsFile ) { this.olcReplicaArgsFile = olcReplicaArgsFile; } /** * @param olcReplicaPidFile the olcReplicaPidFile to set */ public void setOlcReplicaPidFile( String olcReplicaPidFile ) { this.olcReplicaPidFile = olcReplicaPidFile; } /** * @param olcReplicationInterval the olcReplicationInterval to set */ public void setOlcReplicationInterval( Integer olcReplicationInterval ) { this.olcReplicationInterval = olcReplicationInterval; } /** * @param olcReplogFile the olcReplogFile to set */ public void setOlcReplogFile( String olcReplogFile ) { this.olcReplogFile = olcReplogFile; } /** * @param olcRequires the olcRequires to set */ public void setOlcRequires( List<String> olcRequires ) { this.olcRequires = copyListString( olcRequires ); } /** * @param olcRestrict the olcRestrict to set */ public void setOlcRestrict( List<String> olcRestrict ) { this.olcRestrict = copyListString( olcRestrict ); } /** * @param olcRootDN the olcRootDN to set */ public void setOlcRootDN( Dn olcRootDN ) { this.olcRootDN = olcRootDN; } /** * @param olcRootPW the olcRootPW to set */ public void setOlcRootPW( String olcRootPW ) { this.olcRootPW = olcRootPW; } /** * @param olcSchemaDN the olcSchemaDN to set */ public void setOlcSchemaDN( Dn olcSchemaDN ) { this.olcSchemaDN = olcSchemaDN; } /** * @param olcSecurity the olcSecurity to set */ public void setOlcSecurity( List<String> olcSecurity ) { this.olcSecurity = copyListString( olcSecurity ); } /** * @param olcSizeLimit the olcSizeLimit to set */ public void setOlcSizeLimit( String olcSizeLimit ) { this.olcSizeLimit = olcSizeLimit; } /** * @param olcSubordinate the olcSubordinate to set */ public void setOlcSubordinate( String olcSubordinate ) { this.olcSubordinate = olcSubordinate; } /** * @param olcSuffix the olcSuffix to set */ public void setOlcSuffix( List<Dn> olcSuffix ) { this.olcSuffix = olcSuffix; } /** * @param olcSyncrepl the olcSyncrepl to set */ public void setOlcSyncrepl( List<String> olcSyncrepl ) { this.olcSyncrepl = copyListString( olcSyncrepl ); } /** * @param olcSyncUseSubentry the olcSyncUseSubentry to set */ public void setOlcSyncUseSubentry( Boolean olcSyncUseSubentry ) { this.olcSyncUseSubentry = olcSyncUseSubentry; } /** * @param olcTimeLimit the olcTimeLimit to set */ public void setOlcTimeLimit( List<String> olcTimeLimit ) { this.olcTimeLimit = copyListString( olcTimeLimit ); } /** * @param olcUpdateDN the olcUpdateDN to set */ public void setOlcUpdateDN( Dn olcUpdateDN ) { this.olcUpdateDN = olcUpdateDN; } /** * @param olcUpdateRef the olcUpdateRef to set */ public void setOlcUpdateRef( List<String> olcUpdateRef ) { this.olcUpdateRef = copyListString( olcUpdateRef ); } /** * Gets the type of the database. * * @return the type of the database */ public String getOlcDatabaseType() { return "default"; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcLDAPConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcLDAPConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcLDAPConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcLDAPConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbACLAuthcDn' attribute. */ @ConfigurationElement(attributeType = "olcDbACLAuthcDn", version="2.4.0") private Dn olcDbACLAuthcDn; /** * Field for the 'olcDbACLBind' attribute. */ @ConfigurationElement(attributeType = "olcDbACLBind", version="2.4.0") private String olcDbACLBind; /** * Field for the 'olcDbACLPasswd' attribute. */ @ConfigurationElement(attributeType = "olcDbACLPasswd", version="2.4.0") private String olcDbACLPasswd; /** * Field for the 'olcDbCancel' attribute. */ @ConfigurationElement(attributeType = "olcDbCancel", version="2.4.0") private String olcDbCancel; /** * Field for the 'olcDbChaseReferrals' attribute. */ @ConfigurationElement(attributeType = "olcDbChaseReferrals", version="2.4.0") private Boolean olcDbChaseReferrals; /** * Field for the 'olcDbConnectionPoolMax' attribute. */ @ConfigurationElement(attributeType = "olcDbConnectionPoolMax", version="2.4.0") private Integer olcDbConnectionPoolMax; /** * Field for the 'olcDbConnTtl' attribute. */ @ConfigurationElement(attributeType = "olcDbConnTtl", version="2.4.0") private String olcDbConnTtl; /** * Field for the 'olcDbIDAssertAuthcDn' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertAuthcDn", version="2.4.0") private Dn olcDbIDAssertAuthcDn; /** * Field for the 'olcDbIDAssertAuthzFrom' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertAuthzFrom", version="2.4.0") private List<String> olcDbIDAssertAuthzFrom = new ArrayList<>(); /** * Field for the 'olcDbIDAssertBind' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertBind", version="2.4.0") private String olcDbIDAssertBind; /** * Field for the 'olcDbIDAssertMode' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertMode", version="2.4.0") private String olcDbIDAssertMode; /** * Field for the 'olcDbIDAssertPassThru' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertPassThru", version="2.4.22") private List<String> olcDbIDAssertPassThru = new ArrayList<>(); /** * Field for the 'olcDbIDAssertPasswd' attribute. */ @ConfigurationElement(attributeType = "olcDbIDAssertPasswd", version="2.4.0") private String olcDbIDAssertPasswd; /** * Field for the 'olcDbIdleTimeout' attribute. */ @ConfigurationElement(attributeType = "olcDbIdleTimeout", version="2.4.0") private String olcDbIdleTimeout; /** * Field for the 'olcDbKeepalive' attribute. (Added in OpenLDAP 2.4.34) */ @ConfigurationElement(attributeType = "olcDbKeepalive", version="2.4.34") private String olcDbKeepalive; /** * Field for the 'olcDbNetworkTimeout' attribute. */ @ConfigurationElement(attributeType = "olcDbNetworkTimeout", version="2.4.0") private String olcDbNetworkTimeout; /** * Field for the 'olcDbNoRefs' attribute. */ @ConfigurationElement(attributeType = "olcDbNoRefs", version="2.4.12") private Boolean olcDbNoRefs; /** * Field for the 'olcDbNoUndefFilter' attribute. */ @ConfigurationElement(attributeType = "olcDbNoUndefFilter", version="2.4.12") private Boolean olcDbNoUndefFilter; /** * Field for the 'olcDbOnErr' attribute. (Added in OpenLDAP 2.4.34) */ @ConfigurationElement(attributeType = "olcDbOnErr", version="2.4.34") private String olcDbOnErr; /** * Field for the 'olcDbProtocolVersion' attribute. */ @ConfigurationElement(attributeType = "olcDbProtocolVersion", version="2.4.0") private Integer olcDbProtocolVersion; /** * Field for the 'olcDbProxyWhoAmI' attribute. */ @ConfigurationElement(attributeType = "olcDbProxyWhoAmI", version="2.4.0") private Boolean olcDbProxyWhoAmI; /** * Field for the 'olcDbQuarantine' attribute. */ @ConfigurationElement(attributeType = "olcDbQuarantine", version="2.4.0") private String olcDbQuarantine; /** * Field for the 'olcDbRebindAsUser' attribute. */ @ConfigurationElement(attributeType = "olcDbRebindAsUser", version="2.4.0") private Boolean olcDbRebindAsUser; /** * Field for the 'olcDbSessionTrackingRequest' attribute. */ @ConfigurationElement(attributeType = "olcDbSessionTrackingRequest", version="2.4.0") private Boolean olcDbSessionTrackingRequest; /** * Field for the 'olcDbSingleConn' attribute. */ @ConfigurationElement(attributeType = "olcDbSingleConn", version="2.4.0") private Boolean olcDbSingleConn; /** * Field for the 'olcDbStartTLS' attribute. */ @ConfigurationElement(attributeType = "olcDbStartTLS", version="2.4.0") private String olcDbStartTLS; /** * Field for the 'olcDbTFSupport' attribute. */ @ConfigurationElement(attributeType = "olcDbTFSupport", version="2.4.0") private String olcDbTFSupport; /** * Field for the 'olcDbTimeout' attribute. */ @ConfigurationElement(attributeType = "olcDbTimeout", version="2.4.0") private String olcDbTimeout; /** * Field for the 'olcDbURI' attribute. */ @ConfigurationElement(attributeType = "olcDbURI", version="2.4.0") private String olcDbURI; /** * Field for the 'olcDbUseTemporaryConn' attribute. */ @ConfigurationElement(attributeType = "olcDbUseTemporaryConn", version="2.4.0") private Boolean olcDbUseTemporaryConn; /** * @param strings */ public void addOlcDbIDAssertAuthzFrom( String... strings ) { for ( String string : strings ) { olcDbIDAssertAuthzFrom.add( string ); } } /** * @param strings */ public void addOlcDbIDAssertPassThru( String... strings ) { for ( String string : strings ) { olcDbIDAssertPassThru.add( string ); } } public void clearOlcDbIDAssertAuthzFrom() { olcDbIDAssertAuthzFrom.clear(); } public void clearOlcDbIDAssertPassThru() { olcDbIDAssertPassThru.clear(); } /** * @return the olcDbACLAuthcDn */ public Dn getOlcDbACLAuthcDn() { return olcDbACLAuthcDn; } /** * @return the olcDbACLBind */ public String getOlcDbACLBind() { return olcDbACLBind; } /** * @return the olcDbACLPasswd */ public String getOlcDbACLPasswd() { return olcDbACLPasswd; } /** * @return the olcDbCancel */ public String getOlcDbCancel() { return olcDbCancel; } /** * @return the olcDbChaseReferrals */ public Boolean getOlcDbChaseReferrals() { return olcDbChaseReferrals; } /** * @return the olcDbConnectionPoolMax */ public Integer getOlcDbConnectionPoolMax() { return olcDbConnectionPoolMax; } /** * @return the olcDbConnTtl */ public String getOlcDbConnTtl() { return olcDbConnTtl; } /** * @return the olcDbIDAssertAuthcDn */ public Dn getOlcDbIDAssertAuthcDn() { return olcDbIDAssertAuthcDn; } /** * @return the olcDbIDAssertAuthzFrom */ public List<String> getOlcDbIDAssertAuthzFrom() { return copyListString( olcDbIDAssertAuthzFrom ); } /** * @return the olcDbIDAssertBind */ public String getOlcDbIDAssertBind() { return olcDbIDAssertBind; } /** * @return the olcDbIDAssertMode */ public String getOlcDbIDAssertMode() { return olcDbIDAssertMode; } /** * @return the olcDbIDAssertPassThru */ public List<String> getOlcDbIDAssertPassThru() { return copyListString( olcDbIDAssertPassThru ); } /** * @return the olcDbIDAssertPasswd */ public String getOlcDbIDAssertPasswd() { return olcDbIDAssertPasswd; } /** * @return the olcDbIdleTimeout */ public String getOlcDbIdleTimeout() { return olcDbIdleTimeout; } /** * @return the olcDbKeepalive */ public String getOlcDbKeepalive() { return olcDbKeepalive; } /** * @return the olcDbNetworkTimeout */ public String getOlcDbNetworkTimeout() { return olcDbNetworkTimeout; } /** * @return the olcDbNoRefs */ public Boolean getOlcDbNoRefs() { return olcDbNoRefs; } /** * @return the olcDbNoUndefFilter */ public Boolean getOlcDbNoUndefFilter() { return olcDbNoUndefFilter; } /** * @return the olcDbOnErr */ public String getOlcDbOnErr() { return olcDbOnErr; } /** * @return the olcDbProtocolVersion */ public Integer getOlcDbProtocolVersion() { return olcDbProtocolVersion; } /** * @return the olcDbProxyWhoAmI */ public Boolean getOlcDbProxyWhoAmI() { return olcDbProxyWhoAmI; } /** * @return the olcDbQuarantine */ public String getOlcDbQuarantine() { return olcDbQuarantine; } /** * @return the olcDbRebindAsUser */ public Boolean getOlcDbRebindAsUser() { return olcDbRebindAsUser; } /** * @return the olcDbSessionTrackingRequest */ public Boolean getOlcDbSessionTrackingRequest() { return olcDbSessionTrackingRequest; } /** * @return the olcDbSingleConn */ public Boolean getOlcDbSingleConn() { return olcDbSingleConn; } /** * @return the olcDbStartTLS */ public String getOlcDbStartTLS() { return olcDbStartTLS; } /** * @return the olcDbTFSupport */ public String getOlcDbTFSupport() { return olcDbTFSupport; } /** * @return the olcDbTimeout */ public String getOlcDbTimeout() { return olcDbTimeout; } /** * @return the olcDbURI */ public String getOlcDbURI() { return olcDbURI; } /** * @return the olcDbUseTemporaryConn */ public Boolean getOlcDbUseTemporaryConn() { return olcDbUseTemporaryConn; } /** * @param olcDbACLAuthcDn the olcDbACLAuthcDn to set */ public void setOlcDbACLAuthcDn( Dn olcDbACLAuthcDn ) { this.olcDbACLAuthcDn = olcDbACLAuthcDn; } /** * @param olcDbACLBind the olcDbACLBind to set */ public void setOlcDbACLBind( String olcDbACLBind ) { this.olcDbACLBind = olcDbACLBind; } /** * @param olcDbACLPasswd the olcDbACLPasswd to set */ public void setOlcDbACLPasswd( String olcDbACLPasswd ) { this.olcDbACLPasswd = olcDbACLPasswd; } /** * @param olcDbCancel the olcDbCancel to set */ public void setOlcDbCancel( String olcDbCancel ) { this.olcDbCancel = olcDbCancel; } /** * @param olcDbChaseReferrals the olcDbChaseReferrals to set */ public void setOlcDbChaseReferrals( Boolean olcDbChaseReferrals ) { this.olcDbChaseReferrals = olcDbChaseReferrals; } /** * @param olcDbConnectionPoolMax the olcDbConnectionPoolMax to set */ public void setOlcDbConnectionPoolMax( Integer olcDbConnectionPoolMax ) { this.olcDbConnectionPoolMax = olcDbConnectionPoolMax; } /** * @param olcDbConnTtl the olcDbConnTtl to set */ public void setOlcDbConnTtl( String olcDbConnTtl ) { this.olcDbConnTtl = olcDbConnTtl; } /** * @param olcDbIDAssertAuthcDn the olcDbIDAssertAuthcDn to set */ public void setOlcDbIDAssertAuthcDn( Dn olcDbIDAssertAuthcDn ) { this.olcDbIDAssertAuthcDn = olcDbIDAssertAuthcDn; } /** * @param olcDbIDAssertAuthzFrom the olcDbIDAssertAuthzFrom to set */ public void setOlcDbIDAssertAuthzFrom( List<String> olcDbIDAssertAuthzFrom ) { this.olcDbIDAssertAuthzFrom = copyListString( olcDbIDAssertAuthzFrom ); } /** * @param olcDbIDAssertBind the olcDbIDAssertBind to set */ public void setOlcDbIDAssertBind( String olcDbIDAssertBind ) { this.olcDbIDAssertBind = olcDbIDAssertBind; } /** * @param olcDbIDAssertMode the olcDbIDAssertMode to set */ public void setOlcDbIDAssertMode( String olcDbIDAssertMode ) { this.olcDbIDAssertMode = olcDbIDAssertMode; } /** * @param olcDbIDAssertPassThru the olcDbIDAssertPassThru to set */ public void setOlcDbIDAssertPassThru( List<String> olcDbIDAssertPassThru ) { this.olcDbIDAssertPassThru = copyListString( olcDbIDAssertPassThru ); } /** * @param olcDbIDAssertPasswd the olcDbIDAssertPasswd to set */ public void setOlcDbIDAssertPasswd( String olcDbIDAssertPasswd ) { this.olcDbIDAssertPasswd = olcDbIDAssertPasswd; } /** * @param olcDbIdleTimeout the olcDbIdleTimeout to set */ public void setOlcDbIdleTimeout( String olcDbIdleTimeout ) { this.olcDbIdleTimeout = olcDbIdleTimeout; } /** * @param olcDbKeepalive the olcDbKeepalive to set */ public void setOlcDbKeepalive( String olcDbKeepalive ) { this.olcDbKeepalive = olcDbKeepalive; } /** * @param olcDbNetworkTimeout the olcDbNetworkTimeout to set */ public void setOlcDbNetworkTimeout( String olcDbNetworkTimeout ) { this.olcDbNetworkTimeout = olcDbNetworkTimeout; } /** * @param olcDbNoRefs the olcDbNoRefs to set */ public void setOlcDbNoRefs( Boolean olcDbNoRefs ) { this.olcDbNoRefs = olcDbNoRefs; } /** * @param olcDbNoUndefFilter the olcDbNoUndefFilter to set */ public void setOlcDbNoUndefFilter( Boolean olcDbNoUndefFilter ) { this.olcDbNoUndefFilter = olcDbNoUndefFilter; } /** * @param olcDbOnErr the olcDbOnErr to set */ public void setOlcDbOnErr( String olcDbOnErr ) { this.olcDbOnErr = olcDbOnErr; } /** * @param olcDbProtocolVersion the olcDbProtocolVersion to set */ public void setOlcDbProtocolVersion( Integer olcDbProtocolVersion ) { this.olcDbProtocolVersion = olcDbProtocolVersion; } /** * @param olcDbProxyWhoAmI the olcDbProxyWhoAmI to set */ public void setOlcDbProxyWhoAmI( Boolean olcDbProxyWhoAmI ) { this.olcDbProxyWhoAmI = olcDbProxyWhoAmI; } /** * @param olcDbQuarantine the olcDbQuarantine to set */ public void setOlcDbQuarantine( String olcDbQuarantine ) { this.olcDbQuarantine = olcDbQuarantine; } /** * @param olcDbRebindAsUser the olcDbRebindAsUser to set */ public void setOlcDbRebindAsUser( Boolean olcDbRebindAsUser ) { this.olcDbRebindAsUser = olcDbRebindAsUser; } /** * @param olcDbSessionTrackingRequest the olcDbSessionTrackingRequest to set */ public void setOlcDbSessionTrackingRequest( Boolean olcDbSessionTrackingRequest ) { this.olcDbSessionTrackingRequest = olcDbSessionTrackingRequest; } /** * @param olcDbSingleConn the olcDbSingleConn to set */ public void setOlcDbSingleConn( Boolean olcDbSingleConn ) { this.olcDbSingleConn = olcDbSingleConn; } /** * @param olcDbStartTLS the olcDbStartTLS to set */ public void setOlcDbStartTLS( String olcDbStartTLS ) { this.olcDbStartTLS = olcDbStartTLS; } /** * @param olcDbTFSupport the olcDbTFSupport to set */ public void setOlcDbTFSupport( String olcDbTFSupport ) { this.olcDbTFSupport = olcDbTFSupport; } /** * @param olcDbTimeout the olcDbTimeout to set */ public void setOlcDbTimeout( String olcDbTimeout ) { this.olcDbTimeout = olcDbTimeout; } /** * @param olcDbURI the olcDbURI to set */ public void setOlcDbURI( String olcDbURI ) { this.olcDbURI = olcDbURI; } /** * @param olcDbUseTemporaryConn the olcDbUseTemporaryConn to set */ public void setOlcDbUseTemporaryConn( Boolean olcDbUseTemporaryConn ) { this.olcDbUseTemporaryConn = olcDbUseTemporaryConn; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.LDAP.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcHdbConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcHdbConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcHdbConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcHdbConfig extends OlcBdbConfig { /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.HDB.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcRelayConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcRelayConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcRelayConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcRelayConfig extends OlcDatabaseConfig { /** * Field for the 'olcRelay' attribute. */ @ConfigurationElement(attributeType = "olcRelay", version="2.4.0") private Dn olcRelay; /** * @return the olcRelay */ public Dn getOlcRelay() { return olcRelay; } /** * @param olcRelay the olcRelay to set */ public void setOlcRelay( Dn olcRelay ) { this.olcRelay = olcRelay; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.RELAY.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcLdifConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcLdifConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcLdifConfig' object class. */ public class OlcLdifConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbDirectory' attribute. */ @ConfigurationElement(attributeType = "olcDbDirectory", isOptional = false, version="2.4.0") private String olcDbDirectory; /** * @return the olcDbDirectory */ public String getOlcDbDirectory() { return olcDbDirectory; } /** * @param olcDbDirectory the olcDbDirectory to set */ public void setOlcDbDirectory( String olcDbDirectory ) { this.olcDbDirectory = olcDbDirectory; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.LDIF.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMetaConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMetaConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMetaConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcMetaConfig extends OlcDatabaseConfig { /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.META.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcShellConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcShellConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcShellConfig extends OlcDatabaseConfig { // No other fields than those inherited from the 'OlcDatabaseConfig' class /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.SHELL.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDbPerlConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDbPerlConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcDbPerlConfig extends OlcDatabaseConfig { /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.DB_PERL.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcNullConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcNullConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcNullConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcNullConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbBindAllowed' attribute. */ @ConfigurationElement(attributeType = "olcDbBindAllowed", version="2.4.24") private Boolean olcDbBindAllowed; /** * @return the olcDbBindAllowed */ public Boolean getOlcDbBindAllowed() { return olcDbBindAllowed; } /** * @param olcDbBindAllowed the olcDbBindAllowed to set */ public void setOlcDbBindAllowed( Boolean olcDbBindAllowed ) { this.olcDbBindAllowed = olcDbBindAllowed; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.NULL.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcBdbConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcBdbConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcBdbConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcBdbConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbDirectory' attribute. */ @ConfigurationElement(attributeType = "olcDbDirectory", isOptional = false, version="2.4.0") private String olcDbDirectory; /** * Field for the 'olcDbCacheFree' attribute. */ @ConfigurationElement(attributeType = "olcDbCacheFree", version="2.4.0") private Integer olcDbCacheFree; /** * Field for the 'olcDbCacheSize' attribute. */ @ConfigurationElement(attributeType = "olcDbCacheSize", version="2.4.0") private Integer olcDbCacheSize; /** * Field for the 'olcDbCheckpoint' attribute. */ @ConfigurationElement(attributeType = "olcDbCheckpoint", version="2.4.0") private String olcDbCheckpoint; /** * Field for the 'olcDbConfig' attribute. */ @ConfigurationElement(attributeType = "olcDbConfig", version="2.4.0") private List<String> olcDbConfig = new ArrayList<>(); /** * Field for the 'olcDbCryptFile' attribute. */ @ConfigurationElement(attributeType = "olcDbCryptFile", version="2.4.8") private String olcDbCryptFile; /** * Field for the 'olcDbCryptKey' attribute. */ @ConfigurationElement(attributeType = "olcDbCryptKey", version="2.4.8") private byte[] olcDbCryptKey; /** * Field for the 'olcDbDirtyRead' attribute. */ @ConfigurationElement(attributeType = "olcDbDirtyRead", version="2.4.0") private Boolean olcDbDirtyRead; /** * Field for the 'olcDbDNcacheSize' attribute. */ @ConfigurationElement(attributeType = "olcDbDNcacheSize", version="2.4.0") private Integer olcDbDNcacheSize; /** * Field for the 'olcDbIDLcacheSize' attribute. */ @ConfigurationElement(attributeType = "olcDbIDLcacheSize", version="2.4.0") private Integer olcDbIDLcacheSize; /** * Field for the 'olcDbIndex' attribute. */ @ConfigurationElement(attributeType = "olcDbIndex", version="2.4.0") private List<String> olcDbIndex = new ArrayList<>(); /** * Field for the 'olcDbLinearIndex' attribute. */ @ConfigurationElement(attributeType = "olcDbLinearIndex", version="2.4.0") private Boolean olcDbLinearIndex; /** * Field for the 'olcDbLockDetect' attribute. */ @ConfigurationElement(attributeType = "olcDbLockDetect", version="2.4.0") private String olcDbLockDetect; /** * Field for the 'olcDbMode' attribute. */ @ConfigurationElement(attributeType = "olcDbMode", version="2.4.0") private String olcDbMode; /** * Field for the 'olcDbNoSync' attribute. */ @ConfigurationElement(attributeType = "olcDbNoSync", version="2.4.0") private Boolean olcDbNoSync; /** * Field for the 'olcDbPageSize' attribute. */ @ConfigurationElement(attributeType = "olcDbPageSize", version="2.4.13") private List<String> olcDbPageSize = new ArrayList<>(); /** * Field for the 'olcDbSearchStack' attribute. */ @ConfigurationElement(attributeType = "olcDbSearchStack", version="2.4.0") private Integer olcDbSearchStack; /** * Field for the 'olcDbShmKey' attribute. */ @ConfigurationElement(attributeType = "olcDbShmKey", version="2.4.0") private Integer olcDbShmKey; /** * @param strings */ public void addOlcDbConfig( String... strings ) { for ( String string : strings ) { olcDbConfig.add( string ); } } /** * @param strings */ public void addOlcDbIndex( String... strings ) { for ( String string : strings ) { olcDbIndex.add( string ); } } /** * @param strings */ public void addOlcDbPageSize( String... strings ) { for ( String string : strings ) { olcDbPageSize.add( string ); } } public void clearOlcDbConfig() { olcDbConfig.clear(); } public void clearOlcDbIndex() { olcDbIndex.clear(); } public void clearOlcDbPageSize() { olcDbPageSize.clear(); } /** * @return the olcDbCacheFree */ public Integer getOlcDbCacheFree() { return olcDbCacheFree; } /** * @return the olcDbCacheSize */ public Integer getOlcDbCacheSize() { return olcDbCacheSize; } /** * @return the olcDbCheckpoint */ public String getOlcDbCheckpoint() { return olcDbCheckpoint; } /** * @return the olcDbConfig */ public List<String> getOlcDbConfig() { return copyListString( olcDbConfig ); } /** * @return the olcDbCryptFile */ public String getOlcDbCryptFile() { return olcDbCryptFile; } /** * @return the olcDbCryptKey */ public byte[] getOlcDbCryptKey() { if ( olcDbCryptKey != null ) { byte[] copy = new byte[olcDbCryptKey.length]; System.arraycopy( olcDbCryptKey, 0, copy, 0, olcDbCryptKey.length ); return copy; } return olcDbCryptKey; } /** * @return the olcDbDirectory */ public String getOlcDbDirectory() { return olcDbDirectory; } /** * @return the olcDbDirtyRead */ public Boolean getOlcDbDirtyRead() { return olcDbDirtyRead; } /** * @return the olcDbDNcacheSize */ public Integer getOlcDbDNcacheSize() { return olcDbDNcacheSize; } /** * @return the olcDbIDLcacheSize */ public Integer getOlcDbIDLcacheSize() { return olcDbIDLcacheSize; } /** * @return the olcDbIndex */ public List<String> getOlcDbIndex() { return copyListString( olcDbIndex ); } /** * @return the olcDbLinearIndex */ public Boolean getOlcDbLinearIndex() { return olcDbLinearIndex; } /** * @return the olcDbLockDetect */ public String getOlcDbLockDetect() { return olcDbLockDetect; } /** * @return the olcDbMode */ public String getOlcDbMode() { return olcDbMode; } /** * @return the olcDbNoSync */ public Boolean getOlcDbNoSync() { return olcDbNoSync; } /** * @return the olcDbPageSize */ public List<String> getOlcDbPageSize() { return copyListString( olcDbPageSize ); } /** * @return the olcDbSearchStack */ public Integer getOlcDbSearchStack() { return olcDbSearchStack; } /** * @return the olcDbShmKey */ public Integer getOlcDbShmKey() { return olcDbShmKey; } /** * @param olcDbCacheFree the olcDbCacheFree to set */ public void setOlcDbCacheFree( Integer olcDbCacheFree ) { this.olcDbCacheFree = olcDbCacheFree; } /** * @param olcDbCacheSize the olcDbCacheSize to set */ public void setOlcDbCacheSize( Integer olcDbCacheSize ) { this.olcDbCacheSize = olcDbCacheSize; } /** * @param olcDbCheckpoint the olcDbCheckpoint to set */ public void setOlcDbCheckpoint( String olcDbCheckpoint ) { this.olcDbCheckpoint = olcDbCheckpoint; } /** * @param olcDbConfig the olcDbConfig to set */ public void setOlcDbConfig( List<String> olcDbConfig ) { this.olcDbConfig = copyListString( olcDbConfig ); } /** * @param olcDbCryptFile the olcDbCryptFile to set */ public void setOlcDbCryptFile( String olcDbCryptFile ) { this.olcDbCryptFile = olcDbCryptFile; } /** * @param olcDbCryptKey the olcDbCryptKey to set */ public void setOlcDbCryptKey( byte[] olcDbCryptKey ) { if ( olcDbCryptKey != null ) { this.olcDbCryptKey = new byte[olcDbCryptKey.length]; System.arraycopy( olcDbCryptKey, 0, this.olcDbCryptKey, 0, olcDbCryptKey.length ); } else { this.olcDbCryptKey = olcDbCryptKey; } } /** * @param olcDbDirectory the olcDbDirectory to set */ public void setOlcDbDirectory( String olcDbDirectory ) { this.olcDbDirectory = olcDbDirectory; } /** * @param olcDbDirtyRead the olcDbDirtyRead to set */ public void setOlcDbDirtyRead( Boolean olcDbDirtyRead ) { this.olcDbDirtyRead = olcDbDirtyRead; } /** * @param olcDbDNcacheSize the olcDbDNcacheSize to set */ public void setOlcDbDNcacheSize( Integer olcDbDNcacheSize ) { this.olcDbDNcacheSize = olcDbDNcacheSize; } /** * @param olcDbIDLcacheSize the olcDbIDLcacheSize to set */ public void setOlcDbIDLcacheSize( Integer olcDbIDLcacheSize ) { this.olcDbIDLcacheSize = olcDbIDLcacheSize; } /** * @param olcDbIndex the olcDbIndex to set */ public void setOlcDbIndex( List<String> olcDbIndex ) { this.olcDbIndex = copyListString( olcDbIndex ); } /** * @param olcDbLinearIndex the olcDbLinearIndex to set */ public void setOlcDbLinearIndex( Boolean olcDbLinearIndex ) { this.olcDbLinearIndex = olcDbLinearIndex; } /** * @param olcDbLockDetect the olcDbLockDetect to set */ public void setOlcDbLockDetect( String olcDbLockDetect ) { this.olcDbLockDetect = olcDbLockDetect; } /** * @param olcDbMode the olcDbMode to set */ public void setOlcDbMode( String olcDbMode ) { this.olcDbMode = olcDbMode; } /** * @param olcDbNoSync the olcDbNoSync to set */ public void setOlcDbNoSync( Boolean olcDbNoSync ) { this.olcDbNoSync = olcDbNoSync; } /** * @param olcDbPageSize the olcDbPageSize to set */ public void setOlcDbPageSize( List<String> olcDbPageSize ) { this.olcDbPageSize = copyListString( olcDbPageSize ); } /** * @param olcDbSearchStack the olcDbSearchStack to set */ public void setOlcDbSearchStack( Integer olcDbSearchStack ) { this.olcDbSearchStack = olcDbSearchStack; } /** * @param olcDbShmKey the olcDbShmKey to set */ public void setOlcDbShmKey( Integer olcDbShmKey ) { this.olcDbShmKey = olcDbShmKey; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.BDB.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcNdbConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcNdbConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcNdbConfig extends OlcDatabaseConfig { // No other fields than those inherited from the 'OlcDatabaseConfig' class /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.NDB.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcBdbConfigLockDetectEnum.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcBdbConfigLockDetectEnum.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; /** * This enum represents the various values for the 'olcDbLockDetect' attribute. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum OlcBdbConfigLockDetectEnum { /** Enum value for 'oldest' */ OLDEST, /** Enum value for 'youngest' */ YOUNGEST, /** Enum value for 'fewest' */ FEWEST, /** Enum value for 'random' */ RANDOM, /** Enum value for 'default' */ DEFAULT; /** The constant string for 'oldest' */ private static final String OLDEST_STRING = "oldest"; /** The constant string for 'youngest' */ private static final String YOUNGEST_STRING = "youngest"; /** The constant string for 'fewest' */ private static final String FEWEST_STRING = "fewest"; /** The constant string for 'random' */ private static final String RANDOM_STRING = "random"; /** The constant string for 'default' */ private static final String DEFAULT_STRING = "default"; /** * Gets the associated enum element. * * @param s the string * @return the associated enum element */ public static OlcBdbConfigLockDetectEnum fromString( String s ) { if ( OLDEST_STRING.equalsIgnoreCase( s ) ) { return OLDEST; } else if ( YOUNGEST_STRING.equalsIgnoreCase( s ) ) { return YOUNGEST; } else if ( FEWEST_STRING.equalsIgnoreCase( s ) ) { return FEWEST; } else if ( RANDOM_STRING.equalsIgnoreCase( s ) ) { return RANDOM; } else if ( DEFAULT_STRING.equalsIgnoreCase( s ) ) { return DEFAULT; } return null; } /** * {@inheritDoc} */ @Override public String toString() { switch ( this ) { case OLDEST: return OLDEST_STRING; case YOUNGEST: return YOUNGEST_STRING; case FEWEST: return FEWEST_STRING; case RANDOM: return RANDOM_STRING; case DEFAULT: return DEFAULT_STRING; } return super.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMdbConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcMdbConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcMdbConfig' object class. There are a few parameter * that can be managed for the MDB database : * <ul> * <li>olcDbDirectory : the place on disk the DB will be stored</li> * <li>olcDbCheckpoint : </li> * <li>olcDbEnvFlags</li> * <li>olcDbIndex</li> * <li>olcDbMaxEntrySize</li> * <li>olcDbMaxreaders</li> * <li>olcDbMaxSize : the size of the database, in bytes. As it can't grow automatically, set it to * the expected maximum DB size</li> * <li>olcDbMode</li> * <li>olcDbNoSync</li> * <li>olcDbSearchStack</li> * </ul> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcMdbConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbDirectory' attribute. */ @ConfigurationElement(attributeType = "olcDbDirectory", isOptional = false, version="2.4.0") private String olcDbDirectory; /** * Field for the 'olcDbCheckpoint' attribute. */ @ConfigurationElement(attributeType = "olcDbCheckpoint", version="2.4.0") private String olcDbCheckpoint; /** * Field for the 'olcDbEnvFlags' attribute. */ @ConfigurationElement(attributeType = "olcDbEnvFlags", version="2.4.33") private List<String> olcDbEnvFlags = new ArrayList<>(); /** * Field for the 'olcDbIndex' attribute. */ @ConfigurationElement(attributeType = "olcDbIndex", version="2.4.0") private List<String> olcDbIndex = new ArrayList<>(); /** * Field for the 'olcDbMaxEntrySize' attribute. */ @ConfigurationElement(attributeType = "olcDbMaxEntrySize", version="2.4.42-2") private Integer olcDbMaxEntrySize; /** * Field for the 'olcDbMaxReaders' attribute. */ @ConfigurationElement(attributeType = "olcDbMaxReaders", version="2.4.27") private Integer olcDbMaxReaders; /** * Field for the 'olcDbMaxSize' attribute. */ @ConfigurationElement(attributeType = "olcDbMaxSize", version="2.4.27") private Long olcDbMaxSize; /** * Field for the 'olcDbMode' attribute. */ @ConfigurationElement(attributeType = "olcDbMode", version="2.4.27") private String olcDbMode; /** * Field for the 'olcDbNoSync' attribute. */ @ConfigurationElement(attributeType = "olcDbNoSync", version="2.4.27") private Boolean olcDbNoSync; /** * Field for the 'olcDbSearchStack' attribute. */ @ConfigurationElement(attributeType = "olcDbSearchStack", version="2.4.27") private Integer olcDbSearchStack; /** * @param strings */ public void addOlcDbIndex( String... strings ) { for ( String string : strings ) { olcDbIndex.add( string ); } } /** * @param strings */ public void addOlcDbEnvFlags( String... strings ) { for ( String string : strings ) { olcDbEnvFlags.add( string ); } } public void clearOlcDbIndex() { olcDbIndex.clear(); } public void clearOlcDbEnvFlags() { olcDbEnvFlags.clear(); } /** * @return the olcDbCheckpoint */ public String getOlcDbCheckpoint() { return olcDbCheckpoint; } /** * @return the olcDbDirectory */ public String getOlcDbDirectory() { return olcDbDirectory; } /** * @return the olcDbIndex */ public List<String> getOlcDbIndex() { return copyListString( olcDbIndex ); } /** * @return the olcDbEnvFlags */ public List<String> getOlcDbEnvFlags() { return copyListString( olcDbEnvFlags ); } /** * @return the olcDbMaxEntrySize */ public Integer getOlcDbMaxEntrySize() { return olcDbMaxEntrySize; } /** * @return the olcDbMaxReaders */ public Integer getOlcDbMaxReaders() { return olcDbMaxReaders; } /** * @return the olcDbMaxSize */ public Long getOlcDbMaxSize() { return olcDbMaxSize; } /** * @return the olcDbMode */ public String getOlcDbMode() { return olcDbMode; } /** * @return the olcDbNoSync */ public Boolean getOlcDbNoSync() { return olcDbNoSync; } /** * @return the olcDbSearchStack */ public Integer getOlcDbSearchStack() { return olcDbSearchStack; } /** * @param olcDbCheckpoint the olcDbCheckpoint to set */ public void setOlcDbCheckpoint( String olcDbCheckpoint ) { this.olcDbCheckpoint = olcDbCheckpoint; } /** * @param olcDbDirectory the olcDbDirectory to set */ public void setOlcDbDirectory( String olcDbDirectory ) { this.olcDbDirectory = olcDbDirectory; } /** * @param olcDbIndex the olcDbIndex to set */ public void setOlcDbIndex( List<String> olcDbIndex ) { this.olcDbIndex = copyListString( olcDbIndex ); } /** * @param olcDbEnvFlags the olcDbEnvFlags to set */ public void setOlcDbEnvFlagsx( List<String> olcDbEnvFlags ) { this.olcDbEnvFlags = copyListString( olcDbEnvFlags ); } /** * @param olcDbMaxEntrySize the olcDbMaxEntrySize to set */ public void setOlcDbMaxEntrySize( Integer olcDbMaxEntrySize ) { this.olcDbMaxEntrySize = olcDbMaxEntrySize; } /** * @param olcDbMaxReaders the olcDbMaxReaders to set */ public void setOlcDbMaxReaders( Integer olcDbMaxReaders ) { this.olcDbMaxReaders = olcDbMaxReaders; } /** * @param olcDbMaxSize the olcDbMaxSize to set */ public void setOlcDbMaxSize( Long olcDbMaxSize ) { this.olcDbMaxSize = olcDbMaxSize; } /** * @param olcDbMode the olcDbMode to set */ public void setOlcDbMode( String olcDbMode ) { this.olcDbMode = olcDbMode; } /** * @param olcDbNoSync the olcDbNoSync to set */ public void setOlcDbNoSync( Boolean olcDbNoSync ) { this.olcDbNoSync = olcDbNoSync; } /** * @param olcDbSearchStack the olcDbSearchStack to set */ public void setOlcDbSearchStack( Integer olcDbSearchStack ) { this.olcDbSearchStack = olcDbSearchStack; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.MDB.toString().toLowerCase(); } /** * @see Object#toString() */ public String toString() { if ( !getOlcSuffix().isEmpty() ) { return getOlcDatabase() + ":" + getOlcSuffix().get( 0 ); } else { return getOlcDatabase(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcPasswdConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcPasswdConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcPasswdConfig extends OlcDatabaseConfig { // No other fields than those inherited from the 'OlcDatabaseConfig' class /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.PASSWD.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcSqlConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcSqlConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; /** * Java bean for the 'olcMonitorConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcSqlConfig extends OlcDatabaseConfig { // No other fields than those inherited from the 'OlcDatabaseConfig' class /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.SQL.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDbSocketConfig.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDbSocketConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.database; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; /** * Java bean for the 'olcDbSocketConfig' object class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlcDbSocketConfig extends OlcDatabaseConfig { /** * Field for the 'olcDbSocketPath' attribute. */ @ConfigurationElement(attributeType = "olcDbSocketPath", isOptional = false, version="2.4.8") private String olcDbSocketPath; /** * Field for the 'olcDbSocketExtensions' attribute. */ @ConfigurationElement(attributeType = "olcDbSocketExtensions", version="2.4.8") private List<String> olcDbSocketExtensions = new ArrayList<>(); /** * @param strings */ public void addOlcDbSocketExtensions( String... strings ) { for ( String string : strings ) { olcDbSocketExtensions.add( string ); } } public void clearOlcDbSocketExtensions() { olcDbSocketExtensions.clear(); } /** * @return the olcDbSocketExtensions */ public List<String> getOlcDbSocketExtensions() { return copyListString( olcDbSocketExtensions ); } /** * @return the olcDbSocketPath */ public String getOlcDbSocketPath() { return olcDbSocketPath; } /** * @param olcDbSocketExtensions the olcDbSocketExtensions to set */ public void setOlcDbSocketExtensions( List<String> olcDbSocketExtensions ) { this.olcDbSocketExtensions = copyListString( olcDbSocketExtensions ); } /** * @param olcDbSocketPath the olcDbSocketPath to set */ public void setOlcDbSocketPath( String olcDbSocketPath ) { this.olcDbSocketPath = olcDbSocketPath; } /** * {@inheritDoc} */ @Override public String getOlcDatabaseType() { return DatabaseTypeEnum.DB_SOCKET.toString().toLowerCase(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.io; import org.apache.directory.api.ldap.model.exception.LdapException; /** * An exception used when we cannot read the configuration, or when an error * occurred while reading it from the DIT. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConfigurationException extends LdapException { /** The serial version UUID */ private static final long serialVersionUID = 1L; /** * Creates a new instance of ConfigurationException. * * @param message The exception message */ public ConfigurationException( String message ) { super( message ); } /** * Creates a new instance of ConfigurationException. * * @param cause the original cause */ public ConfigurationException( Throwable cause ) { super( cause ); } /** * Creates a new instance of ConfigurationException. * * @param message The exception message * @param cause the original cause */ public ConfigurationException( String message, Throwable cause ) { super( message, cause ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationReader.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.io; import java.io.File; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.directory.api.ldap.model.constants.LdapConstants; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.entry.Attribute; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.entry.Value; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.ldap.util.tree.DnNode; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.io.api.StudioSearchResult; import org.apache.directory.studio.connection.core.io.api.StudioSearchResultEnumeration; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter; import org.apache.directory.studio.openldap.config.ExpandedLdifUtils; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.editor.ConnectionServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.DirectoryServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditorUtils; import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition; import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcConfig; import org.apache.directory.studio.openldap.config.model.OlcGlobal; import org.apache.directory.studio.openldap.config.model.OlcModuleList; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.osgi.util.NLS; /** * This class implements a configuration reader for OpenLDAP. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConfigurationReader { private ConfigurationReader() { // Nothing to do } /** The package name where the model classes are stored */ private static final String MODEL_PACKAGE_NAME = "org.apache.directory.studio.openldap.config.model"; /** The package name where the database model classes are stored */ private static final String DATABASE_PACKAGE_NAME = "org.apache.directory.studio.openldap.config.model.database"; /** The package name where the overlay model classes are stored */ private static final String OVERLAY_PACKAGE_NAME = "org.apache.directory.studio.openldap.config.model.overlay"; /** * Reads the configuration. * * @param input the input * @return the OpenLDAP configuration * @throws Exception */ public static OpenLdapConfiguration readConfiguration( ConnectionServerConfigurationInput input ) throws Exception { // Creating a new OpenLDAP configuration OpenLdapConfiguration configuration = new OpenLdapConfiguration(); // Saving the connection to the configuration configuration.setConnection( input.getConnection() ); // Getting the browser connection associated with the connection in the input IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( input.getConnection() ); // Find the location of the configuration Dn configurationDn = ConfigurationUtils.getConfigurationDn( browserConnection ); // Reading the configuration entries on the server List<Entry> configurationEntries = readEntries( configurationDn, input, browserConnection ); // Creating a map to store object created based on their DN Map<Dn, OlcConfig> dnToConfigObjectMap = new HashMap<>(); // For each configuration entries we create an associated configuration // object and store it in the OpenLDAP configuration for ( Entry entry : configurationEntries ) { // Converting the entry into a configuration object OlcConfig configurationObject = createConfigurationObject( entry ); if ( configurationObject != null ) { // Storing the object in the configuration objects map dnToConfigObjectMap.put( entry.getDn(), configurationObject ); if ( configurationObject instanceof OlcOverlayConfig ) { OlcOverlayConfig overlayConfig = ( OlcOverlayConfig ) configurationObject; OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) dnToConfigObjectMap.get( entry.getDn() .getParent() ); if ( databaseConfig != null ) { databaseConfig.addOverlay( overlayConfig ); } else { configuration.add( overlayConfig ); } } else if ( configurationObject instanceof OlcGlobal ) { configuration.setGlobal( ( OlcGlobal ) configurationObject ); } else if ( configurationObject instanceof OlcModuleList ) { configuration.add( (OlcModuleList)configurationObject ); } else if ( configurationObject instanceof OlcDatabaseConfig ) { configuration.add( ( OlcDatabaseConfig ) configurationObject ); } else { configuration.add( configurationObject ); } } } return configuration; } /** * Reads the configuration. * * @param input the input * @return the OpenLDAP configuration * @throws Exception */ public static OpenLdapConfiguration readConfiguration( DirectoryServerConfigurationInput input ) throws Exception { return readConfiguration( input.getDirectory() ); } /** * Reads the configuration. * * @param directory the directory * @return the OpenLDAP configuration * @throws Exception */ public static OpenLdapConfiguration readConfiguration( File directory ) throws Exception { // Creating a new OpenLDAP configuration OpenLdapConfiguration configuration = new OpenLdapConfiguration(); // Reading the configuration entries disk DnNode<Entry> tree = readEntries( directory ); // Creating configuration objects createConfigurationObjects( tree, configuration ); return configuration; } /** * Creates the configuration objects. * * @param configuration the configuration * @param dnToConfigObjectMap the maps to store */ /** * Creates the configuration objects. * * @param tree the tree * @param configuration the configuration * @throws ConfigurationException */ private static void createConfigurationObjects( DnNode<Entry> tree, OpenLdapConfiguration configuration ) throws ConfigurationException { // Creating a map to store object created based on their DN Map<Dn, OlcConfig> dnToConfigObjectMap = new HashMap<>(); createConfigurationObjects( tree, configuration, dnToConfigObjectMap ); } /** * Creates the configuration objects. * * @param node the node * @param configuration the configuration * @param dnToConfigObjectMap the maps to associate DNs to configuration objects * @throws ConfigurationException */ private static void createConfigurationObjects( DnNode<Entry> node, OpenLdapConfiguration configuration, Map<Dn, OlcConfig> dnToConfigObjectMap ) throws ConfigurationException { if ( node != null ) { // Checking if the node as an element if ( node.hasElement() ) { // Getting the entry for the node Entry entry = node.getElement(); // Converting the entry into a configuration object OlcConfig configurationObject = createConfigurationObject( entry ); if ( configurationObject != null ) { // Storing the object in the configuration objects map dnToConfigObjectMap.put( entry.getDn(), configurationObject ); // Checking if it's an overlay if ( configurationObject instanceof OlcOverlayConfig ) { OlcOverlayConfig overlayConfig = ( OlcOverlayConfig ) configurationObject; // Getting the associated database configuration object OlcDatabaseConfig databaseConfig = ( OlcDatabaseConfig ) dnToConfigObjectMap.get( entry.getDn() .getParent() ); if ( databaseConfig != null ) { databaseConfig.addOverlay( overlayConfig ); } else { configuration.add( overlayConfig ); } } // Checking if it's the "global' configuration object else if ( configurationObject instanceof OlcGlobal ) { configuration.setGlobal( ( OlcGlobal ) configurationObject ); } // Checking if it's a database else if ( configurationObject instanceof OlcDatabaseConfig ) { configuration.add( (OlcDatabaseConfig)configurationObject ); } // Any other object type else { configuration.add( configurationObject ); } } } // Checking the node has some children if ( node.hasChildren() ) { Collection<DnNode<Entry>> children = node.getChildren().values(); for ( DnNode<Entry> child : children ) { createConfigurationObjects( child, configuration, dnToConfigObjectMap ); } } } } /** * Reads the configuration entries from the input. * * @param directory the directory * @return the tree of configuration entries found * @throws Exception if an error occurred */ private static DnNode<Entry> readEntries( File directory ) throws Exception { // Reading the entries tree DnNode<Entry> tree = ExpandedLdifUtils.read( directory ); // Checking the read tree if ( ( tree != null ) && ( tree.size() != 0 ) ) { return tree; } else { throw new Exception( "No entries found" ); } } /** * Gets the highest structural object class found in the attribute. * * @param objectClassAttribute the 'objectClass' attribute * @return the highest structural object class found in the attribute. */ public static ObjectClass getHighestStructuralObjectClass( Attribute objectClassAttribute ) throws ConfigurationException { Set<ObjectClass> candidates = new HashSet<>(); try { SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager(); if ( ( objectClassAttribute != null ) && ( schemaManager != null ) ) { // Create the set of candidates for ( Value objectClassValue : objectClassAttribute ) { ObjectClass oc = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, objectClassValue.getString() ); if ( ( oc != null ) && ( oc.isStructural() ) ) { candidates.add( oc ); } } // Now find the parent OC for ( Value objectClassValue : objectClassAttribute ) { ObjectClass oc = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, objectClassValue.getString() ); if ( oc != null ) { for ( String superiorName : oc.getSuperiorOids() ) { ObjectClass superior = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, superiorName ); if ( ( superior != null ) && ( superior.isStructural() ) && ( candidates.contains( superior ) ) ) { candidates.remove( superior ); } } } } } } catch ( Exception e ) { throw new ConfigurationException( e ); } // The remaining OC in the candidates set is the one we are looking for return candidates.toArray( new ObjectClass[] {} )[0]; } /** * Gets the auxiliary object classes found in the attribute. * * @param objectClassAttribute the 'objectClass' attribute * @return the auxiliary object classes found in the attribute. */ public static ObjectClass[] getAuxiliaryObjectClasses( Attribute objectClassAttribute ) throws ConfigurationException { List<ObjectClass> auxiliaryObjectClasses = new ArrayList<>(); try { SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager(); if ( ( objectClassAttribute != null ) && ( schemaManager != null ) ) { for ( Value objectClassValue : objectClassAttribute ) { ObjectClass oc = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, objectClassValue.getString() ); if ( ( oc != null ) && ( oc.isAuxiliary() ) ) { auxiliaryObjectClasses.add( oc ); } } } } catch ( Exception e ) { throw new ConfigurationException( e ); } return auxiliaryObjectClasses.toArray( new ObjectClass[0] ); } /** * Reads the configuration entries from the input. * * @param configurationDn the configuration DN * @param input the editor input * @param browserConnection the connection * @return the list of configuration entries found * @throws Exception if an error occurred */ public static List<Entry> readEntries( Dn configurationDn, ConnectionServerConfigurationInput input, IBrowserConnection browserConnection ) throws Exception { List<Entry> foundEntries = new ArrayList<>(); IProgressMonitor progressMonitor = new NullProgressMonitor(); StudioProgressMonitor monitor = new StudioProgressMonitor( progressMonitor ); Connection connection = input.getConnection(); // Creating the schema manager SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager(); // The DN corresponding to the configuration base // Creating the configuration partition EntryBasedConfigurationPartition configurationPartition = OpenLdapServerConfigurationEditorUtils .createConfigurationPartition( schemaManager, configurationDn ); // Opening the connection (if needed) ConfigurationUtils.openConnection( connection, monitor ); // Creating the search parameter SearchParameter configSearchParameter = new SearchParameter(); configSearchParameter.setSearchBase( configurationDn ); configSearchParameter.setFilter( LdapConstants.OBJECT_CLASS_STAR ); configSearchParameter.setScope( SearchScope.OBJECT ); configSearchParameter.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); // Looking for the 'ou=config' base entry Entry configEntry = null; StudioSearchResultEnumeration enumeration = SearchRunnable.search( browserConnection, configSearchParameter, monitor ); // Checking if an error occurred if ( monitor.errorsReported() ) { throw monitor.getException(); } // Getting the entry if ( enumeration.hasMore() ) { // Creating the base entry StudioSearchResult searchResult = enumeration.next(); configEntry = searchResult.getEntry(); } enumeration.close(); // Verifying we found the base entry if ( configEntry == null ) { throw new LdapNoSuchObjectException( NLS.bind( "Unable to find the ''{0}'' base entry.", configurationDn ) ); } // Creating a list to hold the entries that needs to be checked // for children and added to the partition List<Entry> entries = new ArrayList<>(); entries.add( configEntry ); // Looping on the entries list until it's empty while ( !entries.isEmpty() ) { // Removing the first entry from the list Entry entry = entries.remove( 0 ); // Adding the entry to the partition and the entries list configurationPartition.addEntry( entry ); foundEntries.add( entry ); SearchParameter searchParameter = new SearchParameter(); searchParameter.setSearchBase( entry.getDn() ); searchParameter.setFilter( LdapConstants.OBJECT_CLASS_STAR ); searchParameter.setScope( SearchScope.ONELEVEL ); searchParameter.setReturningAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); // Looking for the children of the entry StudioSearchResultEnumeration childrenEnumeration = SearchRunnable.search( browserConnection, searchParameter, monitor ); // Checking if an error occurred if ( monitor.errorsReported() ) { throw monitor.getException(); } while ( childrenEnumeration.hasMore() ) { // Creating the child entry StudioSearchResult searchResult = childrenEnumeration.next(); Entry childEntry = searchResult.getEntry(); // Adding the children to the list of entries entries.add( childEntry ); } childrenEnumeration.close(); } // Setting the created partition to the input input.setOriginalPartition( configurationPartition ); return foundEntries; } private static OlcConfig createConfigurationObject( Entry entry ) throws ConfigurationException { // Getting the 'objectClass' attribute Attribute objectClassAttribute = entry.get( SchemaConstants.OBJECT_CLASS_AT ); if ( objectClassAttribute != null ) { // Getting the highest structural object class based on schema ObjectClass highestStructuralObjectClass = getHighestStructuralObjectClass( objectClassAttribute ); // Computing the class name for the bean corresponding to the structural object class String highestObjectClassName = highestStructuralObjectClass.getName(); StringBuilder className = new StringBuilder(); if ( objectClassAttribute.contains( "olcDatabaseConfig" ) ) { className.append( DATABASE_PACKAGE_NAME ); } else if ( objectClassAttribute.contains( "olcOverlayConfig" ) ) { className.append( OVERLAY_PACKAGE_NAME ); } else { className.append( MODEL_PACKAGE_NAME ); } className.append( "." ); className.append( Character.toUpperCase( highestObjectClassName.charAt( 0 ) ) ); className.append( highestObjectClassName.substring( 1 ) ); // Instantiating the object OlcConfig bean = null; try { Class<?> clazz = Class.forName( className.toString() ); Constructor<?> constructor = clazz.getConstructor(); bean = ( OlcConfig ) constructor.newInstance(); } catch ( Exception e ) { throw new ConfigurationException( e ); } // Checking if the bean as been created if ( bean == null ) { throw new ConfigurationException( "The instantiated bean for '" + highestObjectClassName + "' is null" ); } // Checking auxiliary object classes ObjectClass[] auxiliaryObjectClasses = getAuxiliaryObjectClasses( objectClassAttribute ); if ( ( auxiliaryObjectClasses != null ) && ( auxiliaryObjectClasses.length > 0 ) ) { for ( ObjectClass auxiliaryObjectClass : auxiliaryObjectClasses ) { // Computing the class name for the bean corresponding to the auxiliary object class String auxiliaryObjectClassName = auxiliaryObjectClass.getName(); className = new StringBuilder(); className.append( MODEL_PACKAGE_NAME ); className.append( "." ); className.append( Character.toUpperCase( auxiliaryObjectClassName.charAt( 0 ) ) ); className.append( auxiliaryObjectClassName.substring( 1 ) ); // Instantiating the object AuxiliaryObjectClass auxiliaryObjectClassBean = null; try { Class<?> clazz = Class.forName( className.toString() ); Constructor<?> constructor = clazz.getConstructor(); auxiliaryObjectClassBean = ( AuxiliaryObjectClass ) constructor.newInstance(); } catch ( Exception e ) { throw new ConfigurationException( e ); } // Checking if the bean as been created if ( auxiliaryObjectClassBean == null ) { throw new ConfigurationException( "The instantiated auxiliary object class bean for '" + auxiliaryObjectClassName + "' is null" ); } // Reading all values readValues( entry, auxiliaryObjectClassBean ); // Adding the auxiliary object class bean to the bean bean.addAuxiliaryObjectClasses( auxiliaryObjectClassBean ); } } // Reading all values readValues( entry, bean ); // Storing the parent DN bean.setParentDn( entry.getDn().getParent() ); return bean; } return null; } /** * Reads the values of the entry and saves them to the bean. * * @param entry the entry * @param bean then bean * @throws ConfigurationException */ private static void readValues( Entry entry, Object bean ) throws ConfigurationException { // Checking all fields of the bean (including super class fields) Class<?> clazz = bean.getClass(); while ( clazz != null ) { // Looping on all fields of the class Field[] fields = clazz.getDeclaredFields(); for ( Field field : fields ) { // Looking for the @ConfigurationElement annotation ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class ); if ( configurationElement != null ) { // Checking if we're have a value for the attribute type String attributeType = configurationElement.attributeType(); if ( ( attributeType != null ) && ( !"".equals( attributeType ) ) ) { Attribute attribute = entry.get( attributeType ); if ( ( attribute != null ) && ( attribute.size() > 0 ) ) { // Making the field accessible (we get an exception if we don't do that) field.setAccessible( true ); // loop on the values and inject them in the bean for ( Value value : attribute ) { readAttributeValue( bean, field, attribute, value ); } } } } } // Switching to the super class clazz = clazz.getSuperclass(); } } /** * Reads the attribute value. * * @param bean the bean * @param field the field * @param attribute the attribute * @param value the value * @throws ConfigurationException */ private static void readAttributeValue( Object bean, Field field, Attribute attribute, Value value ) throws ConfigurationException { Class<?> type = field.getType(); String addMethodName = "add" + Character.toUpperCase( field.getName().charAt( 0 ) ) + field.getName().substring( 1 ); String valueStr = value.getString(); try { // String class if ( type == String.class ) { Object stringValue = readSingleValue( type, attribute, valueStr ); if ( stringValue != null ) { field.set( bean, stringValue ); } } // Int primitive type else if ( type == int.class ) { Object integerValue = readSingleValue( type, attribute, valueStr ); if ( integerValue != null ) { field.setInt( bean, ( ( Integer ) integerValue ).intValue() ); } } // Integer class else if ( type == Integer.class ) { Object integerValue = readSingleValue( type, attribute, valueStr ); if ( integerValue != null ) { field.set( bean, ( Integer ) integerValue ); } } // Long primitive type else if ( type == long.class ) { Object longValue = readSingleValue( type, attribute, valueStr ); if ( longValue != null ) { field.setLong( bean, ( ( Long ) longValue ).longValue() ); } } // Long class else if ( type == Long.class ) { Object longValue = readSingleValue( type, attribute, valueStr ); if ( longValue != null ) { field.setLong( bean, ( Long ) longValue ); } } // Boolean primitive type else if ( type == boolean.class ) { Object booleanValue = readSingleValue( type, attribute, valueStr ); if ( booleanValue != null ) { field.setBoolean( bean, ( ( Boolean ) booleanValue ).booleanValue() ); } } // Boolean class else if ( type == Boolean.class ) { Object booleanValue = readSingleValue( type, attribute, valueStr ); if ( booleanValue != null ) { field.set( bean, ( Boolean ) booleanValue ); } } // Dn class else if ( type == Dn.class ) { Object dnValue = readSingleValue( type, attribute, valueStr ); if ( dnValue != null ) { field.set( bean, dnValue ); } } // Set class else if ( type == Set.class ) { Type genericFieldType = field.getGenericType(); if ( genericFieldType instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) genericFieldType; Type[] fieldArgTypes = parameterizedType.getActualTypeArguments(); if ( ( fieldArgTypes != null ) && ( fieldArgTypes.length > 0 ) ) { Class<?> fieldArgClass = ( Class<?> ) fieldArgTypes[0]; Object methodParameter = Array.newInstance( fieldArgClass, 1 ); Array.set( methodParameter, 0, readSingleValue( fieldArgClass, attribute, valueStr ) ); Method method = bean.getClass().getMethod( addMethodName, methodParameter.getClass() ); method.invoke( bean, methodParameter ); } } } // List class else if ( type == List.class ) { Type genericFieldType = field.getGenericType(); if ( genericFieldType instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) genericFieldType; Type[] fieldArgTypes = parameterizedType.getActualTypeArguments(); if ( ( fieldArgTypes != null ) && ( fieldArgTypes.length > 0 ) ) { Class<?> fieldArgClass = ( Class<?> ) fieldArgTypes[0];
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/SaveConfigurationRunnable.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/SaveConfigurationRunnable.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.io; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.IEditorInput; import org.apache.directory.studio.openldap.config.editor.ConnectionServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.DirectoryServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.NewServerConfigurationInput; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditorUtils; /** * This class implements a {@link Job} that is used to save a server configuration. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SaveConfigurationRunnable implements StudioRunnableWithProgress { /** The associated editor */ private OpenLdapServerConfigurationEditor editor; /** * Creates a new instance of SaveConfigurationRunnable. * * @param editor * the editor */ public SaveConfigurationRunnable( OpenLdapServerConfigurationEditor editor ) { super(); this.editor = editor; } /** * {@inheritDoc} */ public String getErrorMessage() { return "Unable to save the configuration."; } /** * {@inheritDoc} */ public Object[] getLockedObjects() { return new Object[0]; } /** * {@inheritDoc} */ public String getName() { return "Save Configuration"; } /** * {@inheritDoc} */ public void run( StudioProgressMonitor monitor ) { try { if ( editor.isDirty() ) { monitor.beginTask( "Saving the server configuration", IProgressMonitor.UNKNOWN ); IEditorInput input = editor.getEditorInput(); boolean success = false; if ( input instanceof ConnectionServerConfigurationInput ) { // Saving the ServerConfiguration to the connection OpenLdapServerConfigurationEditorUtils.saveConfiguration( ( ConnectionServerConfigurationInput ) input, editor, monitor ); success = true; } else if ( input instanceof DirectoryServerConfigurationInput ) { // Saving the ServerConfiguration to the 'slapd.d' directory OpenLdapServerConfigurationEditorUtils.saveConfiguration( editor.getConfiguration(), ( ( DirectoryServerConfigurationInput ) input ).getDirectory() ); success = true; } else if ( input instanceof NewServerConfigurationInput ) { // The 'ServerConfigurationEditorInput' class is used when a // new Server Configuration File is created. // We are saving this as if it is a "Save as..." action. editor.doSaveAs( monitor ); } editor.setDirty( !success ); } } catch ( Exception e ) { // Reporting the error to the monitor monitor.reportError( e ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationWriter.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationWriter.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.io; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.entry.Attribute; import org.apache.directory.api.ldap.model.entry.DefaultAttribute; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.ldif.LdifEntry; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditorUtils; import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass; import org.apache.directory.studio.openldap.config.model.ConfigurationElement; import org.apache.directory.studio.openldap.config.model.OlcConfig; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; /** * This class implements a configuration reader for OpenLDAP. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConfigurationWriter { /** The browserConnection */ private IBrowserConnection browserConnection; /** The configuration */ private OpenLdapConfiguration configuration; /** The list of entries */ private List<LdifEntry> entries; /** * Creates a new instance of ConfigWriter. * * @param browserConnection the browser connection * @param configuration the configuration */ public ConfigurationWriter( IBrowserConnection browserConnection, OpenLdapConfiguration configuration ) { this.browserConnection = browserConnection; this.configuration = configuration; } /** * Creates a new instance of ConfigWriter. * * @param configuration the configuration */ public ConfigurationWriter( OpenLdapConfiguration configuration ) { this.configuration = configuration; } /** * Converts the configuration bean to a list of LDIF entries. */ private void convertConfigurationBeanToLdifEntries( Dn configurationDn ) throws ConfigurationException { try { if ( entries == null ) { entries = new ArrayList<>(); // Adding the global configuration addConfigurationBean( configuration.getGlobal(), Dn.EMPTY_DN ); // Adding databases for ( OlcDatabaseConfig database : configuration.getDatabases() ) { LdifEntry entry = addConfigurationBean( database, configurationDn ); if ( entry != null ) { for ( OlcOverlayConfig overlay : database.getOverlays() ) { addConfigurationBean( overlay, entry.getDn() ); } } } // Adding other elements for ( OlcConfig configurationBean : configuration.getConfigurationElements() ) { addConfigurationBean( configurationBean, configurationDn ); } } } catch ( Exception e ) { throw new ConfigurationException( "Unable to convert the configuration beans to LDIF entries", e ); } } private LdifEntry addConfigurationBean( OlcConfig configurationBean, Dn parentDn ) throws Exception { if ( configurationBean != null ) { // Getting the class of the bean Class<?> beanClass = configurationBean.getClass(); // Creating the entry to hold the bean and adding it to the list LdifEntry entry = new LdifEntry(); entry.setDn( getDn( configurationBean, parentDn ) ); addObjectClassAttribute( entry, getObjectClassNameForBean( beanClass ) ); entries.add( entry ); // Checking auxiliary object classes List<AuxiliaryObjectClass> auxiliaryObjectClassesList = configurationBean.getAuxiliaryObjectClasses(); if ( ( auxiliaryObjectClassesList != null ) && !auxiliaryObjectClassesList.isEmpty() ) { for ( AuxiliaryObjectClass auxiliaryObjectClass : auxiliaryObjectClassesList ) { // Getting the bean class for the auxiliary object class Class<?> auxiliaryObjectClassBeanClass = auxiliaryObjectClass.getClass(); // Updating the objectClass attribute value addAttributeTypeValue( SchemaConstants.OBJECT_CLASS_AT, getObjectClassNameForBean( auxiliaryObjectClassBeanClass ), entry ); // Adding fields of the auxiliary object class to the entry addFieldsToBean( auxiliaryObjectClass, auxiliaryObjectClassBeanClass, entry ); } } // A flag to know when we reached the 'OlcConfig' class when // looping on the class hierarchy of the bean boolean olcConfigBeanClassFound = false; // Looping until the 'OlcConfig' class has been found while ( !olcConfigBeanClassFound ) { // Checking if we reached the 'OlcConfig' class if ( beanClass == OlcConfig.class ) { olcConfigBeanClassFound = true; } // Adding fields of the bean to the entry addFieldsToBean( configurationBean, beanClass, entry ); // Moving to the upper class in the class hierarchy beanClass = beanClass.getSuperclass(); } return entry; } return null; } private void addFieldsToBean( Object configurationBean, Class<?> beanClass, LdifEntry entry ) throws Exception { if ( ( configurationBean != null ) && ( beanClass != null ) && ( entry != null ) ) { // Looping on all fields of the bean for ( Field field : beanClass.getDeclaredFields() ) { // Making the field accessible (we get an exception if we don't do that) field.setAccessible( true ); // Getting the class of the field Class<?> fieldClass = field.getType(); Object fieldValue = field.get( configurationBean ); if ( fieldValue != null ) { // Looking for the @ConfigurationElement annotation ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class ); if ( configurationElement != null ) { // Checking if we have a value for the attribute type String attributeType = configurationElement.attributeType(); if ( !Strings.isEmpty( attributeType ) ) { // Adding values to the entry, and if it's empty, add the default value addAttributeTypeValues( configurationElement, fieldValue, entry ); } else if ( OlcConfig.class.isAssignableFrom( fieldClass ) ) { // Checking if we're dealing with a AdsBaseBean subclass type addConfigurationBean( ( OlcConfig ) fieldValue, entry.getDn() ); } } } } } } /** * Gets the Dn associated with the configuration bean. * * @param bean the configuration bean * @param parentDn the parent dn * @return the Dn associated with the configuration bean based on the given base Dn. * @throws LdapInvalidDnException * @throws IllegalArgumentException * @throws IllegalAccessException */ private Dn getDn( OlcConfig bean, Dn parentDn ) throws LdapInvalidDnException, LdapInvalidAttributeValueException, IllegalAccessException { // Getting the class of the bean Class<?> beanClass = bean.getClass(); // A flag to know when we reached the 'AdsBaseBean' class when // looping on the class hierarchy of the bean boolean olcConfigBeanClassFound = false; // Looping until the 'OlcConfig' class has been found while ( !olcConfigBeanClassFound ) { // Checking if we reached the 'OlcConfig' class if ( beanClass == OlcConfig.class ) { olcConfigBeanClassFound = true; } // Looping on all fields of the bean for ( Field field : beanClass.getDeclaredFields() ) { // Making the field accessible (we get an exception if we don't do that) field.setAccessible( true ); // Looking for the @ConfigurationElement annotation and // if the field is the Rdn ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class ); if ( ( configurationElement != null ) && ( configurationElement.isRdn() ) ) { Object value = field.get( bean ); if ( value == null ) { continue; } // Is the value multiple? if ( isMultiple( value.getClass() ) ) { Collection<?> values = ( Collection<?> ) value; if ( values.isEmpty() ) { String defaultValue = configurationElement.defaultValue(); if ( defaultValue != null ) { value = defaultValue; } else { continue; } } else { value = values.toArray()[0]; } } if ( ( bean.getParentDn() != null ) ) { return bean.getParentDn() .add( new Rdn( configurationElement.attributeType(), value.toString() ) ); } else { return parentDn.add( new Rdn( configurationElement.attributeType(), value.toString() ) ); } } } // Moving to the upper class in the class hierarchy beanClass = beanClass.getSuperclass(); } return Dn.EMPTY_DN; } /** * Gets the name of the object class to use for the given bean class. * * @param clazz the bean class * @return the name of the object class to use for the given bean class */ private String getObjectClassNameForBean( Class<?> clazz ) { String classNameWithPackage = getClassNameWithoutPackageName( clazz ); return Character.toLowerCase( classNameWithPackage.charAt( 0 ) ) + classNameWithPackage.substring( 1 ); } /** * Gets the class name of the given class stripped from its package name. * * @param clazz the class * @return the class name of the given class stripped from its package name */ private String getClassNameWithoutPackageName( Class<?> clazz ) { String className = clazz.getName(); int firstChar = className.lastIndexOf( '.' ) + 1; if ( firstChar > 0 ) { return className.substring( firstChar ); } return className; } /** * Writes the configuration bean as LDIF to the given file. * * @param path the output file path * @throws ConfigurationException if an error occurs during the conversion to LDIF * @throws IOException if an error occurs when writing the file */ public void writeToPath( String path ) throws ConfigurationException, IOException { writeToFile( new File( path ) ); } /** * Writes the configuration bean as LDIF to the given file. * * @param file the output file * @throws ConfigurationException if an error occurs during the conversion to LDIF * @throws IOException if an error occurs when writing the file */ public void writeToFile( File file ) throws ConfigurationException, IOException { // Writing the file to disk try ( FileWriter writer = new FileWriter( file ) ) { writer.append( writeToString() ); } } /** * Writes the configuration to a String object. * * @return a String containing the LDIF representation of the configuration * @throws ConfigurationException if an error occurs during the conversion to LDIF */ public String writeToString() throws ConfigurationException { // Converting the configuration bean to a list of LDIF entries convertConfigurationBeanToLdifEntries( ConfigurationUtils.getConfigurationDn( browserConnection ) ); // Building the StringBuilder StringBuilder sb = new StringBuilder(); sb.append( "version: 1\n" ); for ( LdifEntry entry : entries ) { sb.append( entry.toString() ); } return sb.toString(); } /** * Gets the converted LDIF entries from the configuration bean. * * @param browserConnection the browserConnection * @return the list of converted LDIF entries * @throws ConfigurationException if an error occurs during the conversion to LDIF */ public List<LdifEntry> getConvertedLdifEntries() throws ConfigurationException { // Converting the configuration bean to a list of LDIF entries convertConfigurationBeanToLdifEntries( ConfigurationUtils.getConfigurationDn( browserConnection ) ); // Returning the list of entries return entries; } /** * Gets the converted LDIF entries from the configuration bean. * * @return the list of converted LDIF entries * @throws ConfigurationException if an error occurs during the conversion to LDIF */ public List<LdifEntry> getConvertedLdifEntries( Dn configurationDn ) throws ConfigurationException { // Converting the configuration bean to a list of LDIF entries convertConfigurationBeanToLdifEntries( configurationDn ); // Returning the list of entries return entries; } /** * Adds the computed 'objectClass' attribute for the given entry and object class name. * * @param entry the entry * @param objectClass the object class name * @throws LdapException */ private void addObjectClassAttribute( LdifEntry entry, String objectClass ) throws LdapException { try { ObjectClass objectClassObject = OpenLdapServerConfigurationEditorUtils.getObjectClass( OpenLdapConfigurationPlugin .getDefault().getSchemaManager(), objectClass ); if ( objectClassObject != null ) { // Building the list of 'objectClass' attribute values Set<String> objectClassAttributeValues = new HashSet<>(); computeObjectClassAttributeValues( objectClassAttributeValues, objectClassObject ); // Adding values to the entry addAttributeTypeValues( SchemaConstants.OBJECT_CLASS_AT, objectClassAttributeValues, entry ); } else { // TODO: throw an exception } } catch ( Exception e ) { throw new LdapException( e ); } } /** * Recursively computes the 'objectClass' attribute values set. * * @param schemaManager the schema manager * @param objectClassAttributeValues the set containing the values * @param objectClass the current object class * @throws LdapException */ private void computeObjectClassAttributeValues( Set<String> objectClassAttributeValues, ObjectClass objectClass ) throws LdapException { try { SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager(); ObjectClass topObjectClass = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, SchemaConstants.TOP_OC ); if ( topObjectClass != null ) { // TODO throw new exception (there should be a top object class } if ( topObjectClass.equals( objectClass ) ) { objectClassAttributeValues.add( objectClass.getName() ); } else { objectClassAttributeValues.add( objectClass.getName() ); List<String> superiors = objectClass.getSuperiorOids(); if ( ( superiors != null ) && !superiors.isEmpty() ) { for ( String superior : superiors ) { ObjectClass superiorObjectClass = OpenLdapServerConfigurationEditorUtils.getObjectClass( schemaManager, superior ); computeObjectClassAttributeValues( objectClassAttributeValues, superiorObjectClass ); } } else { objectClassAttributeValues.add( topObjectClass.getName() ); } } } catch ( Exception e ) { throw new LdapException( e ); } } /** * Adds values for an attribute type to the given entry. * * @param attributeType the attribute type * @param value the value * @param entry the entry * @throws org.apache.directory.api.ldap.model.exception.LdapException */ private void addAttributeTypeValues( ConfigurationElement configurationElement, Object o, LdifEntry entry ) throws LdapException { String attributeType = configurationElement.attributeType(); // We don't store a 'null' value if ( o != null ) { // Is the value multiple? if ( isMultiple( o.getClass() ) ) { // Adding each single value separately Collection<?> values = ( Collection<?> ) o; if ( values.isEmpty() ) { if ( !configurationElement.isOptional() ) { // Add the default value addAttributeTypeValue( attributeType, configurationElement.defaultValue(), entry ); } } else { for ( Object value : values ) { addAttributeTypeValue( attributeType, value, entry ); } } } else { // Adding the single value addAttributeTypeValue( attributeType, o, entry ); } } } /** * Adds values for an attribute type to the given entry. * * @param attributeType the attribute type * @param value the value * @param entry the entry * @throws org.apache.directory.api.ldap.model.exception.LdapException */ private void addAttributeTypeValues( String attributeType, Object object, LdifEntry entry ) throws LdapException { // We don't store a 'null' value if ( object != null ) { // Is the value multiple? if ( isMultiple( object.getClass() ) ) { // Adding each single value separately Collection<?> values = ( Collection<?> ) object; for ( Object value : values ) { addAttributeTypeValue( attributeType, value, entry ); } } else { // Adding the single value addAttributeTypeValue( attributeType, object, entry ); } } } /** * Adds a value, either byte[] or another type (converted into a String * via the Object.toString() method), to the attribute. * * @param attributeType the attribute type * @param value the value * @param entry the entry */ private void addAttributeTypeValue( String attributeType, Object value, LdifEntry entry ) throws LdapException { // We don't store a 'null' value if ( value != null ) { // Getting the attribute from the entry Attribute attribute = entry.get( attributeType ); // If no attribute has been found, we need to create it and add it to the entry if ( attribute == null ) { attribute = new DefaultAttribute( attributeType ); entry.addAttribute( attribute ); } // Storing the value to the attribute if ( value instanceof byte[] ) { // Value is a byte[] attribute.add( ( byte[] ) value ); } // Storing the boolean value in UPPERCASE (TRUE or FALSE) to the attribute else if ( value instanceof Boolean ) { // Value is a byte[] attribute.add( value.toString().toUpperCase() ); } else { // Value is another type of object that we store as a String // (There will be an automatic translation for primary types like int, long, etc.) attribute.add( value.toString() ); } } } /** * Indicates the given type is multiple. * * @param clazz the class * @return <code>true</code> if the given is multiple, <code>false</code> if not. */ private boolean isMultiple( Class<?> clazz ) { return Collection.class.isAssignableFrom( clazz ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationUtils.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/io/ConfigurationUtils.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.model.io; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.IConnectionListener; import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry; import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeRootDSERunnable; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; /** * This class implements a configuration reader for OpenLDAP. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConfigurationUtils { private ConfigurationUtils() { // Nothing to do } /** The default OpenLDAP configuration DN */ public static final String DEFAULT_CONFIG_DN = "cn=config"; /** * Gets the configuration DN. * * @param browserConnection the browser connection * @return the configuration DN * @throws ConfigurationException if the configuration DN couldn't be found */ public static Dn getConfigurationDn( IBrowserConnection browserConnection ) throws ConfigurationException { IProgressMonitor progressMonitor = new NullProgressMonitor(); StudioProgressMonitor monitor = new StudioProgressMonitor( progressMonitor ); // Opening the connection (if needed) openConnection( browserConnection.getConnection(), monitor ); // Load Root DSE (if needed) if ( browserConnection.getRootDSE() == null ) { InitializeRootDSERunnable.loadRootDSE( browserConnection, monitor ); } // Getting the Root DSE IRootDSE rootDse = browserConnection.getRootDSE(); try { // Getting the 'configcontext' attribute IAttribute configContextAttribute = rootDse.getAttribute( "configcontext" ); if ( ( configContextAttribute != null ) && ( configContextAttribute.getValueSize() > 0 ) ) { return new Dn( configContextAttribute.getStringValue() ); } else { return getDefaultConfigurationDn(); } } catch ( LdapInvalidDnException e ) { throw new ConfigurationException( e ); } } /** * Gets the default configuration DN. * * @return the default configuration DN * @throws ConfigurationException if an error occurred */ public static Dn getDefaultConfigurationDn() throws ConfigurationException { try { return new Dn( DEFAULT_CONFIG_DN ); } catch ( LdapInvalidDnException e ) { throw new ConfigurationException( e ); } } /** * Opens the connection. * * @param connection the connection * @param monitor the monitor */ public static void openConnection( Connection connection, StudioProgressMonitor monitor ) { if ( connection != null && !connection.getConnectionWrapper().isConnected() ) { connection.getConnectionWrapper().connect( monitor ); if ( connection.getConnectionWrapper().isConnected() ) { connection.getConnectionWrapper().bind( monitor ); } if ( connection.getConnectionWrapper().isConnected() ) { for ( IConnectionListener listener : ConnectionCorePlugin.getDefault() .getConnectionListeners() ) { listener.connectionOpened( connection, monitor ); } ConnectionEventRegistry.fireConnectionOpened( connection, null ); } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/AbstractServerConfigurationInput.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/AbstractServerConfigurationInput.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IPersistableElement; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition; /** * This class represents the Server Configuration Input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractServerConfigurationInput implements ServerConfigurationInput { /** The original configuration partition */ protected EntryBasedConfigurationPartition originalPartition; /** * {@inheritDoc} */ public EntryBasedConfigurationPartition getOriginalPartition() { return originalPartition; } /** * {@inheritDoc} */ public void setOriginalPartition( EntryBasedConfigurationPartition originalPartition ) { this.originalPartition = originalPartition; } /** * {@inheritDoc} */ public String getToolTipText() { return getName(); } /** * {@inheritDoc} */ public String getName() { return "OpenLDAP Configuration"; } /** * {@inheritDoc} */ public boolean exists() { return true; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return OpenLdapConfigurationPlugin.getDefault().getImageDescriptor( OpenLdapConfigurationPluginConstants.IMG_EDITOR ); } /** * {@inheritDoc} */ public IPersistableElement getPersistable() { return null; } /** * {@inheritDoc} */ public Object getAdapter( Class adapter ) { return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OpenLdapServerConfigurationEditor.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OpenLdapServerConfigurationEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import java.lang.reflect.InvocationTargetException; import java.util.Enumeration; import org.apache.directory.studio.common.core.jobs.StudioJob; import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.openldap.config.editor.databases.ConfigPage; import org.apache.directory.studio.openldap.config.editor.databases.FrontendPage; import org.apache.directory.studio.openldap.config.editor.pages.DatabasesPage; import org.apache.directory.studio.openldap.config.editor.pages.ErrorPage; import org.apache.directory.studio.openldap.config.editor.pages.LoadingPage; import org.apache.directory.studio.openldap.config.editor.pages.OpenLDAPServerConfigurationEditorPage; import org.apache.directory.studio.openldap.config.editor.pages.OptionsPage; import org.apache.directory.studio.openldap.config.editor.pages.OverviewPage; import org.apache.directory.studio.openldap.config.editor.pages.SecurityPage; import org.apache.directory.studio.openldap.config.editor.pages.TuningPage; import org.apache.directory.studio.openldap.config.jobs.LoadConfigurationRunnable; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.io.SaveConfigurationRunnable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.IPageChangedListener; import org.eclipse.jface.dialogs.PageChangedEvent; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.forms.editor.FormEditor; /** * This class implements the Server Configuration Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenLdapServerConfigurationEditor extends FormEditor implements IPageChangedListener { /** The Editor ID */ public static final String ID = OpenLdapServerConfigurationEditor.class.getName(); /** The flag indicating if the editor is dirty */ private boolean dirty = false; /** The configuration */ private OpenLdapConfiguration configuration; // The pages for the Open LDAP configuration /** The Overview page */ private OverviewPage overviewPage; /** The page which is used for loading the configuration */ private LoadingPage loadingPage; /** The Frontend database page */ private FrontendPage frontendPage; /** The Config database page */ private ConfigPage configPage; /** The page showing the user's databases */ private DatabasesPage databasesPage; /** The options page */ private OptionsPage optionsPage; /** The Security page */ private SecurityPage securityPage; /** The Tuning page */ private TuningPage tuningPage; /** * {@inheritDoc} */ @Override public void init( IEditorSite site, IEditorInput input ) throws PartInitException { super.init( site, input ); setPartName( input.getName() ); // Checking if the input is a new server configuration file // New server configuration file have a dirty state // set to true since they are not saved yet setDirty( input instanceof NewServerConfigurationInput ); addPageChangedListener( this ); readConfiguration(); } /** * Reads the configuration */ private void readConfiguration() { // Creating and scheduling the job to load the configuration StudioJob<StudioRunnableWithProgress> job = new StudioJob<>( new LoadConfigurationRunnable( this ) ); job.schedule(); } /** * {@inheritDoc} */ public void pageChanged( PageChangedEvent event ) { Object selectedPage = event.getSelectedPage(); if ( selectedPage instanceof OpenLDAPServerConfigurationEditorPage ) { ( ( OpenLDAPServerConfigurationEditorPage ) selectedPage ).refreshUI(); } } /** * {@inheritDoc} */ protected void addPages() { try { loadingPage = new LoadingPage( this ); addPage( loadingPage ); } catch ( PartInitException e ) { } showOrHideTabFolder(); } /** * Shows or hides the tab folder depending on * the number of pages. If we have one page * only, then we show the tab, otherwise, we hide * it. */ private void showOrHideTabFolder() { Composite container = getContainer(); if ( container instanceof CTabFolder ) { CTabFolder folder = ( CTabFolder ) container; if ( getPageCount() == 1 ) { folder.setTabHeight( 0 ); } else { folder.setTabHeight( -1 ); } folder.layout( true, true ); } } /** * {@inheritDoc} */ public void doSave( IProgressMonitor monitor ) { // Saving pages doSavePages( monitor ); // Saving the configuration using a job StudioJob<StudioRunnableWithProgress> job = new StudioJob<>( new SaveConfigurationRunnable( this ) ); job.schedule(); } /** * {@inheritDoc} */ public void doSaveAs() { try { getSite().getWorkbenchWindow().run( false, false, new IRunnableWithProgress() { public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { monitor.beginTask( "Saving Server Configuration", IProgressMonitor.UNKNOWN ); doSaveAs( monitor ); monitor.done(); } catch ( Exception e ) { // TODO handle the exception } } } ); } catch ( Exception e ) { // TODO handle the exception e.printStackTrace(); } } /** * Performs the "Save as..." action. * * @param monitor the monitor to use * @throws Exception */ public void doSaveAs( IProgressMonitor monitor ) throws Exception { // Saving pages doSavePages( monitor ); // Saving the configuration as a new file and getting the associated new editor input IEditorInput newInput = OpenLdapServerConfigurationEditorUtils.saveAs( getConfiguration(), getSite().getShell(), true ); // Checking if the 'save as' is successful if ( newInput != null ) { // Setting the new input to the editor setInput( newInput ); // Resetting the dirty state of the editor setDirty( false ); // Updating the title and tooltip texts Display.getDefault().syncExec( () -> setPartName( getEditorInput().getName() ) ); } } /** * Saves the pages. * * @param monitor the monitor */ private void doSavePages( IProgressMonitor monitor ) { if ( databasesPage != null ) { databasesPage.doSave( monitor ); } if ( frontendPage != null ) { frontendPage.doSave( monitor ); } if ( securityPage != null ) { securityPage.doSave( monitor ); } if ( tuningPage != null ) { tuningPage.doSave( monitor ); } if ( configPage != null ) { configPage.doSave( monitor ); } } /** * {@inheritDoc} */ public boolean isSaveAsAllowed() { return true; } /** * {@inheritDoc} */ @Override public boolean isDirty() { return dirty; } /** * Sets the 'dirty' flag. * * @param dirty the 'dirty' flag */ public void setDirty( boolean dirty ) { this.dirty = dirty; Display.getDefault().asyncExec( () -> firePropertyChange( PROP_DIRTY ) ); } /** * Gets the configuration. * * @return the configuration */ public OpenLdapConfiguration getConfiguration() { return configuration; } /** * Sets the configuration. * * @param configuration the configuration */ public void setConfiguration( OpenLdapConfiguration configuration ) { this.configuration = configuration; } /** * Resets the configuration and refresh the UI. * * @param configBean the configuration bean */ public void resetConfiguration( OpenLdapConfiguration configuration ) { setConfiguration( configuration ); setDirty( true ); overviewPage.refreshUI(); optionsPage.refreshUI(); databasesPage.refreshUI(); frontendPage.refreshUI(); securityPage.refreshUI(); tuningPage.refreshUI(); configPage.refreshUI(); } /** * This method is called by the job responsible for loading the * configuration when it has been fully and correctly loaded. * * @param configBean the loaded configuration bean */ public void configurationLoaded( OpenLdapConfiguration configuration ) { setConfiguration( configuration ); hideLoadingPageAndDisplayConfigPages(); } /** * This method is called by the job responsible for loading the * configuration when it failed to load it. * * @param exception the exception */ public void configurationLoadFailed( Exception exception ) { // Overriding the default dirty setting // (especially in the case of a new configuration file) setDirty( false ); hideLoadingPageAndDisplayErrorPage( exception ); } /** * Hides the loading page and displays the standard configuration pages. */ private void hideLoadingPageAndDisplayConfigPages() { // Removing the loading page removePage( 0 ); // Adding the configuration pages try { overviewPage = new OverviewPage( this ); addPage( overviewPage); databasesPage = new DatabasesPage( this ); addPage( databasesPage ); securityPage = new SecurityPage( this ); addPage( securityPage ); tuningPage = new TuningPage( this ); addPage( tuningPage ); optionsPage = new OptionsPage( this ); addPage( optionsPage ); } catch ( PartInitException e ) { // Will never happen } // Activating the first page setActivePage( 0 ); showOrHideTabFolder(); } /** * Hides the loading page and displays the error page. * * @param exception the exception */ private void hideLoadingPageAndDisplayErrorPage( Exception exception ) { // Removing the loading page removePage( 0 ); // Adding the error page try { addPage( new ErrorPage( this, exception ) ); } catch ( PartInitException e ) { } // Activating the first page setActivePage( 0 ); showOrHideTabFolder(); } /** * Set a particular page as active if it is found in the pages vector. * * @param pageClass the class of the page */ public void showPage( Class<?> pageClass ) { if ( pageClass != null ) { Enumeration<?> enumeration = pages.elements(); while ( enumeration.hasMoreElements() ) { Object page = enumeration.nextElement(); if ( pageClass.isInstance( page ) ) { setActivePage( pages.indexOf( page ) ); return; } } } } /** * Gets the connection. * * @return the connection */ public Connection getConnection() { IEditorInput editorInput = getEditorInput(); if ( editorInput instanceof ConnectionServerConfigurationInput ) { return ( ( ConnectionServerConfigurationInput ) editorInput ).getConnection(); } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OpenLdapServerConfigurationEditorUtils.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/OpenLdapServerConfigurationEditorUtils.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import java.io.File; import java.io.IOException; import java.util.List; import java.util.UUID; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.api.ldap.model.csn.CsnFactory; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.ldif.LdifEntry; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.SchemaManager; import org.apache.directory.api.ldap.model.schema.registries.ObjectClassRegistry; import org.apache.directory.api.ldap.util.tree.DnNode; import org.apache.directory.api.util.DateUtils; import org.apache.directory.api.util.TimeProvider; import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.common.ui.filesystem.PathEditorInput; import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.config.ExpandedLdifUtils; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition; import org.apache.directory.studio.openldap.config.jobs.PartitionsDiffComputer; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.io.ConfigurationException; import org.apache.directory.studio.openldap.config.model.io.ConfigurationReader; import org.apache.directory.studio.openldap.config.model.io.ConfigurationUtils; import org.apache.directory.studio.openldap.config.model.io.ConfigurationWriter; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; /** * This class contains helpful methods for the Server Configuration Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenLdapServerConfigurationEditorUtils { private OpenLdapServerConfigurationEditorUtils() { // Do nothing } /** * Opens a {@link FileDialog} in the UI thread. * * @param shell the shell * @return the result of the dialog */ private static String openFileDialogInUIThread( final Shell shell ) { // Defining our own encapsulating class for the result class DialogResult { private String result; public String getResult() { return result; } public void setResult( String result ) { this.result = result; } } // Creating an object to hold the result final DialogResult result = new DialogResult(); // Opening the dialog in the UI thread Display.getDefault().syncExec( () -> { FileDialog dialog = new FileDialog( shell, SWT.SAVE ); result.setResult( dialog.open() ); } ); return result.getResult(); } /** * Performs the "Save as..." action. * * @param configuration the configuration * @param newInput a flag to indicate if a new input is required * @return the new input for the editor * @throws Exception */ public static IEditorInput saveAs( OpenLdapConfiguration configuration, Shell shell, boolean newInput ) throws Exception { // detect IDE or RCP: // check if perspective org.eclipse.ui.resourcePerspective is available boolean isIDE = CommonUIUtils.isIDEEnvironment(); String path = null; if ( isIDE ) { } else { boolean canOverwrite = false; while ( !canOverwrite ) { // Opening the dialog // Open FileDialog path = openFileDialogInUIThread( shell ); // Checking the returned path if ( path == null ) { // Cancel button has been clicked return null; } // Getting the directory indicated by the user final File directory = new File( path ); // Checking if the directory exists if ( !directory.exists() ) { CommonUIUtils.openErrorDialog( "The directory does not exist." ); continue; } // Checking if the location is a directory if ( !directory.isDirectory() ) { CommonUIUtils.openErrorDialog( "The location is not a directory." ); continue; } // Checking if the directory is writable if ( !directory.canWrite() ) { CommonUIUtils.openErrorDialog( "The directory is not writable." ); continue; } // Checking if the directory is empty if ( !isEmpty( directory ) ) { CommonUIUtils.openErrorDialog( "The directory is not empty." ); continue; } // The directory meets all requirements break; } } // Saving the file to disk saveConfiguration( configuration, new File( path ) ); // Checking if a new input is required if ( newInput ) { // Creating the new input for the editor return new PathEditorInput( new Path( path ) ); } else { return null; } } private static boolean isEmpty( File directory ) { if ( directory != null ) { String[] children = directory.list( ( dir, name ) -> // Only accept visible files (which don't start with a dot). !name.startsWith( "." ) ); return ( ( children == null ) || ( children.length == 0 ) ); } return false; } /** * Opens a {@link DirectoryDialog} in the UI thread. * * @param dialog the directory dialog * @return the result of the dialog */ private static String openDirectoryDialogInUIThread( final DirectoryDialog dialog ) { // Defining our own encapsulating class for the result class DialogResult { private String result; public String getResult() { return result; } public void setResult( String result ) { this.result = result; } } // Creating an object to hold the result final DialogResult result = new DialogResult(); // Opening the dialog in the UI thread Display.getDefault().syncExec( () -> result.setResult( dialog.open() ) ); return result.getResult(); } /** * Saves the configuration. * * @param configuration the configuration * @param directory the directory * @throws Exception */ public static void saveConfiguration( OpenLdapConfiguration configuration, File directory ) throws Exception { saveConfiguration( null, configuration, directory ); } /** * Saves the configuration. * * @param browserConnection the browser connection * @param configurationthe configuration * @param directory the directory * @throws Exception */ public static void saveConfiguration( IBrowserConnection browserConnection, OpenLdapConfiguration configuration, File directory ) throws Exception { // Creating the configuration writer ConfigurationWriter configurationWriter = new ConfigurationWriter( browserConnection, configuration ); SchemaManager schemaManager = OpenLdapConfigurationPlugin.getDefault().getSchemaManager(); // Converting the configuration beans to entries List<LdifEntry> entries = configurationWriter.getConvertedLdifEntries( ConfigurationUtils .getDefaultConfigurationDn() ); // Creating a tree to store entries DnNode<Entry> tree = new DnNode<>(); CsnFactory csnFactory = new CsnFactory( 1 ); for ( LdifEntry entry : entries ) { // Getting the current generalized time String currentgeGeneralizedTime = DateUtils.getGeneralizedTime( TimeProvider.DEFAULT ); // 'createTimestamp' attribute entry.addAttribute( "createTimestamp", currentgeGeneralizedTime ); // 'creatorsName' attribute entry.addAttribute( "creatorsName", "cn=config" ); // 'entryCSN' attribute entry.addAttribute( "entryCSN", csnFactory.newInstance().toString() ); // 'entryUUID' attribute entry.addAttribute( "entryUUID", UUID.randomUUID().toString() ); // 'modifiersName' attribute entry.addAttribute( "modifiersName", "cn=config" ); // 'modifyTimestamp' attribute entry.addAttribute( "modifyTimestamp", currentgeGeneralizedTime ); // 'structuralObjectClass' attribute entry.addAttribute( "structuralObjectClass", getStructuralObjectClass( entry ) ); // Adding the entry to tree tree.add( new Dn( schemaManager, entry.getDn() ), entry.getEntry() ); } try { Dn rootDn = ConfigurationUtils.getDefaultConfigurationDn(); ExpandedLdifUtils.write( tree, new Dn( schemaManager, rootDn ), directory ); } catch ( ConfigurationException e ) { throw new IOException( e ); } } /** * Gets the structural object class of the entry. * * @param ldifEntry the LDIF entry * @return the structural object class of the entry * @throws ConfigurationException */ private static Object getStructuralObjectClass( LdifEntry ldifEntry ) throws ConfigurationException { if ( ldifEntry != null ) { Entry entry = ldifEntry.getEntry(); if ( entry != null ) { ObjectClass structuralObjectClass = ConfigurationReader .getHighestStructuralObjectClass( entry.get( SchemaConstants.OBJECT_CLASS_AT ) ); if ( structuralObjectClass != null ) { return structuralObjectClass.getName(); } } } return SchemaConstants.TOP_OC; } /** * Saves the configuration. * * @param input the connection server configuration input * @param editor the editor * @param monitor the monitor * @return <code>true</code> if the operation is successful, <code>false</code> if not * @throws Exception */ public static void saveConfiguration( ConnectionServerConfigurationInput input, OpenLdapServerConfigurationEditor editor, IProgressMonitor monitor ) throws Exception { // Getting the browser connection associated with the connection in the input IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( input.getConnection() ); // Creating the configuration writer ConfigurationWriter configurationWriter = new ConfigurationWriter( browserConnection, editor.getConfiguration() ); // Getting the original configuration partition and its schema manager EntryBasedConfigurationPartition originalPartition = input.getOriginalPartition(); SchemaManager schemaManager = originalPartition.getSchemaManager(); // Suspends event firing in current thread. ConnectionEventRegistry.suspendEventFiringInCurrentThread(); try { // Creating a new configuration partition EntryBasedConfigurationPartition modifiedPartition = createConfigurationPartition( schemaManager, originalPartition.getSuffixDn() ); for ( LdifEntry ldifEntry : configurationWriter.getConvertedLdifEntries() ) { modifiedPartition.addEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) ); } // Comparing both partitions to get the list of modifications to be applied List<LdifEntry> modificationsList = PartitionsDiffComputer.computeModifications( originalPartition, modifiedPartition, new String[] { SchemaConstants.ALL_USER_ATTRIBUTES } ); // Building the resulting LDIF StringBuilder modificationsLdif = new StringBuilder(); for ( LdifEntry ldifEntry : modificationsList ) { modificationsLdif.append( ldifEntry.toString() ); } // Creating a StudioProgressMonitor to run the LDIF with StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( new NullProgressMonitor() ); // Updating the configuration with the resulting LDIF ExecuteLdifRunnable.executeLdif( browserConnection, modificationsLdif.toString(), true, true, studioProgressMonitor ); // Checking if there were errors during the execution of the LDIF if ( studioProgressMonitor.errorsReported() ) { StringBuilder message = new StringBuilder(); message.append( "Changes could not be saved to the connection." ); Exception exception = studioProgressMonitor.getException(); if ( exception != null ) { message.append( "\n\n" ); message.append( "Cause: " ); message.append( exception.getMessage() ); throw new Exception( message.toString(), exception ); } else { throw new Exception( message.toString() ); } } else { // Swapping the new configuration partition input.setOriginalPartition( modifiedPartition ); } } finally { // Resumes event firing in current thread. ConnectionEventRegistry.resumeEventFiringInCurrentThread(); } } /** * Creates a configuration partition to store configuration entries. * * @param schemaManager the schema manager * @param configBaseDn the configuration base DN * @return a configuration partition to store configuration entries * @throws LdapException */ public static EntryBasedConfigurationPartition createConfigurationPartition( SchemaManager schemaManager, Dn configBaseDn ) throws LdapException { EntryBasedConfigurationPartition configurationPartition = new EntryBasedConfigurationPartition( schemaManager, configBaseDn ); configurationPartition.initialize(); return configurationPartition; } /** * Gets the object class for the given name. * * @param schemaManager the schema manager * @param name the name * @return the object class for the given name */ public static ObjectClass getObjectClass( SchemaManager schemaManager, String name ) { // Checking the schema manager and name if ( ( schemaManager != null ) && ( name != null ) ) { try { // Getting the object class registry ObjectClassRegistry ocRegistry = schemaManager.getObjectClassRegistry(); if ( ocRegistry != null ) { // Getting the oid from the object class name String oid = ocRegistry.getOidByName( name ); if ( oid != null ) { // Getting the object class from the oid return ocRegistry.get( oid ); } } } catch ( LdapException e ) { // No OID found for the given name return null; } } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/Messages.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/Messages.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { private Messages() { // Do nothing } /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ServerConfigurationInput.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import org.apache.directory.studio.openldap.config.jobs.EntryBasedConfigurationPartition; import org.eclipse.ui.IEditorInput; /** * This class represents the Server Configuration Input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface ServerConfigurationInput extends IEditorInput { /** * Gets the original configuration partition. * * @return the original configuration partition */ EntryBasedConfigurationPartition getOriginalPartition(); /** * Sets the original configuration partition. * * @param originalPartition the original configuration */ void setOriginalPartition( EntryBasedConfigurationPartition originalPartition ); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/NewServerConfigurationInput.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/NewServerConfigurationInput.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import org.apache.directory.studio.openldap.config.model.OpenLdapConfigFormat; import org.apache.directory.studio.openldap.config.model.OpenLdapVersion; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; /** * This class represents the Non Existing Server Configuration Input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewServerConfigurationInput implements IEditorInput { /** The selected version */ private OpenLdapVersion openLdapVersion; /** The file format*/ private OpenLdapConfigFormat openLdapConfigFormat; /** * {@inheritDoc} */ public String getToolTipText() { return Messages.getString( "NewServerConfigurationInput.NewOpenLDAPConfigurationFile" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public String getName() { return Messages.getString( "NewServerConfigurationInput.NewOpenLDAPConfigurationFile" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean exists() { return true; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return null; } /** * {@inheritDoc} */ public IPersistableElement getPersistable() { return null; } /** * {@inheritDoc} */ @SuppressWarnings("rawtypes") public Object getAdapter( Class adapter ) { return null; } /** * @return the openLdapVersion */ public OpenLdapVersion getOpenLdapVersion() { return openLdapVersion; } /** * @param openLdapVersion the openLdapVersion to set */ public void setOpenLdapVersion( OpenLdapVersion openLdapVersion ) { this.openLdapVersion = openLdapVersion; } /** * @return the openLdapConfigFomat */ public OpenLdapConfigFormat getOpenLdapConfigFormat() { return openLdapConfigFormat; } /** * @param openLdapConfigFomat the openLdapConfigFomat to set */ public void setOpenLdapConfigFormat( OpenLdapConfigFormat openLdapConfigFormat ) { this.openLdapConfigFormat = openLdapConfigFormat; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ConnectionServerConfigurationInput.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/ConnectionServerConfigurationInput.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import org.apache.directory.studio.connection.core.Connection; import org.eclipse.osgi.util.NLS; /** * This class represents the Non Existing Server Configuration Input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConnectionServerConfigurationInput extends AbstractServerConfigurationInput { /** The connection */ private Connection connection; /** * Creates a new instance of ConnectionServerConfigurationInput. * * @param connection the connection */ public ConnectionServerConfigurationInput( Connection connection ) { this.connection = connection; } /** * Gets the connection. * * @return * the connection */ public Connection getConnection() { return connection; } /** * {@inheritDoc} */ @Override public String getToolTipText() { return NLS.bind( "{0} - Configuration", connection.getName() ); } /** * {@inheritDoc} */ @Override public String getName() { return NLS.bind( "{0} - Configuration", connection.getName() ); } /** * {@inheritDoc} */ @Override public boolean exists() { return connection != null; } /** * {@inheritDoc} */ public boolean equals( Object obj ) { if ( obj == null ) { return false; } if ( obj instanceof ConnectionServerConfigurationInput ) { ConnectionServerConfigurationInput input = ( ConnectionServerConfigurationInput ) obj; if ( input.exists() && exists() ) { Connection inputConnection = input.getConnection(); if ( inputConnection != null ) { return inputConnection.equals( connection ); } } } return false; } /** * {@inheritDoc} */ public int hashCode() { return connection.hashCode(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/DirectoryServerConfigurationInput.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor; import java.io.File; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.eclipse.jface.resource.ImageDescriptor; /** * This class represents the Directory Server Configuration Input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DirectoryServerConfigurationInput extends AbstractServerConfigurationInput { /** The directory */ private File directory; /** * Creates a new instance of DirectoryServerConfigurationInput. * * @param directory * the directory */ public DirectoryServerConfigurationInput( File directory ) { this.directory = directory; } /** * Gets the directory. * * @return * the directory */ public File getDirectory() { return directory; } /** * {@inheritDoc} */ @Override public String getToolTipText() { if ( directory != null ) { return directory.toString(); } return getName(); } /** * {@inheritDoc} */ @Override public String getName() { if ( directory != null ) { return directory.getName(); } return "OpenLDAP Configuration"; } /** * {@inheritDoc} */ @Override public boolean exists() { return directory != null; } /** * {@inheritDoc} */ @Override public ImageDescriptor getImageDescriptor() { return OpenLdapConfigurationPlugin.getDefault().getImageDescriptor( OpenLdapConfigurationPluginConstants.IMG_EDITOR ); } /** * {@inheritDoc} */ public boolean equals( Object obj ) { if ( obj == null ) { return false; } if ( obj instanceof DirectoryServerConfigurationInput ) { DirectoryServerConfigurationInput input = ( DirectoryServerConfigurationInput ) obj; if ( input.exists() && exists() ) { File inputDirectory = input.getDirectory(); if ( inputDirectory != null ) { return inputDirectory.equals( directory ); } } } return false; } /** * {@inheritDoc} */ public int hashCode() { if ( directory != null ) { return directory.hashCode(); } return super.hashCode(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.CommonUIConstants; import org.apache.directory.studio.common.ui.CommonUIPlugin; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.config.editor.wrappers.DbIndexDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.DbIndexWrapper; import org.apache.directory.studio.openldap.config.model.database.OlcMdbConfig; import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget; import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget; import org.apache.directory.studio.openldap.common.ui.widgets.UnixPermissionsWidget; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; /** * This class implements a block for Memory-Mapped DB Specific Details. The GUI will * look like : * * <pre> * .--------------------------------------------------------------------. * | Database Specific Settings | * +--------------------------------------------------------------------+ * | .----------------------------------------------------------------. | * | |v MDB Configuration | | * | +----------------------------------------------------------------+ | * | | Directory : [////////////////////////////[v] (Browse) | | * | | Mode : [--------(0000) ] (Edit Permissions) | | * | +----------------------------------------------------------------+ | * | | * | v Database indices | * | +----------------------------------------------+ | * | | indice 1 | (Add) | * | | indice 2 | (Edit) | * | | ... | (Delete) | * | +----------------------------------------------+ | * | | * | v Database Limits | * | Maximum Readers : [ ] | * | Maximum Size : [ ] | * | Maximum Entry Size : [ ] | (2.4.41) * | Search Stack Depth : [ ] | * | Checkpoint Interval : [ ] | * | | * | v Database Options | * | Disable Synchronous Database Writes : [----------] | * | Environment Flags : | (2.4.33) * | +----------------------------------------------+ | * | | Flag 1 | (Add) | * | | Flag 2 | (Edit) | * | | ... | (Delete) | * | +----------------------------------------------+ | * +--------------------------------------------------------------------+ * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MdbDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcMdbConfig> { // UI Widgets /** The olcDbDirectory attribute (String) */ private DirectoryBrowserWidget directoryBrowserWidget; /** The olcDbCheckpoint attribute (String) */ private Text checkpointText; /** The olcDbEnvFlags attribute (String, multi-values) */ private Text envFlagsText; /** The olcDbIndex attribute (String, multi-values) */ private TableWidget<DbIndexWrapper> indicesWidget; /** The olcMaxEntrySize attribute (Integer) No yet available (2.4.41) */ private Text maxEntrySizeText; /** The olcDbMaxReaders attribute (Integer) */ private Text maxReadersText; /** The olcMaxSize attribute (Long) */ private Text maxSizeText; /** The olcDbMode attribute (String) */ private UnixPermissionsWidget modeUnixPermissionsWidget; /** The olcDbNoSync attribute (Boolean) */ private BooleanWithDefaultWidget disableSynchronousDatabaseWritesBooleanWithDefaultWidget; /** The olcDbSearchStack attribute( Integer) */ private Text searchStackDepthText; /** * The olcAllows listener */ private WidgetModifyListener indexesListener = event -> { List<String> indices = new ArrayList<>(); for ( DbIndexWrapper dbIndex : indicesWidget.getElements() ) { indices.add( dbIndex.toString() ); } database.setOlcDbIndex( indices ); }; /** * Creates a new instance of MdbDatabaseSpecificDetailsBlock. * * @param databaseDetailsPage the database details page * @param database the database * @param browserConnection the connection */ public MdbDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcMdbConfig database, IBrowserConnection browserConnection ) { super( detailsPage, database, browserConnection ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); createDatabaseConfigurationSection( composite, toolkit ); createDatabaseIndexesSection( composite, toolkit ); createDatabaseLimitsSection( composite, toolkit ); createDatabaseOptionsSection( composite, toolkit ); return composite; } /** * Creates the database configuration section. We manage the following configuration elements : * <ul> * <li>Directory : the directory on disk where the file will be stored</li> * <li>mode : the file mode for this directory</li> * </ul> * It covers the following attributes : * <ul> * <li>olcDbDirectory</li> * <li>olcDbMode</li> * </ul> * * <pre> * .------------------------------------------------------------------. * |v MDB Configuration | * +------------------------------------------------------------------+ * | Directory : [///////////////////////////////] (Browse) | * | Mode : [///////////////////////////////] (Edit Permissions) | * +------------------------------------------------------------------+ * </pre * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseConfigurationSection( Composite parent, FormToolkit toolkit ) { // Database Configuration Section Section databaseConfigurationSection = toolkit.createSection( parent, Section.TWISTIE ); databaseConfigurationSection.setText( Messages.getString( "OpenLDAPMDBConfiguration.Section" ) ); databaseConfigurationSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseConfigurationComposite = toolkit.createComposite( databaseConfigurationSection ); toolkit.paintBordersFor( databaseConfigurationComposite ); databaseConfigurationComposite.setLayout( new GridLayout( 2, false ) ); databaseConfigurationSection.setClient( databaseConfigurationComposite ); // Directory Text. This is a MUST attribute (it will be red and bold) Label olcDirectory = toolkit.createLabel( databaseConfigurationComposite, Messages.getString( "OpenLDAPMDBConfiguration.Directory" ) ); olcDirectory.setForeground( CommonUIPlugin.getDefault().getColor( CommonUIConstants.ERROR_COLOR ) ); FontDescriptor boldDescriptor = FontDescriptor.createFrom( olcDirectory.getFont() ).setStyle( SWT.BOLD ); Font boldFont = boldDescriptor.createFont( olcDirectory.getDisplay() ); olcDirectory.setFont( boldFont ); Composite directoryComposite = toolkit.createComposite( databaseConfigurationComposite ); GridLayout directoryCompositeGridLayout = new GridLayout( 2, false ); directoryCompositeGridLayout.marginHeight = directoryCompositeGridLayout.marginWidth = 0; directoryCompositeGridLayout.verticalSpacing = 0; directoryComposite.setLayout( directoryCompositeGridLayout ); directoryComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); directoryBrowserWidget = new DirectoryBrowserWidget( "" ); directoryBrowserWidget.createWidget( directoryComposite, toolkit ); // Mode Text toolkit.createLabel( databaseConfigurationComposite, Messages.getString( "OpenLDAPMDBConfiguration.Mode" ) ); modeUnixPermissionsWidget = new UnixPermissionsWidget(); modeUnixPermissionsWidget.create( databaseConfigurationComposite, toolkit ); modeUnixPermissionsWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database indexes section. * It covers the following attribute : * <ul> * <li>olcDbIndex</li> * </ul> * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseIndexesSection( Composite parent, FormToolkit toolkit ) { // Database Indices Section Section databaseIndexesSection = toolkit.createSection( parent, Section.TWISTIE ); databaseIndexesSection.setText( Messages.getString( "OpenLDAPMDBConfiguration.IndicesSection" ) ); databaseIndexesSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseIndexesComposite = toolkit.createComposite( databaseIndexesSection ); toolkit.paintBordersFor( databaseIndexesComposite ); databaseIndexesComposite.setLayout( new GridLayout( 2, false ) ); databaseIndexesSection.setClient( databaseIndexesComposite ); // Indices Widget indicesWidget = new TableWidget<>( new DbIndexDecorator( null, browserConnection ) ); indicesWidget.createWidgetWithEdit( databaseIndexesComposite, toolkit ); indicesWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); indicesWidget.addWidgetModifyListener( indexesListener ); } /** * Creates the database limits section. * It covers the following attributes : * <ul> * <li>olcDbCheckpoint</li> * <li>olcDbMaxEntrySize (for OpenLDAP 2.4.41)</li> * <li>olcDbMaxReaders</li> * <li>olcDbMaxSize</li> * <li>olcDbSearchStack</li> * </ul> * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseLimitsSection( Composite parent, FormToolkit toolkit ) { // Database Limits Section Section databaseLimitsSection = toolkit.createSection( parent, Section.TWISTIE ); databaseLimitsSection.setText( "Database Limits" ); databaseLimitsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseLimitsComposite = toolkit.createComposite( databaseLimitsSection ); toolkit.paintBordersFor( databaseLimitsComposite ); databaseLimitsComposite.setLayout( new GridLayout( 2, false ) ); databaseLimitsSection.setClient( databaseLimitsComposite ); // Max Readers Text toolkit.createLabel( databaseLimitsComposite, "Maximum Readers:" ); maxReadersText = BaseWidgetUtils.createIntegerText( toolkit, databaseLimitsComposite ); maxReadersText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Max Size Text toolkit.createLabel( databaseLimitsComposite, "Maximum Size:" ); maxSizeText = BaseWidgetUtils.createIntegerText( toolkit, databaseLimitsComposite ); maxSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); if ( browserConnection.getSchema().hasAttributeTypeDescription( "olcDbMaxEntrySize" ) ) { // Max Entry Size Text toolkit.createLabel( databaseLimitsComposite, "Maximum Entry Size:" ); maxEntrySizeText = BaseWidgetUtils.createIntegerText( toolkit, databaseLimitsComposite ); maxEntrySizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } // Search Stack Depth Text toolkit.createLabel( databaseLimitsComposite, "Search Stack Depth:" ); searchStackDepthText = BaseWidgetUtils.createIntegerText( toolkit, databaseLimitsComposite ); searchStackDepthText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Checkpoint Text toolkit.createLabel( databaseLimitsComposite, "Checkpoint Interval:" ); checkpointText = toolkit.createText( databaseLimitsComposite, "" ); checkpointText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database options section. * It covers the following attributes : * <ul> * <li>olcDbNoSync</li> * <li>olcDbEnvFlags (for OpenLDAP 2.4.33)</li> * </ul> * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseOptionsSection( Composite parent, FormToolkit toolkit ) { // Database Options Section Section databaseOptionsSection = toolkit.createSection( parent, Section.TWISTIE ); databaseOptionsSection.setText( "Database Options" ); databaseOptionsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseOptionsComposite = toolkit.createComposite( databaseOptionsSection ); toolkit.paintBordersFor( databaseOptionsComposite ); databaseOptionsComposite.setLayout( new GridLayout( 2, false ) ); databaseOptionsSection.setClient( databaseOptionsComposite ); // Disable Synchronous Database Writes Widget toolkit.createLabel( databaseOptionsComposite, "Disable Synchronous Database Writes:" ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.create( databaseOptionsComposite, toolkit ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Env flags here... } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { // Directory Text String directory = database.getOlcDbDirectory(); directoryBrowserWidget.setDirectoryPath( ( directory == null ) ? "" : directory ); // Mode Text String mode = database.getOlcDbMode(); modeUnixPermissionsWidget.setValue( mode ); // Indices Text List<DbIndexWrapper> dbIndexWrappers = new ArrayList<>(); for ( String index : database.getOlcDbIndex() ) { dbIndexWrappers.add( new DbIndexWrapper( index ) ); } indicesWidget.setElements( dbIndexWrappers ); // Max Readers Text Integer maxReaders = database.getOlcDbMaxReaders(); maxReadersText.setText( ( maxReaders == null ) ? "" : maxReaders.toString() ); //$NON-NLS-1$ // Max Size Text Long maxSize = database.getOlcDbMaxSize(); maxSizeText.setText( ( maxSize == null ) ? "" : maxSize.toString() ); //$NON-NLS-1$ // Search Stack Depth Text Integer searchStackDepth = database.getOlcDbSearchStack(); searchStackDepthText.setText( ( searchStackDepth == null ) ? "" : searchStackDepth.toString() ); //$NON-NLS-1$ // Checkpoint Text String checkpoint = database.getOlcDbCheckpoint(); checkpointText.setText( ( checkpoint == null ) ? "" : checkpoint ); //$NON-NLS-1$ // Disable Synchronous Database Writes Widget disableSynchronousDatabaseWritesBooleanWithDefaultWidget.setValue( database.getOlcDbNoSync() ); // MaxEntrySize Text if ( browserConnection.getSchema().hasAttributeTypeDescription( "olcDbMaxEntrySize" ) ) { // Max Entry Size Text Integer maxEntrySize = database.getOlcDbMaxEntrySize(); if ( maxEntrySize != null ) { maxEntrySizeText.setText( maxEntrySize.toString() ); } } } addListeners(); } /** * Adds the listeners. */ private void addListeners() { directoryBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); modeUnixPermissionsWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); indicesWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); maxReadersText.addModifyListener( dirtyModifyListener ); maxSizeText.addModifyListener( dirtyModifyListener ); if ( browserConnection.getSchema().hasAttributeTypeDescription( "olcDbMaxEntrySize" ) ) { maxEntrySizeText.addModifyListener( dirtyModifyListener ); } searchStackDepthText.addModifyListener( dirtyModifyListener ); checkpointText.addModifyListener( dirtyModifyListener ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); } /** * Removes the listeners */ private void removeListeners() { directoryBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); modeUnixPermissionsWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); indicesWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); maxReadersText.removeModifyListener( dirtyModifyListener ); maxSizeText.removeModifyListener( dirtyModifyListener ); if ( browserConnection.getSchema().hasAttributeTypeDescription( "olcDbMaxEntrySize" ) ) { maxEntrySizeText.removeModifyListener( dirtyModifyListener ); } searchStackDepthText.removeModifyListener( dirtyModifyListener ); checkpointText.removeModifyListener( dirtyModifyListener ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { // Directory String directory = directoryBrowserWidget.getDirectoryPath(); if ( Strings.isEmpty( directory ) ) { database.setOlcDbDirectory( null ); } else { database.setOlcDbDirectory( directory ); } directoryBrowserWidget.saveDialogSettings(); // Mode database.setOlcDbMode( modeUnixPermissionsWidget.getValue() ); // Indices database.clearOlcDbIndex(); for ( DbIndexWrapper dbIndexWrapper : indicesWidget.getElements() ) { database.addOlcDbIndex( dbIndexWrapper.toString() ); } // Max readers try { database.setOlcDbMaxReaders( Integer.parseInt( maxReadersText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbMaxReaders( null ); } // Max Size try { database.setOlcDbMaxSize( Long.parseLong( maxSizeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbMaxSize( null ); } // Max Entry Size if ( browserConnection.getSchema().hasAttributeTypeDescription( "olcDbMaxEntrySize" ) ) { try { database.setOlcDbMaxEntrySize( Integer.parseInt( maxEntrySizeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbMaxEntrySize( null ); } } // Search Stack Depth try { database.setOlcDbSearchStack( Integer.parseInt( searchStackDepthText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbSearchStack( null ); } // Checkpoint Interval database.setOlcDbCheckpoint( checkpointText.getText() ); // Disable Synchronous Database Writes database.setOlcDbNoSync( disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getValue() ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * This interface represents a block for Database Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface DatabaseSpecificDetailsBlock { /** * Creates the block content. * * @param parent the parent composite * @param toolkit the toolkit */ Composite createBlockContent( Composite parent, FormToolkit toolkit ); /** * Gets the associated details page. * * @return the associated details page. */ DatabasesDetailsPage getDetailsPage(); /** * Refreshes the UI based on the input. */ void refresh(); /** * If part is displaying information loaded from a model, this method * instructs it to commit the new (modified) data back into the model. * * @param onSave * indicates if commit is called during 'save' operation or for * some other reason (for example, if form is contained in a * wizard or a multi-page editor and the user is about to leave * the page). */ void commit( boolean onSave ); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/AbstractDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/AbstractDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; /** * This interface represents a block for overlay configuration. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractDatabaseSpecificDetailsBlock<D extends OlcDatabaseConfig> implements DatabaseSpecificDetailsBlock { /** The details page*/ protected DatabasesDetailsPage detailsPage; /** The database */ protected D database; /** The connection */ protected IBrowserConnection browserConnection; // Listeners protected ModifyListener dirtyModifyListener = event -> detailsPage.setEditorDirty(); protected WidgetModifyListener dirtyWidgetModifyListener = event -> detailsPage.setEditorDirty(); protected SelectionListener dirtySelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { detailsPage.setEditorDirty(); } }; /** * Creates a new instance of AbstractDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database */ public AbstractDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, D database, IBrowserConnection browserConnection ) { this.detailsPage = detailsPage; this.database = database; this.browserConnection = browserConnection; } /** * Creates a new instance of AbstractDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database */ public AbstractDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, D database ) { this( detailsPage, database, null ); } /** * {@inheritDoc} */ public DatabasesDetailsPage getDetailsPage() { return detailsPage; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.editor.FormPage; /** * This page represent all the Frontend database options * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class FrontendPage extends FormPage { /** The Page ID*/ public static final String ID = FrontendPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = "Frontend Database"; /** * Creates a new instance of FrontendPage. * * @param editor */ public FrontendPage( FormEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} */ public void refreshUI() { } /** * {@inheritDoc} */ @Override public void doSave( IProgressMonitor monitor ) { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/Messages.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/Messages.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file for the databases OpenLDAP pages. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { private Messages() { // Nothing to do } /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.dialogs.DatabaseTypeDialog; import org.apache.directory.studio.openldap.config.editor.pages.DatabasesPage; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperLabelProvider; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperViewerComparator; import org.apache.directory.studio.openldap.config.model.database.OlcBdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.apache.directory.studio.openldap.config.model.database.OlcDbPerlConfig; import org.apache.directory.studio.openldap.config.model.database.OlcDbSocketConfig; import org.apache.directory.studio.openldap.config.model.database.OlcHdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcLDAPConfig; import org.apache.directory.studio.openldap.config.model.database.OlcLdifConfig; import org.apache.directory.studio.openldap.config.model.database.OlcMdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcMetaConfig; import org.apache.directory.studio.openldap.config.model.database.OlcMonitorConfig; import org.apache.directory.studio.openldap.config.model.database.OlcNdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcNullConfig; import org.apache.directory.studio.openldap.config.model.database.OlcPasswdConfig; import org.apache.directory.studio.openldap.config.model.database.OlcRelayConfig; import org.apache.directory.studio.openldap.config.model.database.OlcShellConfig; import org.apache.directory.studio.openldap.config.model.database.OlcSqlConfig; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.ui.forms.DetailsPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.MasterDetailsBlock; import org.eclipse.ui.forms.SectionPart; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; /** * This class represents the Databases Master/Details Block used in the Databases Page. This is the * left part of the Database tab : * <pre> * .------------------------------------------------------------------. * | .-------------------------------. | * | | All Databases | | * | | +------------------+ | | * | | |DB1 | ( Add ) | | * | | |DB2 | (Delete) | | * | | |DB3 | -------- | | * | | | | ( Up ) | | * | | | | ( Down ) | | * | | | | | | * | | | | | | * | | | | | | * | | +------------------+ | | * | +-------------------------------+ | *'-------------------------------------------------------------------' * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DatabasesMasterDetailsBlock extends MasterDetailsBlock { private static final String NEW_ID = "database"; /** The associated page */ private DatabasesPage page; /** The Managed form */ private IManagedForm managedForm; /** The details page */ private DatabasesDetailsPage detailsPage; /** The database wrappers */ private List<DatabaseWrapper> databaseWrappers = new ArrayList<>(); /** The currently selected object */ private Object currentSelection; // UI Fields /** The table listing all the existing databases */ private TableViewer databaseTableViewer; /** The button used to add a new Database */ private Button addButton; private DatabaseTypeDialog databaseTypeDialog; /** The button used to delete an existing Database */ private Button deleteButton; /** The button used to move up Database in the list */ private Button upButton; /** The button used to move down Database in the list */ private Button downButton; // Listeners /** * A listener called when the Database table content has changed. It will enable * or disabled button accordingly to the changes. */ private ISelectionChangedListener viewerSelectionChangedListener = event -> { if ( !event.getSelection().isEmpty() ) { Object newSelection = ( ( StructuredSelection ) event.getSelection() ).getFirstElement(); if ( newSelection != currentSelection ) { currentSelection = newSelection; // Only show the details if the database is enabled // 2.5 feature... // TODO : check with the SchemaManager is the olcDisabled AT is present. /* OlcDatabaseConfig database = ((DatabaseWrapper)currentSelection).getDatabase(); Boolean disabled = database.getOlcDisabled(); if ( ( disabled == null ) || ( disabled == false ) ) { detailsPart.commit( false ); managedForm.fireSelectionChanged( managedForm.getParts()[0], event.getSelection() ); databseViewer.refresh(); refreshButtonStates(); } */ detailsPart.commit( false ); managedForm.fireSelectionChanged( managedForm.getParts()[0], event.getSelection() ); databaseTableViewer.refresh(); refreshButtonStates(); } } }; /** * A listener called when the Add button is clicked */ private SelectionAdapter addButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { addNewDatabase(); } }; /** * A listener called when the Delete button is clicked */ private SelectionAdapter deleteButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { deleteSelectedDatabase(); } }; /** * A listener called when the Up button is clicked */ private SelectionAdapter upButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { moveSelectedDatabaseUp(); } }; /** * A listener called when the Down button is clicked */ private SelectionAdapter downButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { moveSelectedDatabaseDown(); } }; /** * Creates a new instance of DatabasesMasterDetailsBlock. * * @param page the associated page */ public DatabasesMasterDetailsBlock( DatabasesPage page ) { super(); this.page = page; } /** * {@inheritDoc} */ @Override public void createContent( IManagedForm managedForm ) { super.createContent( managedForm ); // Giving the weights of both parts of the SashForm. sashForm.setWeights( new int[] { 1, 2 } ); } /** * Create the form with the list of existing Database, and the button to update it : * <pre> * .------------------------------. * | All Databases | * |+------------------+ | * ||DB1 | ( Add ) | * ||DB2 | (Delete) | * ||DB3 | -------- | * || | ( Up ) | * || | ( Down ) | * || | | * || | | * || | | * |+------------------+ | * +------------------------------+ * </pre> */ protected void createMasterPart( IManagedForm managedForm, Composite parent ) { FormToolkit toolkit = managedForm.getToolkit(); // Creating the Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); // Creating the Section Section section = toolkit.createSection( composite, Section.TITLE_BAR ); section.setText( "All Databases" ); Composite client = toolkit.createComposite( section ); client.setLayout( new GridLayout( 2, false ) ); toolkit.paintBordersFor( client ); section.setClient( client ); section.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); // Creating the Table and Table Viewer Table table = toolkit.createTable( client, SWT.NONE ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 5 ); gd.heightHint = 20; gd.widthHint = 100; table.setLayoutData( gd ); SectionPart sectionPart = new SectionPart( section ); this.managedForm = managedForm; managedForm.addPart( sectionPart ); databaseTableViewer = new TableViewer( table ); databaseTableViewer.setContentProvider( new ArrayContentProvider() ); databaseTableViewer.setLabelProvider( new DatabaseWrapperLabelProvider() ); databaseTableViewer.setComparator( new DatabaseWrapperViewerComparator() ); // Add a contextual menu to enable/disable a Database. This is a 2.5 feature. // TODO : check with the schemaManager /* databseViewer.getTable().addMouseListener ( new MouseListener() { public void mouseUp( MouseEvent e ) { // Nothing to do } public void mouseDown( MouseEvent event ) { if ( event.button == 3 ) { Table table = (Table)event.getSource(); int selectedItem = table.getSelectionIndex(); DatabaseWrapper database = databaseWrappers.get( selectedItem ); Menu menu = new Menu( databseViewer.getTable().getShell(), SWT.POP_UP ); MenuItem enabled = new MenuItem ( menu, SWT.PUSH ); Boolean disabled = database.getDatabase().getOlcDisabled(); if ( ( disabled != null ) && ( disabled == true ) ) { enabled.setText ( "Enable" ); } else { enabled.setText ( "Disable" ); } // Add a listener on the menu enabled.addListener( SWT.Selection, new Listener() { @Override public void handleEvent( Event event ) { // Switch the flag from disabled to enabled, and from enabled to disabled database.getDatabase().setOlcDisabled( ( disabled == null ) || !disabled ); databseViewer.refresh(); } }); // draws pop up menu: Point pt = new Point( event.x, event.y ); pt = table.toDisplay( pt ); menu.setLocation( pt.x, pt.y ); menu.setVisible ( true ); } } public void mouseDoubleClick( MouseEvent e ) { // Nothing to do } } ); */ // Creating the button(s) addButton = toolkit.createButton( client, "Add", SWT.PUSH ); addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); databaseTypeDialog = new DatabaseTypeDialog( addButton.getShell() ); deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH ); deleteButton.setEnabled( false ); deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); Label separator = BaseWidgetUtils.createSeparator( client, 1 ); separator.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false ) ); upButton = toolkit.createButton( client, "Up", SWT.PUSH ); upButton.setEnabled( false ); upButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); downButton = toolkit.createButton( client, "Down", SWT.PUSH ); downButton.setEnabled( false ); downButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); initFromInput(); addListeners(); } /** * Initializes the page with the Editor input. */ private void initFromInput() { databaseWrappers.clear(); for ( OlcDatabaseConfig database : page.getConfiguration().getDatabases() ) { databaseWrappers.add( new DatabaseWrapper( database ) ); } databaseTableViewer.setInput( databaseWrappers ); } /** * Refreshes the UI. */ public void refreshUI() { initFromInput(); databaseTableViewer.refresh(); } /** * Add listeners to UI fields. */ private void addListeners() { databaseTableViewer.addSelectionChangedListener( viewerSelectionChangedListener ); addButton.addSelectionListener( addButtonSelectionListener ); deleteButton.addSelectionListener( deleteButtonSelectionListener ); upButton.addSelectionListener( upButtonSelectionListener ); downButton.addSelectionListener( downButtonSelectionListener ); } /** * This method is called when the 'Add' button is clicked. */ private void addNewDatabase() { String newId = getNewId(); OlcDatabaseConfig database = null; DatabaseTypeEnum databaseTypeEnum = DatabaseTypeEnum.NONE; // Open the Dialog, and process the addition if it went fine if ( databaseTypeDialog.open() == Dialog.OK ) { databaseTypeEnum = databaseTypeDialog.getDatabaseType(); switch ( databaseTypeEnum ) { case BDB : database = new OlcBdbConfig(); break; case CONFIG : //database = new OlcConfig(); break; case DB_PERL : database = new OlcDbPerlConfig(); break; case DB_SOCKET : database = new OlcDbSocketConfig(); break; case FRONTEND : //database = new OlcFrontendConfig(); break; case HDB : database = new OlcHdbConfig(); break; case LDAP : database = new OlcLDAPConfig(); break; case LDIF : database = new OlcLdifConfig(); break; case MDB : database = new OlcMdbConfig(); break; case META : database = new OlcMetaConfig(); break; case MONITOR : database = new OlcMonitorConfig(); break; case NDB : database = new OlcNdbConfig(); break; case NULL : database = new OlcNullConfig(); break; case PASSWD : database = new OlcPasswdConfig(); break; case RELAY : database = new OlcRelayConfig(); break; case SHELL : database = new OlcShellConfig(); break; case SQL : database = new OlcSqlConfig(); break; default : break; } } database.setOlcDatabase( "{" + getNewOrderingValue() + "}" + databaseTypeEnum.name() ); try { database.addOlcSuffix( new Dn( "dc=" + newId + ",dc=com" ) ); //$NON-NLS-1$ //$NON-NLS-2$ } catch ( LdapInvalidDnException e1 ) { // Will never happen } DatabaseWrapper databaseWrapper = new DatabaseWrapper( database ); databaseWrappers.add( databaseWrapper ); databaseTableViewer.refresh(); databaseTableViewer.setSelection( new StructuredSelection( databaseWrapper ) ); setEditorDirty(); } /** * This method is called when the 'Delete' button is clicked. */ private void deleteSelectedDatabase() { StructuredSelection selection = ( StructuredSelection ) databaseTableViewer.getSelection(); if ( !selection.isEmpty() ) { DatabaseWrapper databaseWrapper = ( DatabaseWrapper ) selection.getFirstElement(); OlcDatabaseConfig database = databaseWrapper.getDatabase(); if ( MessageDialog.openConfirm( page.getManagedForm().getForm().getShell(), "Confirm Delete", NLS.bind( "Are you sure you want to delete database ''{0} ({1})''?", OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() ), getSuffixValue( database ) ) ) ) { databaseWrappers.remove( databaseWrapper ); setEditorDirty(); } } } /** * Gets the suffix value. * * @param database the database * @return the suffix value */ private String getSuffixValue( OlcDatabaseConfig database ) { String suffix = OpenLdapConfigurationPluginUtils.getFirstValueDn( database.getOlcSuffix() ); if ( suffix != null ) { return suffix; } else { return "none"; } } /** * Gets a new ID for a new database. They are incremental * * @return a new ID for a new database */ private String getNewId() { int counter = 1; String name = NEW_ID; boolean ok = false; while ( !ok ) { ok = true; name = NEW_ID + counter; for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { if ( name.equalsIgnoreCase( OpenLdapConfigurationPluginUtils.stripOrderingPrefix( databaseWrapper .getDatabase().getOlcDatabase() ) ) ) { ok = false; } } counter++; } return name; } /** * Gets the new ordering value. * * @return the new ordering value */ private int getNewOrderingValue() { return getMaxOrderingValue() + 1; } /** * Gets the minimum ordering value. * * @return the minimum ordering value */ private int getMinOrderingValue() { int minOrderingValue = Integer.MAX_VALUE; for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( databaseWrapper.getDatabase().getOlcDatabase() ) ) { int databaseOrderingValue = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper .getDatabase().getOlcDatabase() ); if ( databaseOrderingValue < minOrderingValue ) { minOrderingValue = databaseOrderingValue; } } } return minOrderingValue; } /** * Gets the maximum ordering value. * * @return the maximum ordering value */ private int getMaxOrderingValue() { int maxOrderingValue = -1; for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { String database = databaseWrapper.getDatabase().getOlcDatabase(); int databaseOrderingValue = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database ); if ( databaseOrderingValue > maxOrderingValue ) { maxOrderingValue = databaseOrderingValue; } } return maxOrderingValue; } /** * This method is called when the 'Up' button is clicked. */ private void moveSelectedDatabaseUp() { StructuredSelection selection = ( StructuredSelection ) databaseTableViewer.getSelection(); if ( !selection.isEmpty() ) { OlcDatabaseConfig selectedDatabase = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase(); int selectedDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( selectedDatabase .getOlcDatabase() ); String selectedDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( selectedDatabase .getOlcDatabase() ); OlcDatabaseConfig swapDatabase = findPreviousDatabase( selectedDatabaseOrderingPrefix ); if ( swapDatabase != null ) { int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase .getOlcDatabase() ); String swapDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( swapDatabase .getOlcDatabase() ); selectedDatabase.setOlcDatabase( "{" + swapDatabaseOrderingPrefix + "}" + selectedDatabaseName ); swapDatabase.setOlcDatabase( "{" + selectedDatabaseOrderingPrefix + "}" + swapDatabaseName ); databaseTableViewer.refresh(); refreshButtonStates(); setEditorDirty(); } } } /** * Finds the previous database. * * @param orderingPrefix the ordering prefix * @return the previous database */ private OlcDatabaseConfig findPreviousDatabase( int orderingPrefix ) { OlcDatabaseConfig selectedDatabase = null; int selectedDatabaseOrderingPrefix = Integer.MIN_VALUE; for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { int databaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper .getDatabase().getOlcDatabase() ); if ( ( databaseOrderingPrefix < orderingPrefix ) && ( databaseOrderingPrefix > selectedDatabaseOrderingPrefix ) ) { selectedDatabase = databaseWrapper.getDatabase(); selectedDatabaseOrderingPrefix = databaseOrderingPrefix; } } return selectedDatabase; } /** * This method is called when the 'Down' button is clicked. */ private void moveSelectedDatabaseDown() { StructuredSelection selection = ( StructuredSelection ) databaseTableViewer.getSelection(); if ( !selection.isEmpty() ) { OlcDatabaseConfig selectedDatabase = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase(); int selectedDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( selectedDatabase .getOlcDatabase() ); String selectedDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( selectedDatabase .getOlcDatabase() ); OlcDatabaseConfig swapDatabase = findNextDatabase( selectedDatabaseOrderingPrefix ); if ( swapDatabase != null ) { int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase .getOlcDatabase() ); String swapDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( swapDatabase .getOlcDatabase() ); selectedDatabase.setOlcDatabase( "{" + swapDatabaseOrderingPrefix + "}" + selectedDatabaseName ); swapDatabase.setOlcDatabase( "{" + selectedDatabaseOrderingPrefix + "}" + swapDatabaseName ); databaseTableViewer.refresh(); refreshButtonStates(); setEditorDirty(); } } } /** * Finds the next database. * * @param orderingPrefix the ordering prefix * @return the next database */ private OlcDatabaseConfig findNextDatabase( int orderingPrefix ) { OlcDatabaseConfig selectedDatabase = null; int selectedDatabaseOrderingPrefix = Integer.MAX_VALUE; for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { int databaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper .getDatabase().getOlcDatabase() ); if ( ( databaseOrderingPrefix > orderingPrefix ) && ( databaseOrderingPrefix < selectedDatabaseOrderingPrefix ) ) { selectedDatabase = databaseWrapper.getDatabase(); selectedDatabaseOrderingPrefix = databaseOrderingPrefix; } } return selectedDatabase; } /** * Update the button according to the content of the table. If we have * no Database, we just enable the Add button. If we only have one Database, * we don't enable the Add and Delete buttons. We also enable the Up and * Down button accordingly to the selected database : if it's the first one, * the Up butto is disabled, if it's the last one, the Down button is * disabled. */ private void refreshButtonStates() { // Getting the selection of the table viewer StructuredSelection selection = ( StructuredSelection ) databaseTableViewer.getSelection(); if ( !selection.isEmpty() ) { OlcDatabaseConfig database = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase(); deleteButton.setEnabled( true ); upButton.setEnabled( getMinOrderingValue() != OpenLdapConfigurationPluginUtils .getOrderingPrefix( database.getOlcDatabase() ) ); downButton.setEnabled( getMaxOrderingValue() != OpenLdapConfigurationPluginUtils .getOrderingPrefix( database.getOlcDatabase() ) ); } else { deleteButton.setEnabled( false ); upButton.setEnabled( false ); downButton.setEnabled( false ); } } /** * Sets the Editor as dirty. */ public void setEditorDirty() { ( ( OpenLdapServerConfigurationEditor ) page.getEditor() ).setDirty( true ); detailsPage.commit( false ); databaseTableViewer.refresh(); } /** * {@inheritDoc} */ protected void registerPages( DetailsPart detailsPart ) { detailsPage = new DatabasesDetailsPage( this ); detailsPart.registerPage( DatabaseWrapper.class, detailsPage ); } /** * {@inheritDoc} */ protected void createToolBarActions( IManagedForm managedForm ) { // No toolbar actions } /** * Gets the associated editor page. * * @return the associated editor page */ public DatabasesPage getPage() { return page; } /** * Saves the necessary elements to the input model. */ public void doSave( IProgressMonitor monitor ) { // Committing information on the details page detailsPage.commit( true ); // Saving the databases getPage().getConfiguration().clearDatabases(); for ( DatabaseWrapper databaseWrapper : databaseWrappers ) { getPage().getConfiguration().add( databaseWrapper.getDatabase() ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget; import org.apache.directory.studio.openldap.config.model.database.OlcLdifConfig; /** * This interface represents a block for None Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LdifDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcLdifConfig> { // UI Widgets private DirectoryBrowserWidget directoryBrowserWidget; /** * Creates a new instance of LdifDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database */ public LdifDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcLdifConfig database ) { super( detailsPage, database ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Directory Widget toolkit.createLabel( composite, "Directory:" ); directoryBrowserWidget = new DirectoryBrowserWidget( "" ); directoryBrowserWidget.createWidget( composite, toolkit ); return composite; } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { // Directory Widget String directory = database.getOlcDbDirectory(); if ( directory != null ) { directoryBrowserWidget.setDirectoryPath( directory ); } else { directoryBrowserWidget.setDirectoryPath( "" ); } } addListeners(); } /** * Adds the listeners. */ private void addListeners() { directoryBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); } /** * Removes the listeners */ private void removeListeners() { directoryBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { if ( database != null ) { database.setOlcDbDirectory( directoryBrowserWidget.getDirectoryPath() ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/ConfigPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/ConfigPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.editor.FormPage; /** * This page represent all the Config database options * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConfigPage extends FormPage { /** The Page ID*/ public static final String ID = ConfigPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = "Config Database"; /** * Creates a new instance of ConfigPage. * * @param editor */ public ConfigPage( FormEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} */ public void refreshUI() { } /** * {@inheritDoc} */ @Override public void doSave( IProgressMonitor monitor ) { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.eclipse.swt.SWT; 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.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.config.model.database.OlcNullConfig; /** * This interface represents a block for Null Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NullDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcNullConfig> { // UI Widgets private Button allowBindCheckbox; /** * Creates a new instance of NullDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database */ public NullDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcNullConfig database ) { super( detailsPage, database ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Allow Bind allowBindCheckbox = toolkit.createButton( composite, "Allow bind to the database", SWT.CHECK ); return composite; } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { // Allow Bind Boolean allowBind = database.getOlcDbBindAllowed(); if ( allowBind != null ) { allowBindCheckbox.setSelection( allowBind ); } else { allowBindCheckbox.setSelection( false ); } } addListeners(); } /** * Adds the listeners. */ private void addListeners() { allowBindCheckbox.addSelectionListener( dirtySelectionListener ); } /** * Removes the listeners */ private void removeListeners() { allowBindCheckbox.removeSelectionListener( dirtySelectionListener ); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { if ( database != null ) { // Allow Bind database.setOlcDbBindAllowed( allowBindCheckbox.getSelection() ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.common.ui.widgets.AbstractWidget; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.common.ui.wrappers.StringValueWrapper; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.common.ui.model.RequireConditionEnum; import org.apache.directory.studio.openldap.common.ui.model.RestrictOperationEnum; import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget; import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget; import org.apache.directory.studio.openldap.common.ui.widgets.PasswordWidget; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog; import org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog; import org.apache.directory.studio.openldap.config.editor.dialogs.SizeLimitDialog; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.DnDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.DnWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.LimitsDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.LimitsWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.RequireConditionDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.RestrictOperationDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.SsfDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitWrapper; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; import org.apache.directory.studio.openldap.config.model.database.OlcBdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.apache.directory.studio.openldap.config.model.database.OlcHdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcLdifConfig; import org.apache.directory.studio.openldap.config.model.database.OlcMdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcNullConfig; import org.apache.directory.studio.openldap.config.model.database.OlcRelayConfig; import org.apache.directory.studio.openldap.syncrepl.Provider; import org.apache.directory.studio.openldap.syncrepl.SyncRepl; import org.apache.directory.studio.openldap.syncrepl.SyncReplParser; import org.apache.directory.studio.openldap.syncrepl.SyncReplParserException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; /** * This class represents the Details Page of the Server Configuration Editor for the Database type. * We have 6 sections to manage : * <ul> * <li>general :</li> * <ul> * <li>olcSuffix(DN, SV/MV)</li> * <li>olcRootDN(DN, SV)</li> * <li>olcRootPw(String, SV)</li> * <li></li> * </ul> * <li>limits :</li> * <ul> * <li>olcSizeLimit(String, SV)</li> * <li>olcTimeLimit(String, MV)</li> * <li>olcLimits(String, MV, Ordered)</li> * <li>olcMaxDerefDepth(Integer, SV)</li> * </ul> * <li>security :</li> * <ul> * <li>olcHidden(Boolean)</li> * <li>olcReadOnly(Boolean)</li> * <li>olcRequires(String, MV)</li> * <li>olcRestrict(String, MV)</li> * <li>olcSecurity(String, MV)</li> * </ul> * <li>access</li> * <ul> * <li>olcAccess(String, MV, Ordered)</li> * <li>olcAddContentAcl(Boolean)</li> * </ul> * <li>replication :</li> * <ul> * <li>olcMirrorMode(Boolean)</li> * <li>olcSyncrepl(String, MV, Ordered)</li> * <li>olcSyncUseSubentry(Boolean)</li> * <li>olcUpdateDN(DN, SV)</li> * <li>olcUpdateRef(String, MV)</li> * <li>olcReplica(String, MV, Ordered)</li> * <li>olcReplicaArgsFile(String, SV)</li> * <li>olcReplicaPidFile(String, SV)</li> * <li>olcReplicationInterval(Integer, SV)</li> * <li>olcReplogFile(String, SV)</li> * </ul> * <li>options :</li> * <ul> * <li>olcLastMod(Boolean)</li> * <li>olcMonitoring(Boolean)</li> * <li>olcPlugin(String, MV)</li> * <li>olcExtraArgs(String, MV)</li> * <li>olcSchemaDN(DN, SV)</li> * <li>olcSubordinate(String, SV)</li> * </ul> * </ul> * * <pre> * +--------------------------------------------------------+ * | .----------------------------------------------------. | * | |V XXXX Database general | | * | +----------------------------------------------------+ | * | | Root DN : [ ] none [///////////////////////] | | * | | Root password : [ ] none [///////////////////////] | | * | | Suffix : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * | | * | .----------------------------------------------------. | * | |V XXXX Database limits | | * | +----------------------------------------------------+ | * | | Size limit : [//////////] (Edit...) | | * | | Max Deref Depth : [///] | | * | | Timelimit : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | | Limits : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | | | -------- | | * | | | | (Up...) | | * | | | | (Down...) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * | | * | .----------------------------------------------------. | * | |V XXXX Database security | | * | +----------------------------------------------------+ | * | | Hidden : [ ] Read Only : [ ] | | * | | Requires : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Delete) | | * | | | | | | * | | +------------------------------------+ | | * | | Restrict : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Delete) | | * | | | | | | * | | +------------------------------------+ | | * | | Security Strength Factors : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * | | * | .----------------------------------------------------. | * | |V XXXX Database access | | * | +----------------------------------------------------+ | * | | Add content ACL : [ ] | | * | | ACLs : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | | | -------- | | * | | | | (Up...) | | * | | | | (Down...) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * | | * | .----------------------------------------------------. | * | |V XXXX Database replication | | * | +----------------------------------------------------+ | * | | MirrorMode : [ ] Use Subentry : [ ] | | * | | Replication Interval : [///] | | * | | Replication Args[fileo:e[////////////////////////] | | * | | Replication PID file : [////////////////////////] | | * | | Replication Log file : [////////////////////////] | | * | | Update DN : [-------------------------->] (Browse) | | * | | Update References : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | | Replicas : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | | | -------- | | * | | | | (Up...) | | * | | | | (Down...) | | * | | +------------------------------------+ | | * | | Syncrepls : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | | | -------- | | * | | | | (Up...) | | * | | | | (Down...) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * | | * | .----------------------------------------------------. | * | |V XXXX Database options | | * | +----------------------------------------------------+ | * | | Last Modification : [ ] Monitoring : [ ] | | * | | Schema DN : [-------------------------->] (Browse) | | * | | Subordinate : [//////////////////////////////////] | | * | | Plugins : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | | Extras Arguments : | | * | | +------------------------------------+ | | * | | | | (Add...) | | * | | | | (Edit...) | | * | | | | (Delete) | | * | | +------------------------------------+ | | * | +----------------------------------------------------+ | * +--------------------------------------------------------+ * </pre> * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DatabasesDetailsPage implements IDetailsPage { /** The frontend database type array */ private static final DatabaseTypeEnum[] FRONTEND_DATABASE_TYPES = new DatabaseTypeEnum[] { DatabaseTypeEnum.FRONTEND }; /** The frontend database type array */ private static final DatabaseTypeEnum[] CONFIG_DATABASE_TYPES = new DatabaseTypeEnum[] { DatabaseTypeEnum.CONFIG }; /** The class instance */ private DatabasesDetailsPage instance; /** The associated Master Details Block */ private DatabasesMasterDetailsBlock masterDetailsBlock; /** The database wrapper */ private DatabaseWrapper databaseWrapper; /** The database specific details block */ private DatabaseSpecificDetailsBlock databaseSpecificDetailsBlock; /** The browser connection */ private IBrowserConnection browserConnection; /** The dirty flag */ private boolean dirty = false; // UI widgets private Composite parentComposite; private FormToolkit toolkit; //private ComboViewer databaseTypeComboViewer; // UI General sesstings widgets /** The olcSuffixDN attribute */ private TableWidget<DnWrapper> suffixDnTableWidget; /** The olcRootDN attribute */ private EntryWidget rootDnEntryWidget; /** The olcRootPW attribute */ private PasswordWidget rootPasswordWidget; // UI limits settings widgets /** The olcSizeLimit */ private Text sizeLimitText; /** The SizeLimit edit Button */ private Button sizeLimitEditButton; /** The olcMaxDerefDepth parameter */ private Text maxDerefDepthText; /** The olcTimeLimit Table */ private TableWidget<TimeLimitWrapper> timeLimitTableWidget; /** The olcLimits Table */ private TableWidget<LimitsWrapper> limitsTableWidget; /** The olcSchemaDN attribute */ private EntryWidget schemaDnEntryWidget; // The Security UI Widgets /** The olcReadOnly attribute */ private Button readOnlyButton; /** The olcHidden attribute */ private Button hiddenButton; /** The olcRequires parameter */ private TableWidget<RequireConditionEnum> requireConditionTableWidget; /** The olcRestrict parameter */ private TableWidget<RestrictOperationEnum> restrictOperationTableWidget; /** The olcSecurity table widget */ private TableWidget<SsfWrapper> securityTableWidget; // The Access UI Widgets /** The olcAddContentAcl Button */ private Button addContentAclCheckbox; /** The olcAcess Table */ private TableWidget<StringValueWrapper> aclsTableWidget; /** The associated overlays */ private TableViewer overlaysTableViewer; private Button addOverlayButton; private Button editOverlayButton; private Button deleteOverlayButton; /** The specific configuration for each type of database */ private Section specificSettingsSection; private Composite specificSettingsSectionComposite; private Composite databaseSpecificDetailsComposite; /** The olcMirrorMode flag */ private BooleanWithDefaultWidget mirrorModeBooleanWithDefaultWidget; /** The olcDisabled flag (only available in OpenDLAP 2.4.36) */ private BooleanWithDefaultWidget disabledBooleanWithDefaultWidget; /** The olcLastMod flag */ private BooleanWithDefaultWidget lastModBooleanWithDefaultWidget; /** The olMonitoring flag */ private BooleanWithDefaultWidget monitoringBooleanWithDefaultWidget; /** The Syncrepl consumer part */ private TableViewer replicationConsumersTableViewer; private Button addReplicationConsumerButton; private Button editReplicationConsumerButton; private Button deleteReplicationConsumerButton; /** * The olcSuffixDn listener * private WidgetModifyListener suffixDnTableWidgetListener = new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent e ) { List<String> suffixDns = new ArrayList<String>(); for ( DnWrapper dnWrapper : suffixDnTableWidget.getElements() ) { suffixDns.add( dnWrapper.toString() ); } getConfiguration().getGlobal().setOlcRequires( requires ); } }; /** * The listener for the sizeLimit Text */ private SelectionListener sizeLimitEditSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { SizeLimitDialog dialog = new SizeLimitDialog( sizeLimitText.getShell(), sizeLimitText.getText() ); if ( dialog.open() == OverlayDialog.OK ) { String newSizeLimitStr = dialog.getNewLimit(); if ( newSizeLimitStr != null ) { sizeLimitText.setText( newSizeLimitStr ); } } } }; // Listeners /** * A listener for changes on the Overlay table */ private ISelectionChangedListener overlaysTableViewerSelectionChangedListener = event -> updateOverlaysTableButtonsState(); /** * A listener for selections on the Overlay table */ private IDoubleClickListener overlaysTableViewerDoubleClickListener = event -> editOverlayButtonAction(); /** * A listener for the Overlay table Add button */ private SelectionListener addOverlayButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { addOverlayButtonAction(); } }; /** * A listener for the Overlay table Edit button */ private SelectionListener editOverlayButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { editOverlayButtonAction(); } }; /** * A listener for the Overlay table Delete button */ private SelectionListener deleteOverlayButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { deleteOverlayButtonAction(); } }; /** * A listener for changes on the Replication Consumers table */ private ISelectionChangedListener replicationConsumersTableViewerSelectionChangedListener = event -> updateReplicationConsumersTableButtonsState(); /** * A listener for selections on the Replication Consumers table */ private IDoubleClickListener replicationConsumersTableViewerDoubleClickListener = event -> editReplicationConsumerButtonAction(); /** * A listener for the Replication Consumers table Add button */ private SelectionListener addReplicationConsumerButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { addReplicationConsumerButtonAction(); } }; /** * A listener for the Replication Consumers table Edit button */ private SelectionListener editReplicationConsumerButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { editReplicationConsumerButtonAction(); } }; /** * A listener for the Replication Consumers table Delete button */ private SelectionListener deleteReplicationConsumerButtonListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { deleteReplicationConsumerButtonAction(); } }; /** * The listener that manage the specific database parameters * private ISelectionChangedListener databaseTypeComboViewerSelectionChangedListener = new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { DatabaseTypeEnum type = ( DatabaseTypeEnum ) ( ( StructuredSelection ) databaseTypeComboViewer .getSelection() ) .getFirstElement(); if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) ) { OlcDatabaseConfig database = databaseWrapper.getDatabase(); switch ( type ) { case BDB: OlcBdbConfig newBdbDatabase = new OlcBdbConfig(); copyDatabaseProperties( database, newBdbDatabase ); databaseWrapper.setDatabase( newBdbDatabase ); databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcBdbConfig>( instance, newBdbDatabase, browserConnection ); break; case HDB: OlcHdbConfig newHdbDatabase = new OlcHdbConfig(); copyDatabaseProperties( database, newHdbDatabase ); databaseWrapper.setDatabase( newHdbDatabase ); databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcHdbConfig>( instance, newHdbDatabase, browserConnection ); break; case MDB: // The MDB database OlcMdbConfig newMdbDatabase = new OlcMdbConfig(); copyDatabaseProperties( database, newMdbDatabase ); databaseWrapper.setDatabase( newMdbDatabase ); databaseSpecificDetailsBlock = new MdbDatabaseSpecificDetailsBlock( instance, newMdbDatabase, browserConnection ); break; case LDIF: OlcLdifConfig newLdifDatabase = new OlcLdifConfig(); copyDatabaseProperties( database, newLdifDatabase ); databaseWrapper.setDatabase( newLdifDatabase ); databaseSpecificDetailsBlock = new LdifDatabaseSpecificDetailsBlock( instance, newLdifDatabase ); break; // case LDAP: // OlcLDAPConfig newLdapDatabase = new OlcLDAPConfig(); // copyDatabaseProperties( database, newLdapDatabase ); // databaseWrapper.setDatabase( newLdapDatabase ); // // databaseSpecificDetailsBlock = new LdapDatabaseSpecificDetailsBlock( newLdapDatabase ); // TODO // break; case NULL: OlcNullConfig newNullDatabase = new OlcNullConfig(); copyDatabaseProperties( database, newNullDatabase ); databaseWrapper.setDatabase( newNullDatabase ); databaseSpecificDetailsBlock = new NullDatabaseSpecificDetailsBlock( instance, newNullDatabase ); break; case RELAY: OlcRelayConfig newRelayDatabase = new OlcRelayConfig(); copyDatabaseProperties( database, newRelayDatabase ); databaseWrapper.setDatabase( newRelayDatabase ); databaseSpecificDetailsBlock = new RelayDatabaseSpecificDetailsBlock( instance, newRelayDatabase, browserConnection ); break; case NONE: OlcDatabaseConfig newNoneDatabase = new OlcDatabaseConfig(); copyDatabaseProperties( database, newNoneDatabase ); databaseWrapper.setDatabase( newNoneDatabase ); databaseSpecificDetailsBlock = null; break; default: break; } updateDatabaseSpecificSettingsSection(); setEditorDirty(); } } }; /** * The modify listener which set the editor dirty **/ private WidgetModifyListener dirtyWidgetModifyListener = event -> setEditorDirty(); /** * The modify listener which set the editor dirty **/ private SelectionListener dirtySelectionListener = new SelectionListener() { @Override public void widgetSelected( SelectionEvent e ) { setEditorDirty(); } @Override public void widgetDefaultSelected( SelectionEvent e ) { // TODO Auto-generated method stub } }; /** * A modify listener for text zones when they have been modified */ protected ModifyListener dirtyModifyListener = event -> setEditorDirty(); /** * The olcHidden listener */ private SelectionListener hiddenButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { setEditorDirty(); } }; /** * The olcReadOnly listener */ private SelectionListener readOnlyButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { setEditorDirty(); } }; /** * The olcRequires listener */ private WidgetModifyListener requireConditionListener = event -> { List<String> requires = new ArrayList<>(); for ( RequireConditionEnum requireCondition : requireConditionTableWidget.getElements() ) { requires.add( requireCondition.getName() ); } //getConfiguration().getGlobal().setOlcRequires( requires ); }; /** * The olcRestrict listener */ private WidgetModifyListener restrictOperationListener = event -> { List<String> restricts = new ArrayList<>(); for ( RestrictOperationEnum restrictOperation : restrictOperationTableWidget.getElements() ) { restricts.add( restrictOperation.getName() ); } //getConfiguration().getGlobal().setOlcRestrict( restricts ); }; /** * The olcSecurity listener */ private WidgetModifyListener securityListener = event -> { List<String> ssfWrappers = new ArrayList<>(); for ( SsfWrapper ssfWrapper : securityTableWidget.getElements() ) { ssfWrappers.add( ssfWrapper.toString() ); } //getConfiguration().getGlobal().setOlcSecurity( ssfWrappers ); }; /** * Creates a new instance of PartitionDetailsPage. * * @param pmdb * the associated Master Details Block */ public DatabasesDetailsPage( DatabasesMasterDetailsBlock pmdb ) { instance = this; masterDetailsBlock = pmdb; // Getting the browser connection associated with the connection in the configuration browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( masterDetailsBlock.getPage().getConfiguration().getConnection() ); } /** * Creates the Database general configuration panel. We have 8 sections : * <ul> * <li>General</li> * <li>Limits</li> * <li>Security</li> * <li>Access</li> * <li>Overlays</li> * <li>Replication</li> * <li>Options</li> * <li>Specific</li> * </ul> * {@inheritDoc} */ public void createContents( Composite parent ) { parentComposite = parent; parent.setLayout( new GridLayout() ); createGeneralSettingsSection( parent, toolkit ); createLimitsSettingsSection( parent, toolkit ); createSecuritySettingsSection( parent, toolkit ); createAccessSettingsSection( parent, toolkit ); createOverlaySettingsSection( parent, toolkit ); createReplicationConsumersSettingsSection( parent, toolkit ); //createOptionsSettingsSection( parent, toolkit ); createDatabaseSpecificSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section. This will expose the following attributes : * <ul> * <li>olcRootDN</li> * <li>olcRootPW</li> * <li>olcSuffix</li> * </ul> * * <pre> * .----------------------------------------------------.
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.common.ui.dialogs.AttributeDialog; import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass; import org.apache.directory.studio.openldap.config.model.OlcFrontendConfig; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; /** * This interface represents a block for Frontend Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class FrontendDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcDatabaseConfig> { private static final String SHA = "{SHA}"; private static final String SSHA = "{SSHA}"; private static final String CRYPT = "{CRYPT}"; private static final String MD5 = "{MD5}"; private static final String SMD5 = "{SMD5}"; private static final String CLEARTEXT = "{CLEARTEXT}"; /** The list of sorted attributes values */ private List<String> sortedValuesAttributesList = new ArrayList<>(); // UI Fields private EntryWidget defaultSearchBaseEntryWidget; private Button shaCheckbox; private Button sshaCheckbox; private Button cryptCheckbox; private Button md5Checkbox; private Button smd5Checkbox; private Button cleartextCheckbox; private Table sortedValuesTable; private TableViewer sortedValuesTableViewer; private Button addSortedValueButton; private Button deleteSortedValueButton; // Listeners private ISelectionChangedListener sortedValuesTableViewerSelectionChangedListener = event -> deleteSortedValueButton.setEnabled( !sortedValuesTableViewer.getSelection().isEmpty() ); private SelectionListener addSortedValueButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { AttributeDialog dialog = new AttributeDialog( addSortedValueButton.getShell(), browserConnection ); if ( dialog.open() == AttributeDialog.OK ) { String attribute = dialog.getAttribute(); if ( !sortedValuesAttributesList.contains( attribute ) ) { sortedValuesAttributesList.add( attribute ); sortedValuesTableViewer.refresh(); sortedValuesTableViewer.setSelection( new StructuredSelection( attribute ) ); detailsPage.setEditorDirty(); } } } }; private SelectionListener deleteSortedValueButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { StructuredSelection selection = ( StructuredSelection ) sortedValuesTableViewer.getSelection(); if ( !selection.isEmpty() ) { String selectedAttribute = ( String ) selection.getFirstElement(); sortedValuesAttributesList.remove( selectedAttribute ); sortedValuesTableViewer.refresh(); detailsPage.setEditorDirty(); } } }; /** * Creates a new instance of FrontendDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database * @param browserConnection the connection */ public FrontendDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcDatabaseConfig database, IBrowserConnection browserConnection ) { super( detailsPage, database, browserConnection ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout( 2, false ) ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Default Search Base Text toolkit.createLabel( composite, "Default Search Base:" ); defaultSearchBaseEntryWidget = new EntryWidget( browserConnection, null, true ); defaultSearchBaseEntryWidget.createWidget( composite, toolkit ); defaultSearchBaseEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Password Hash createPasswordHashContent( composite, toolkit ); // Sorted Values Attributes createSortedValuesAttributesContent( composite, toolkit ); return composite; } /** * Creates the content for the password hash. * * @param parent the parent composite * @param toolkit the toolkit */ private void createPasswordHashContent( Composite parent, FormToolkit toolkit ) { // Label Label passwordHashLabel = toolkit.createLabel( parent, "Password Hash:" ); passwordHashLabel.setLayoutData( new GridData( SWT.NONE, SWT.TOP, false, false ) ); // Composite Composite passwordHashComposite = toolkit.createComposite( parent ); GridLayout passwordHashCompositeGridLayout = new GridLayout( 3, true ); passwordHashCompositeGridLayout.marginHeight = passwordHashCompositeGridLayout.marginWidth = 0; passwordHashComposite.setLayout( passwordHashCompositeGridLayout ); passwordHashComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // SHA Checkbox shaCheckbox = toolkit.createButton( passwordHashComposite, "SHA", SWT.CHECK ); // SSHA Checkbox sshaCheckbox = toolkit.createButton( passwordHashComposite, "SSHA", SWT.CHECK ); // CRYPT Checkbox cryptCheckbox = toolkit.createButton( passwordHashComposite, "CRYPT", SWT.CHECK ); // MD5 Checkbox md5Checkbox = toolkit.createButton( passwordHashComposite, "MD5", SWT.CHECK ); // SMD5 Checkbox smd5Checkbox = toolkit.createButton( passwordHashComposite, "SMD5", SWT.CHECK ); // CLEARTEXT Checkbox cleartextCheckbox = toolkit.createButton( passwordHashComposite, "CLEARTEXT", SWT.CHECK ); } /** * Creates the content for the sorted values attributes. * * @param parent the parent composite * @param toolkit the toolkit */ private void createSortedValuesAttributesContent( Composite parent, FormToolkit toolkit ) { // Label Label sortedValuesLabel = toolkit.createLabel( parent, "Maintain sorted values for these attributes:" ); sortedValuesLabel.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) ); // Composite Composite sortedValuesComposite = toolkit.createComposite( parent ); GridLayout attributesCompositeGridLayout = new GridLayout( 2, false ); attributesCompositeGridLayout.marginHeight = attributesCompositeGridLayout.marginWidth = 0; // attributesCompositeGridLayout.verticalSpacing = attributesCompositeGridLayout.horizontalSpacing = 0; sortedValuesComposite.setLayout( attributesCompositeGridLayout ); sortedValuesComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); // Table and Table Viewer sortedValuesTable = toolkit.createTable( sortedValuesComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ); gd.heightHint = 20; gd.widthHint = 100; sortedValuesTable.setLayoutData( gd ); sortedValuesTableViewer = new TableViewer( sortedValuesTable ); sortedValuesTableViewer.setContentProvider( new ArrayContentProvider() ); sortedValuesTableViewer.setLabelProvider( new LabelProvider() { @Override public Image getImage( Object element ) { return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_ATTRIBUTE ); } } ); sortedValuesTableViewer.setInput( sortedValuesAttributesList ); // Add Button addSortedValueButton = toolkit.createButton( sortedValuesComposite, "Add...", SWT.PUSH ); addSortedValueButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); // Delete Button deleteSortedValueButton = toolkit.createButton( sortedValuesComposite, "Delete", SWT.PUSH ); deleteSortedValueButton.setEnabled( false ); deleteSortedValueButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { OlcFrontendConfig frontendConfig = getFrontendConfig(); if ( frontendConfig == null ) { // Default Search Base defaultSearchBaseEntryWidget.setInput( null ); // Password Hash shaCheckbox.setSelection( false ); sshaCheckbox.setSelection( false ); cryptCheckbox.setSelection( false ); md5Checkbox.setSelection( false ); smd5Checkbox.setSelection( false ); cleartextCheckbox.setSelection( false ); // Sorted Values Attributes sortedValuesAttributesList.clear(); sortedValuesTableViewer.refresh(); } else { // Default Search Base String defaultSearchBase = frontendConfig.getOlcDefaultSearchBase(); if ( Strings.isEmpty( defaultSearchBase ) ) { defaultSearchBaseEntryWidget.setInput( null ); } else { try { defaultSearchBaseEntryWidget.setInput( new Dn( defaultSearchBase ) ); } catch ( LdapInvalidDnException e ) { // Nothing to do. } } // Password Hash List<String> passwordHashList = frontendConfig.getOlcPasswordHash(); if ( ( passwordHashList != null ) && !passwordHashList.isEmpty() ) { shaCheckbox.setSelection( passwordHashList.contains( SHA ) ); sshaCheckbox.setSelection( passwordHashList.contains( SSHA ) ); cryptCheckbox.setSelection( passwordHashList.contains( CRYPT ) ); md5Checkbox.setSelection( passwordHashList.contains( MD5 ) ); smd5Checkbox.setSelection( passwordHashList.contains( SMD5 ) ); cleartextCheckbox.setSelection( passwordHashList.contains( CLEARTEXT ) ); } // Sorted Values Attributes sortedValuesAttributesList.clear(); List<String> sortVals = frontendConfig.getOlcSortVals(); for ( String attribute : sortVals ) { sortedValuesAttributesList.add( attribute ); } sortedValuesTableViewer.refresh(); } } addListeners(); } /** * Adds the listeners. */ private void addListeners() { defaultSearchBaseEntryWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); sortedValuesTableViewer.addSelectionChangedListener( sortedValuesTableViewerSelectionChangedListener ); addSortedValueButton.addSelectionListener( addSortedValueButtonSelectionListener ); deleteSortedValueButton.addSelectionListener( deleteSortedValueButtonSelectionListener ); shaCheckbox.addSelectionListener( dirtySelectionListener ); sshaCheckbox.addSelectionListener( dirtySelectionListener ); cryptCheckbox.addSelectionListener( dirtySelectionListener ); md5Checkbox.addSelectionListener( dirtySelectionListener ); smd5Checkbox.addSelectionListener( dirtySelectionListener ); cleartextCheckbox.addSelectionListener( dirtySelectionListener ); } /** * Removes the listeners */ private void removeListeners() { defaultSearchBaseEntryWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); sortedValuesTableViewer.removeSelectionChangedListener( sortedValuesTableViewerSelectionChangedListener ); addSortedValueButton.removeSelectionListener( addSortedValueButtonSelectionListener ); deleteSortedValueButton.removeSelectionListener( deleteSortedValueButtonSelectionListener ); shaCheckbox.removeSelectionListener( dirtySelectionListener ); sshaCheckbox.removeSelectionListener( dirtySelectionListener ); cryptCheckbox.removeSelectionListener( dirtySelectionListener ); md5Checkbox.removeSelectionListener( dirtySelectionListener ); smd5Checkbox.removeSelectionListener( dirtySelectionListener ); cleartextCheckbox.removeSelectionListener( dirtySelectionListener ); } /** * Gets the frontend config. * * @return the frontend config */ private OlcFrontendConfig getFrontendConfig() { if ( database != null ) { List<AuxiliaryObjectClass> auxiliaryObjectClassesList = database.getAuxiliaryObjectClasses(); if ( ( auxiliaryObjectClassesList != null ) && !auxiliaryObjectClassesList.isEmpty() ) { for ( AuxiliaryObjectClass auxiliaryObjectClass : auxiliaryObjectClassesList ) { if ( auxiliaryObjectClass instanceof OlcFrontendConfig ) { return ( OlcFrontendConfig ) auxiliaryObjectClass; } } } } return null; } /** * {@inheritDoc} */ public void commit( boolean onSave ) { OlcFrontendConfig frontendConfig = getOrCreateFrontendConfig(); if ( frontendConfig != null ) { // Default Search Base Dn defaultSearchBase = defaultSearchBaseEntryWidget.getDn(); if ( defaultSearchBase == null ) { frontendConfig.setOlcDefaultSearchBase( null ); } else { frontendConfig.setOlcDefaultSearchBase( defaultSearchBase.toString() ); } // Password Hash frontendConfig.clearOlcPasswordHash(); if ( shaCheckbox.getSelection() ) { frontendConfig.addOlcPasswordHash( SHA ); } if ( sshaCheckbox.getSelection() ) { frontendConfig.addOlcPasswordHash( SSHA ); } if ( cryptCheckbox.getSelection() ) { frontendConfig.addOlcPasswordHash( CRYPT ); } if ( md5Checkbox.getSelection() ) { frontendConfig.addOlcPasswordHash( MD5 ); } if ( smd5Checkbox.getSelection() ) { frontendConfig.addOlcPasswordHash( SMD5 ); } if ( cleartextCheckbox.getSelection() ) { frontendConfig.addOlcPasswordHash( CLEARTEXT ); } // Sorted Values Attributes frontendConfig.clearOlcSortVals(); for ( String attribute : sortedValuesAttributesList ) { frontendConfig.addOlcSortVals( attribute ); } } } /** * Gets the frontend config or creates one if it's not available. * * @return the frontend config */ private OlcFrontendConfig getOrCreateFrontendConfig() { OlcFrontendConfig frontendConfig = getFrontendConfig(); if ( ( frontendConfig == null ) && ( database != null ) ) { frontendConfig = new OlcFrontendConfig(); database.addAuxiliaryObjectClasses( frontendConfig ); } return frontendConfig; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/BerkeleyDbDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/BerkeleyDbDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget; import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget; import org.apache.directory.studio.openldap.common.ui.widgets.FileBrowserWidget; import org.apache.directory.studio.openldap.common.ui.widgets.UnixPermissionsWidget; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.editor.dialogs.DbConfigurationDialog; import org.apache.directory.studio.openldap.config.model.database.OlcBdbConfig; import org.apache.directory.studio.openldap.config.model.database.OlcBdbConfigLockDetectEnum; import org.apache.directory.studio.openldap.config.model.widgets.IndicesWidget; import org.apache.directory.studio.openldap.config.model.widgets.LockDetectWidget; /** * This class implements a block for Berkeley DB Database Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BerkeleyDbDatabaseSpecificDetailsBlock<BDB extends OlcBdbConfig> extends AbstractDatabaseSpecificDetailsBlock<BDB> { // UI Widgets private DirectoryBrowserWidget directoryBrowserWidget; private UnixPermissionsWidget modeUnixPermissionsWidget; private Button editConfigurationButton; private FileBrowserWidget cryptFileBrowserWidget; private Text cryptKeyText; private Text sharedMemoryKeyText; private IndicesWidget indicesWidget; private BooleanWithDefaultWidget linearIndexBooleanWithDefaultWidget; private Text cacheSizeText; private Text cacheFreeText; private Text dnCacheSizeText; private Text idlCacheSizeText; private Text searchStackDepthText; private Text pageSizeText; private Text checkpointText; private BooleanWithDefaultWidget disableSynchronousDatabaseWritesBooleanWithDefaultWidget; private BooleanWithDefaultWidget allowReadsOfUncommitedDataBooleanWithDefaultWidget; private LockDetectWidget lockDetectWidget; // Listeners private SelectionListener editConfigurationButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { DbConfigurationDialog dialog = new DbConfigurationDialog( editConfigurationButton.getShell(), database.getOlcDbConfig().toArray( new String[0] ) ); if ( dialog.open() == DbConfigurationDialog.OK ) { List<String> newConfiguration = new ArrayList<>(); String[] configurationFromDialog = dialog.getConfiguration(); if ( configurationFromDialog.length > 0 ) { for ( String configurationLineFromDialog : configurationFromDialog ) { newConfiguration.add( configurationLineFromDialog ); } } database.setOlcDbConfig( newConfiguration ); detailsPage.setEditorDirty(); } } }; /** * Creates a new instance of BdbDatabaseSpecificDetailsBlock. * * @param databaseDetailsPage the database details page * @param database the database * @param browserConnection the connection */ public BerkeleyDbDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, BDB database, IBrowserConnection browserConnection ) { super( detailsPage, database, browserConnection ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); createDatabaseConfigurationSection( composite, toolkit ); createDatabaseIndexesSection( composite, toolkit ); createDatabaseCacheSection( composite, toolkit ); createDatabaseLimitsSection( composite, toolkit ); createDatabaseOptionsSection( composite, toolkit ); return composite; } /** * Creates the database configuration section. * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseConfigurationSection( Composite parent, FormToolkit toolkit ) { // Database Configuration Section Section databaseConfigurationSection = toolkit.createSection( parent, Section.TWISTIE ); databaseConfigurationSection.setText( "Database Configuration" ); databaseConfigurationSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseConfigurationComposite = toolkit.createComposite( databaseConfigurationSection ); toolkit.paintBordersFor( databaseConfigurationComposite ); databaseConfigurationComposite.setLayout( new GridLayout( 2, false ) ); databaseConfigurationSection.setClient( databaseConfigurationComposite ); // Directory Text toolkit.createLabel( databaseConfigurationComposite, "Directory:" ); Composite directoryComposite = toolkit.createComposite( databaseConfigurationComposite ); GridLayout directoryCompositeGridLayout = new GridLayout( 2, false ); directoryCompositeGridLayout.marginHeight = directoryCompositeGridLayout.marginWidth = 0; directoryCompositeGridLayout.verticalSpacing = 0; directoryComposite.setLayout( directoryCompositeGridLayout ); directoryComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); directoryBrowserWidget = new DirectoryBrowserWidget( "" ); directoryBrowserWidget.createWidget( directoryComposite, toolkit ); // Mode Text toolkit.createLabel( databaseConfigurationComposite, "Mode:" ); modeUnixPermissionsWidget = new UnixPermissionsWidget(); modeUnixPermissionsWidget.create( databaseConfigurationComposite, toolkit ); modeUnixPermissionsWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Configuration Text toolkit.createLabel( databaseConfigurationComposite, "Configuration:" ); editConfigurationButton = toolkit.createButton( databaseConfigurationComposite, "Edit Configuration...", SWT.PUSH ); editConfigurationButton.addSelectionListener( editConfigurationButtonSelectionListener ); // Crypt File Text toolkit.createLabel( databaseConfigurationComposite, "Crypt File:" ); Composite cryptFileComposite = toolkit.createComposite( databaseConfigurationComposite ); GridLayout cryptFileCompositeGridLayout = new GridLayout( 2, false ); cryptFileCompositeGridLayout.marginHeight = cryptFileCompositeGridLayout.marginWidth = 0; cryptFileCompositeGridLayout.verticalSpacing = 0; cryptFileComposite.setLayout( cryptFileCompositeGridLayout ); cryptFileComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); cryptFileBrowserWidget = new FileBrowserWidget( "", new String[0], FileBrowserWidget.TYPE_OPEN ); cryptFileBrowserWidget.createWidget( cryptFileComposite, toolkit ); // Crypt Key Text toolkit.createLabel( databaseConfigurationComposite, "Crypt Key:" ); cryptKeyText = toolkit.createText( databaseConfigurationComposite, "" ); cryptKeyText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Shared Memory Key Text toolkit.createLabel( databaseConfigurationComposite, "Shared Memory Key:" ); sharedMemoryKeyText = BaseWidgetUtils.createIntegerText( toolkit, databaseConfigurationComposite ); sharedMemoryKeyText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database indexes section. * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseIndexesSection( Composite parent, FormToolkit toolkit ) { // Database Indices Section Section databaseIndexesSection = toolkit.createSection( parent, Section.TWISTIE ); databaseIndexesSection.setText( "Database Indices" ); databaseIndexesSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseIndexesComposite = toolkit.createComposite( databaseIndexesSection ); toolkit.paintBordersFor( databaseIndexesComposite ); databaseIndexesComposite.setLayout( new GridLayout( 2, false ) ); databaseIndexesSection.setClient( databaseIndexesComposite ); // Indices Widget indicesWidget = new IndicesWidget( browserConnection ); indicesWidget.createWidgetWithEdit( databaseIndexesComposite, toolkit ); indicesWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); // Linear Indexes Widget toolkit.createLabel( databaseIndexesComposite, "Linear Index:" ); linearIndexBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false ); linearIndexBooleanWithDefaultWidget.create( databaseIndexesComposite, toolkit ); linearIndexBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database cache section. * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseCacheSection( Composite parent, FormToolkit toolkit ) { // Database Cache Section Section databaseCacheSection = toolkit.createSection( parent, Section.TWISTIE ); databaseCacheSection.setText( "Database Cache" ); databaseCacheSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseCacheComposite = toolkit.createComposite( databaseCacheSection ); toolkit.paintBordersFor( databaseCacheComposite ); databaseCacheComposite.setLayout( new GridLayout( 2, false ) ); databaseCacheSection.setClient( databaseCacheComposite ); // Cache Size Text toolkit.createLabel( databaseCacheComposite, "Cache Size:" ); cacheSizeText = BaseWidgetUtils.createIntegerText( toolkit, databaseCacheComposite ); cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Cache Free Text toolkit.createLabel( databaseCacheComposite, "Cache Free:" ); cacheFreeText = BaseWidgetUtils.createIntegerText( toolkit, databaseCacheComposite ); cacheFreeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // DN Cache Size Text toolkit.createLabel( databaseCacheComposite, "DN Cache Size:" ); dnCacheSizeText = BaseWidgetUtils.createIntegerText( toolkit, databaseCacheComposite ); dnCacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // IDL Cache Size Text toolkit.createLabel( databaseCacheComposite, "IDL Cache Size:" ); idlCacheSizeText = BaseWidgetUtils.createIntegerText( toolkit, databaseCacheComposite ); idlCacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database limits section. * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseLimitsSection( Composite parent, FormToolkit toolkit ) { // Database Limits Section Section databaseLimitsSection = toolkit.createSection( parent, Section.TWISTIE ); databaseLimitsSection.setText( "Database Limits" ); databaseLimitsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseLimitsComposite = toolkit.createComposite( databaseLimitsSection ); toolkit.paintBordersFor( databaseLimitsComposite ); databaseLimitsComposite.setLayout( new GridLayout( 2, false ) ); databaseLimitsSection.setClient( databaseLimitsComposite ); // Search Stack Depth Text toolkit.createLabel( databaseLimitsComposite, "Search Stack Depth:" ); searchStackDepthText = BaseWidgetUtils.createIntegerText( toolkit, databaseLimitsComposite ); searchStackDepthText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Page Size Text toolkit.createLabel( databaseLimitsComposite, "Page Size:" ); pageSizeText = toolkit.createText( databaseLimitsComposite, "" ); pageSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Checkpoint Text toolkit.createLabel( databaseLimitsComposite, "Checkpoint Interval:" ); checkpointText = toolkit.createText( databaseLimitsComposite, "" ); checkpointText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * Creates the database options section. * * @param parent the parent composite * @param toolkit the toolkit */ private void createDatabaseOptionsSection( Composite parent, FormToolkit toolkit ) { // Database Options Section Section databaseOptionsSection = toolkit.createSection( parent, Section.TWISTIE ); databaseOptionsSection.setText( "Database Options" ); databaseOptionsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite databaseOptionsComposite = toolkit.createComposite( databaseOptionsSection ); toolkit.paintBordersFor( databaseOptionsComposite ); databaseOptionsComposite.setLayout( new GridLayout( 2, false ) ); databaseOptionsSection.setClient( databaseOptionsComposite ); // Disable Synchronous Database Writes Widget toolkit.createLabel( databaseOptionsComposite, "Disable Synchronous Database Writes:" ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.create( databaseOptionsComposite, toolkit ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Allow Reads Of Uncommited Data Widget toolkit.createLabel( databaseOptionsComposite, "Allow Reads Of Uncommited Data:" ); allowReadsOfUncommitedDataBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false ); allowReadsOfUncommitedDataBooleanWithDefaultWidget.create( databaseOptionsComposite, toolkit ); allowReadsOfUncommitedDataBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Deadlock Detection Algorithm Widget toolkit.createLabel( databaseOptionsComposite, "Deadlock Detection Algorithm:" ); lockDetectWidget = new LockDetectWidget(); lockDetectWidget.createWidget( databaseOptionsComposite ); lockDetectWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { // Directory Text String directory = database.getOlcDbDirectory(); directoryBrowserWidget.setDirectoryPath( ( directory == null ) ? "" : directory ); // Mode Text String mode = database.getOlcDbMode(); modeUnixPermissionsWidget.setValue( mode ); // Crypt File Text String cryptFile = database.getOlcDbCryptFile(); cryptFileBrowserWidget.setFilename( ( cryptFile == null ) ? "" : cryptFile ); // Crypt Key Text byte[] cryptKey = database.getOlcDbCryptKey(); cryptKeyText.setText( ( cryptKey == null ) ? "" : new String( cryptKey ) ); //$NON-NLS-1$ // Shared Memory Key Text Integer sharedMemoryKey = database.getOlcDbShmKey(); sharedMemoryKeyText.setText( ( sharedMemoryKey == null ) ? "" : "" + sharedMemoryKey ); //$NON-NLS-1$ // Indices Text //indicesWidget.setIndices( database.getOlcDbIndex() ); // Linear Index Widget linearIndexBooleanWithDefaultWidget.setValue( database.getOlcDbLinearIndex() ); // Cache Size Text Integer cacheSize = database.getOlcDbCacheSize(); cacheSizeText.setText( ( cacheSize == null ) ? "" : "" + cacheSize ); //$NON-NLS-1$ // Cache Free Text Integer cacheFree = database.getOlcDbCacheFree(); cacheFreeText.setText( ( cacheFree == null ) ? "" : "" + cacheFree ); //$NON-NLS-1$ // DN Cache Size Text Integer dnCacheSize = database.getOlcDbDNcacheSize(); dnCacheSizeText.setText( ( dnCacheSize == null ) ? "" : "" + dnCacheSize ); //$NON-NLS-1$ // IDL Cache Size Text Integer idlCacheSize = database.getOlcDbIDLcacheSize(); idlCacheSizeText.setText( ( idlCacheSize == null ) ? "" : "" + idlCacheSize ); //$NON-NLS-1$ // Search Stack Depth Text Integer searchStackDepth = database.getOlcDbSearchStack(); searchStackDepthText.setText( ( searchStackDepth == null ) ? "" : "" + searchStackDepth ); //$NON-NLS-1$ // Page Size Text List<String> pageSize = database.getOlcDbPageSize(); pageSizeText.setText( ( pageSize == null ) ? "" : OpenLdapConfigurationPluginUtils.concatenate( pageSize ) ); //$NON-NLS-1$ // Checkpoint Text String checkpoint = database.getOlcDbCheckpoint(); checkpointText.setText( ( checkpoint == null ) ? "" : checkpoint ); //$NON-NLS-1$ // Disable Synchronous Database Writes Widget disableSynchronousDatabaseWritesBooleanWithDefaultWidget.setValue( database.getOlcDbNoSync() ); // Allow Reads Of Uncommited Data Widget allowReadsOfUncommitedDataBooleanWithDefaultWidget.setValue( database.getOlcDbDirtyRead() ); // Deadlock Detection Algorithm Text lockDetectWidget.setValue( OlcBdbConfigLockDetectEnum.fromString( database.getOlcDbLockDetect() ) ); } addListeners(); } /** * Adds the listeners. */ private void addListeners() { directoryBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); modeUnixPermissionsWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); editConfigurationButton.addSelectionListener( editConfigurationButtonSelectionListener ); cryptFileBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); cryptKeyText.addModifyListener( dirtyModifyListener ); sharedMemoryKeyText.addModifyListener( dirtyModifyListener ); indicesWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); linearIndexBooleanWithDefaultWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); cacheSizeText.addModifyListener( dirtyModifyListener ); cacheFreeText.addModifyListener( dirtyModifyListener ); dnCacheSizeText.addModifyListener( dirtyModifyListener ); idlCacheSizeText.addModifyListener( dirtyModifyListener ); searchStackDepthText.addModifyListener( dirtyModifyListener ); pageSizeText.addModifyListener( dirtyModifyListener ); checkpointText.addModifyListener( dirtyModifyListener ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); allowReadsOfUncommitedDataBooleanWithDefaultWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); lockDetectWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); } /** * Removes the listeners */ private void removeListeners() { directoryBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); modeUnixPermissionsWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); editConfigurationButton.removeSelectionListener( editConfigurationButtonSelectionListener ); cryptFileBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); cryptKeyText.removeModifyListener( dirtyModifyListener ); sharedMemoryKeyText.removeModifyListener( dirtyModifyListener ); indicesWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); linearIndexBooleanWithDefaultWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); cacheSizeText.removeModifyListener( dirtyModifyListener ); cacheFreeText.removeModifyListener( dirtyModifyListener ); dnCacheSizeText.removeModifyListener( dirtyModifyListener ); idlCacheSizeText.removeModifyListener( dirtyModifyListener ); searchStackDepthText.removeModifyListener( dirtyModifyListener ); pageSizeText.removeModifyListener( dirtyModifyListener ); checkpointText.removeModifyListener( dirtyModifyListener ); disableSynchronousDatabaseWritesBooleanWithDefaultWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); allowReadsOfUncommitedDataBooleanWithDefaultWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); lockDetectWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { // Directory Text String directory = directoryBrowserWidget.getDirectoryPath(); if ( Strings.isEmpty( directory ) ) { database.setOlcDbDirectory( null ); } else { database.setOlcDbDirectory( directory ); } directoryBrowserWidget.saveDialogSettings(); // Mode Text database.setOlcDbMode( modeUnixPermissionsWidget.getValue() ); // Crypt File Text String cryptFile = cryptFileBrowserWidget.getFilename(); if ( Strings.isEmpty( cryptFile ) ) { database.setOlcDbCryptFile( null ); } else { database.setOlcDbCryptFile( cryptFile ); } cryptFileBrowserWidget.saveDialogSettings(); // Crypt Key Text String cryptKey = cryptKeyText.getText(); if ( Strings.isEmpty( cryptKey ) ) { database.setOlcDbCryptKey( null ); } else { database.setOlcDbCryptKey( cryptKey.getBytes() ); } // Shared Memory Key Text try { database.setOlcDbShmKey( Integer.parseInt( sharedMemoryKeyText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbShmKey( null ); } // Indices Widget database.clearOlcDbIndex(); /* for ( String index : indicesWidget.getIndices() ) { database.addOlcDbIndex( index ); } */ // Linear Index Widget database.setOlcDbLinearIndex( linearIndexBooleanWithDefaultWidget.getValue() ); // Cache Size Text try { database.setOlcDbCacheSize( Integer.parseInt( cacheSizeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbCacheSize( null ); } // Cache Free Text try { database.setOlcDbCacheFree( Integer.parseInt( cacheFreeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbCacheFree( null ); } // DN Cache Size Text try { database.setOlcDbDNcacheSize( Integer.parseInt( dnCacheSizeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbDNcacheSize( null ); } // IDL Cache Size Text try { database.setOlcDbIDLcacheSize( Integer.parseInt( idlCacheSizeText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbIDLcacheSize( null ); } // Search Stack Depth Text try { database.setOlcDbSearchStack( Integer.parseInt( searchStackDepthText.getText() ) ); } catch ( NumberFormatException e ) { database.setOlcDbSearchStack( null ); } // Page Size Text //TODO // Checkpoint Text database.setOlcDbCheckpoint( checkpointText.getText() ); // Disable Synchronous Database Writes Widget database.setOlcDbNoSync( disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getValue() ); // Allow Reads Of Uncommited Data Widget database.setOlcDbDirtyRead( allowReadsOfUncommitedDataBooleanWithDefaultWidget.getValue() ); // Deadlock Detection Algorithm Text OlcBdbConfigLockDetectEnum lockDetect = lockDetectWidget.getValue(); if ( lockDetect != null ) { database.setOlcDbLockDetect( lockDetect.toString() ); } else { database.setOlcDbLockDetect( null ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.databases; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget; import org.apache.directory.studio.openldap.config.model.database.OlcRelayConfig; /** * This interface represents a block for Relay Specific Details. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RelayDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcRelayConfig> { // UI Widgets private EntryWidget relayEntryWidget; /** * Creates a new instance of NullDatabaseSpecificDetailsBlock. * * @param detailsPage the details page * @param database the database * @param browserConnection the connection */ public RelayDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcRelayConfig database, IBrowserConnection browserConnection ) { super( detailsPage, database, browserConnection ); } /** * {@inheritDoc} */ public Composite createBlockContent( Composite parent, FormToolkit toolkit ) { // Composite Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout( 3, false ) ); composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Relay toolkit.createLabel( composite, "Relay:" ); relayEntryWidget = new EntryWidget( browserConnection ); relayEntryWidget.createWidget( composite, toolkit ); relayEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); return composite; } /** * {@inheritDoc} */ public void refresh() { removeListeners(); if ( database != null ) { // Relay relayEntryWidget.setInput( database.getOlcRelay() ); } addListeners(); } /** * Adds the listeners. */ private void addListeners() { relayEntryWidget.addWidgetModifyListener( dirtyWidgetModifyListener ); } /** * Removes the listeners */ private void removeListeners() { relayEntryWidget.removeWidgetModifyListener( dirtyWidgetModifyListener ); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { if ( database != null ) { // Relay Dn relay = relayEntryWidget.getDn(); if ( ( relay != null ) & ( !Dn.EMPTY_DN.equals( relay ) ) ) { database.setOlcRelay( relay ); } else { database.setOlcRelay( null ); } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/DatabasesPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/DatabasesPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.databases.DatabasesMasterDetailsBlock; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; /** * This class represents the Databases Page of the Server Configuration Editor. It just * create a main page that contains two other pages, a master block and a detail block. * * NOTE : I'm not sure we need this page... * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DatabasesPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = DatabasesPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "OpenLDAPDatabasesPage.Title" ); //$NON-NLS-1$ /** The master details block */ private DatabasesMasterDetailsBlock masterDetailsBlock; /** * Creates a new instance of DatabasePage. * * @param editor the associated editor */ public DatabasesPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { masterDetailsBlock = new DatabasesMasterDetailsBlock( this ); masterDetailsBlock.createContent( getManagedForm() ); } /** * {@inheritDoc} */ public void refreshUI() { if ( isInitialized() ) { masterDetailsBlock.refreshUI(); } } /** * {@inheritDoc} */ @Override public void doSave( IProgressMonitor monitor ) { if ( masterDetailsBlock != null ) { masterDetailsBlock.doSave( monitor ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.openldap.common.ui.model.PasswordHashEnum; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog; import org.apache.directory.studio.openldap.config.editor.dialogs.SaslSecPropsDialog; import org.apache.directory.studio.openldap.config.editor.wrappers.PasswordHashDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.SsfDecorator; import org.apache.directory.studio.openldap.config.model.OlcGlobal; /** * This class represents the Security Page of the Server Configuration Editor. It covers * the TLS configuration, the SASL configuration and some othe rseci-urity parameters. * <ul> * <li> TLS : * <ul> * <li>olcTLSCACertificateFile</li> * <li>olcTLSCACertificatePath</li> * <li>olcTLSCertificateFile</li> * <li>olcTLSCertificateKeyFile</li> * <li>olcTLSCipherSuite</li> * <li>olcTLSCrlCheck</li> * <li>olcTLSCrlFile</li> * <li>olcTLSDhParamFile</li> * <li>olcTLSProtocolMin</li> * <li>olcTLSRandFile</li> * <li>olcTLSVerifyClient></li> * </ul> * </li> * <li> SASL : * <ul> * <li>olcSaslAuxProps</li> * <li>olcSaslHost</li> * <li>olcSaslRealm</li> * <li>olcSaslSecProps</li> * </ul> * </li> * <li> Miscellaneous : * <ul> * <li>olcLocalSsf</li> * <li>olcPasswordCryptSaltFormat</li> * <li>olcPasswordHash</li> * <li>olcSecurity</li> * </ul> * </li> * </ul> * * <pre> * +------------------------------------------------------------------------------------------------------+ * | Security Configuration | * +------------------------------------------------------------------------------------------------------+ * | .-----------------------------------------------. .------------------------------------------------. | * | |V TLS Configuration | |V SASL Configuration | | * | +-----------------------------------------------+ +------------------------------------------------+ | * | | TLS Certificate File : [ ] | | SASL Host : [ ] | | * | | TLS Certificate Key File : [ ] | | SASL Realm : [ ] | | * | | TLS CA Certificate File : [ ] | | SASL Auxprops plugin : [ ] | | * | | TLS CA Certificate Path : [ ] | | SASL Security Properties : [ ] (Edit...) | | * | | TLS Cipher Suite : [ ] | +------------------------------------------------+ | * | | TLS CRL Check : [=============] | .------------------------------------------------. | * | | TLS CRL File : [ ] | |V Miscellaneous Security Parameters | | * | | TLS DH Parameter File : [ ] | +------------------------------------------------+ | * | | TLS Minimum Protocol : [=============] | | Local SSF : [ ] pWD Crypt Salt : [ ] | | * | | TLS Random Bits File : [ ] | | | | * | | TLS Verify Client : [=============] | | Password Hash : | | * | +-----------------------------------------------+ | +----------------------------------+ | | * | | | | (Add) | | * | | | | (Delete) | | * | | | | | | * | | +----------------------------------+ | | * | | Security : | | * | | +----------------------------------+ | | * | | | | (Add) | | * | | | | (Edit) | | * | | | | (Delete) | | * | | +----------------------------------+ | | * | +------------------------------------------------+ | * +------------------------------------------------------------------------------------------------------+ * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SecurityPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = SecurityPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "OpenLDAPSecurityPage.Title" ); //$NON-NLS-1$ // UI Controls for the TLS part /** The olcTLSCACertificateFile Text */ private Text tlsCaCertificateFileText; /** The olcTLSCACertificatePath Text */ private Text tlsCaCertificatePathText; /** The olcTLSCertificateFile Text */ private Text tlsCertificateFileText; /** The olcTLSCertificateKeyFile Text */ private Text tlsCertificateKeyFileText; /** The olcTLSCipherSuite Text */ private Text tlsCipherSuiteText; /** The olcTLSCrlCheck Text */ private Combo tlsCrlCheckCombo; /** The olcTLSCrlFile Text */ private Text tlsCrlFileText; /** The olcTLSDhParamFile Text */ private Text tlsDhParamFileText; /** The olcTLSProtocolMin Text */ private Combo tlsProtocolMinCombo; /** The olcTLSRandFile Text */ private Text tlsRandFileText; /** The olcTLSVerifyClient Text */ private Combo tlsVerifyClientCombo; // UI Controls for the SASL part /** The olcSaslAuxProps */ private Text saslAuxPropsText; /** The olcSaslHost */ private Text saslHostText; /** The olcSaslRealm */ private Text saslRealmText; /** The olcSaslSecProps */ private Text saslSecPropsText; private Button saslSecPropsEditButton; // UI Controls for the Misc part /** The olcLocalSSF */ private Text localSsfText; /** The olcPasswordCryptSaltFormat */ private Text passwordCryptSaltFormatText; /** The olcPasswordHash */ private TableWidget<PasswordHashEnum> passwordHashTableWidget; /** The olcSecurity table widget */ private TableWidget<SsfWrapper> securityTableWidget; /** A constant for the no-selection in Combo */ private static final String NO_CHOICE = "---"; /** The CRL Checks */ private static final String[] crlChecks = new String[] { NO_CHOICE, "none", "peer", "all" }; /** The list of supported protocols */ private static final String[] protocols = new String[] { NO_CHOICE, "3.0", "3.1", "3.2" }; /** The list of VerifyClients */ private static final String[] verifyClients = new String[] { NO_CHOICE, "never", "allow", "try", "demand", "hard", "true" }; /** * The olcLocalSSF listener */ private ModifyListener localSsfListener = event -> { if ( !Strings.isEmpty( localSsfText.getText() ) ) { getConfiguration().getGlobal().setOlcLocalSSF( Integer.valueOf( localSsfText.getText() ) ); } }; /** * The olcPasswordCryptSaltFormat listener */ private ModifyListener passwordCryptSaltFormatListener = event -> getConfiguration().getGlobal().setOlcPasswordCryptSaltFormat( passwordCryptSaltFormatText.getText() ); /** * The olcPasswordHash listener */ private WidgetModifyListener passwordHashListener = event -> { List<String> passwordHashes = new ArrayList<>(); for ( PasswordHashEnum passwordHash : passwordHashTableWidget.getElements() ) { passwordHashes.add( passwordHash.getName() ); } getConfiguration().getGlobal().setOlcPasswordHash( passwordHashes ); }; /** * The olcSecurity listener */ private WidgetModifyListener securityListener = event -> { List<String> ssfWrappers = new ArrayList<>(); for ( SsfWrapper ssfWrapper : securityTableWidget.getElements() ) { ssfWrappers.add( ssfWrapper.toString() ); } getConfiguration().getGlobal().setOlcSecurity( ssfWrappers ); }; /** * The olcTlsCertificateFile listener */ private ModifyListener tlsCertificateFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSCertificateFile( tlsCertificateFileText.getText() ); /** * The olcTlsCertificateKeyFile listener */ private ModifyListener tlsCertificateKeyFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSCertificateKeyFile( tlsCertificateKeyFileText.getText() ); /** * The olcTlsCACertificateFile listener */ private ModifyListener tlsCaCertificateFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSCACertificateFile( tlsCaCertificateFileText.getText() ); /** * The olcTlsCACertificatePath listener */ private ModifyListener tlsCaCertificatePathTextListener = event -> getConfiguration().getGlobal().setOlcTLSCACertificatePath( tlsCaCertificatePathText.getText() ); /** * The olcTlsCipherSuite listener */ private ModifyListener tlsCipherSuiteTextListener = event -> getConfiguration().getGlobal().setOlcTLSCipherSuite( tlsCipherSuiteText.getText() ); /** * The olcTlsCrlFile listener */ private ModifyListener tlsCrlFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSCRLFile( tlsCrlFileText.getText() ); /** * The olcTlsCrlCheck listener */ private SelectionListener tlsCrlCheckComboListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcTLSCRLCheck( tlsCrlCheckCombo.getText() ); } }; /** * The olcTlsDhParamFile listener */ private ModifyListener tlsDhParamFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSDHParamFile( tlsDhParamFileText.getText() ); /** * The olcTlsRandFile listener */ private ModifyListener tlsRandFileTextListener = event -> getConfiguration().getGlobal().setOlcTLSRandFile( tlsRandFileText.getText() ); /** * The olcTlsProtocolMin listener */ private SelectionListener tlsProtocolMinComboListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcTLSProtocolMin( tlsProtocolMinCombo.getText() ); } }; /** * The olcTlsVerifyClient listener */ private SelectionListener tlsVerifyClientComboListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcTLSVerifyClient( tlsVerifyClientCombo.getText() ); } }; /** * The olcSaslAuxProps listener */ private ModifyListener saslAuxPropsTextListener = event -> getConfiguration().getGlobal().setOlcSaslAuxprops( saslAuxPropsText.getText() ); /** * The olcSaslHost listener */ private ModifyListener saslHostTextListener = event -> getConfiguration().getGlobal().setOlcSaslHost( saslHostText.getText() ); /** * The olcSaslrealm listener */ private ModifyListener saslRealmTextListener = event -> getConfiguration().getGlobal().setOlcSaslRealm( saslRealmText.getText() ); /** * The listener for the SaslSecProps Text */ private SelectionListener saslSecPropsEditSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { SaslSecPropsDialog dialog = new SaslSecPropsDialog( saslSecPropsText.getShell(), saslSecPropsText.getText() ); if ( dialog.open() == OverlayDialog.OK ) { String saslSecPropsValue = dialog.getSaslSecPropsValue(); if ( saslSecPropsValue != null ) { saslSecPropsText.setText( saslSecPropsValue ); } getConfiguration().getGlobal().setOlcSaslSecProps( saslSecPropsValue ); } } }; /** * Creates a new instance of SecurityPage. * * @param editor the associated editor */ public SecurityPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * Creates the OpenLDAP Security config Tab. It contains 2 rows, with * 2 columns : * * <pre> * +-----------------------------------+---------------------------------+ * | | | * | | SASL | * | | | * | TLS +---------------------------------+ * | | | * | | miscellaneous | * | | | * +-----------------------------------+---------------------------------+ * </pre> */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { TableWrapLayout twl = new TableWrapLayout(); twl.numColumns = 2; twl.makeColumnsEqualWidth = true; parent.setLayout( twl ); // The TLS part Composite tlsComposite = toolkit.createComposite( parent ); tlsComposite.setLayout( new GridLayout() ); TableWrapData tlsCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 2, 1 ); tlsCompositeTableWrapData.grabHorizontal = true; tlsComposite.setLayoutData( tlsCompositeTableWrapData ); // The SASL part Composite saslComposite = toolkit.createComposite( parent ); saslComposite.setLayout( new GridLayout() ); TableWrapData saslCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); saslCompositeTableWrapData.grabHorizontal = true; saslComposite.setLayoutData( saslCompositeTableWrapData ); // The MISC part Composite miscComposite = toolkit.createComposite( parent ); miscComposite.setLayout( new GridLayout() ); TableWrapData miscCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); miscCompositeTableWrapData.grabHorizontal = true; miscComposite.setLayoutData( miscCompositeTableWrapData ); // Now, create the sections createTlsSection( toolkit, tlsComposite ); createSaslSection( toolkit, saslComposite ); createMiscSection( toolkit, miscComposite ); } /** * Creates the TLS section. This section is a grid with 4 columns, * <ul> * <li>olcTLSCACertificateFile</li> * <li>olcTLSCACertificatePath</li> * <li>olcTLSCertificateFile</li> * <li>olcTLSCertificateKeyFile</li> * <li>olcTLSCipherSuite</li> * <li>olcTLSCrlCheck</li> * <li>olcTLSCrlFile</li> * <li>olcTLSDhParamFile</li> * <li>olcTLSProtocolMin</li> * <li>olcTLSRandFile</li> * <li>olcTLSVerifyClient></li> * </ul> * * <pre> * .-----------------------------------------------. * |V TLS parameters | * +-----------------------------------------------+ * | | * | TLS Certificate File : [ ] | * | TLS Certificate Key File : [ ] | * | TLS CA Certificate File : [ ] | * | TLS CA Certificate Path : [ ] | * | TLS Cipher Suite : [ ] | * | TLS CRL Check : [=============] | * | TLS CRL File : [ ] | * | TLS DH Parameter File : [ ] | * | TLS Minimum Protocol : [=============] | * | TLS Random Bits File : [ ] | * | TLS Verify Client : [=============] | * +-----------------------------------------------+ * </pre> * * @param toolkit the toolkit * @param parent the parent composite */ private void createTlsSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPSecurityPage.TlsSection" ) ); // The content Composite tlsSectionComposite = createSectionComposite( toolkit, section, 2, false ); // The tlsCertificateFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCertificateFile" ) ); //$NON-NLS-1$ tlsCertificateFileText = toolkit.createText( tlsSectionComposite, "" ); tlsCertificateFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCertificateFileText, tlsCertificateFileTextListener ); // The tlsCertificateKeyFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCertificateKeyFile" ) ); //$NON-NLS-1$ tlsCertificateKeyFileText = toolkit.createText( tlsSectionComposite, "" ); tlsCertificateKeyFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCertificateKeyFileText, tlsCertificateKeyFileTextListener ); // The tlsCaCertificateFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCACertificateFile" ) ); //$NON-NLS-1$ tlsCaCertificateFileText = toolkit.createText( tlsSectionComposite, "" ); tlsCaCertificateFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCaCertificateFileText, tlsCaCertificateFileTextListener ); // The tlsCaCertificatePath parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCACertificatePath" ) ); //$NON-NLS-1$ tlsCaCertificatePathText = toolkit.createText( tlsSectionComposite, "" ); tlsCaCertificatePathText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCaCertificatePathText, tlsCaCertificatePathTextListener ); // The tlsCipherSuite parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCipherSuite" ) ); //$NON-NLS-1$ tlsCipherSuiteText = toolkit.createText( tlsSectionComposite, "" ); tlsCipherSuiteText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCipherSuiteText, tlsCipherSuiteTextListener ); // The tlsDHParamFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSDHParamFile" ) ); //$NON-NLS-1$ tlsDhParamFileText = toolkit.createText( tlsSectionComposite, "" ); tlsDhParamFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsDhParamFileText, tlsDhParamFileTextListener ); // The tlsRandFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSRandFile" ) ); //$NON-NLS-1$ tlsRandFileText = toolkit.createText( tlsSectionComposite, "" ); tlsRandFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsRandFileText, tlsRandFileTextListener ); // The tlsCRLFile parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCRLFile" ) ); //$NON-NLS-1$ tlsCrlFileText = toolkit.createText( tlsSectionComposite, "" ); tlsCrlFileText.setLayoutData( new GridData(GridData.FILL_HORIZONTAL ) ); addModifyListener( tlsCrlFileText, tlsCrlFileTextListener ); // The tlsCRLCheck parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSCRLCheck" ) ); //$NON-NLS-1$ tlsCrlCheckCombo = BaseWidgetUtils.createCombo( tlsSectionComposite, crlChecks, -1, 1 ); tlsCrlCheckCombo.addSelectionListener( tlsCrlCheckComboListener ); // The tlsProtocolMin parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSProtocolMin" ) ); //$NON-NLS-1$ tlsProtocolMinCombo = BaseWidgetUtils.createCombo( tlsSectionComposite, protocols, -1, 1 ); tlsProtocolMinCombo.addSelectionListener( tlsProtocolMinComboListener ); // The tlsProtocolMin parameter toolkit.createLabel( tlsSectionComposite, Messages.getString( "OpenLDAPSecurityPage.TLSVerifyClient" ) ); //$NON-NLS-1$ tlsVerifyClientCombo = BaseWidgetUtils.createCombo( tlsSectionComposite, verifyClients, -1, 1 ); tlsVerifyClientCombo.addSelectionListener( tlsVerifyClientComboListener ); } /** * Creates the SASL section. This section is a grid with 4 columns, * <ul> * <li>olcSaslAuxProps</li> * <li>olcSaslHost</li> * <li>olcSaslRealm</li> * <li>olcSaslSecProps</li> * </ul> * * <pre> * .---------------------------------------------------------. * |V SASL Parameters | * +---------------------------------------------------------+ * | SASL Host : [ ] | * | SASL Realm : [ ] | * | SASL Auxprops plugin : [ ] | * | SASL Security Properties : [ ] (Edit...) | * +---------------------------------------------------------+ * </pre> * * * @param toolkit the toolkit * @param parent the parent composite */ private void createSaslSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPSecurityPage.SaslSection" ) ); // The content Composite saslSectionComposite = createSectionComposite( toolkit, section, 3, false ); // The saslHost parameter toolkit.createLabel( saslSectionComposite, Messages.getString( "OpenLDAPSecurityPage.SaslHost" ) ); //$NON-NLS-1$ saslHostText = toolkit.createText( saslSectionComposite, "" ); saslHostText.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false, 2, 1 ) ); addModifyListener( saslHostText, saslHostTextListener ); // The saslRealm parameter toolkit.createLabel( saslSectionComposite, Messages.getString( "OpenLDAPSecurityPage.SaslRealm" ) ); //$NON-NLS-1$ saslRealmText = toolkit.createText( saslSectionComposite, "" ); saslRealmText.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false, 2, 1 ) ); addModifyListener( saslRealmText, saslRealmTextListener ); // The saslAuxProps parameter toolkit.createLabel( saslSectionComposite, Messages.getString( "OpenLDAPSecurityPage.SaslAuxProps" ) ); //$NON-NLS-1$ saslAuxPropsText = toolkit.createText( saslSectionComposite, "" ); saslAuxPropsText.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false, 2, 1 ) ); addModifyListener( saslAuxPropsText, saslAuxPropsTextListener ); // The saslSecProps parameter toolkit.createLabel( saslSectionComposite, Messages.getString( "OpenLDAPSecurityPage.SaslSecProps" ) ); //$NON-NLS-1$ saslSecPropsText = toolkit.createText( saslSectionComposite, "" ); saslSecPropsText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); saslSecPropsEditButton = BaseWidgetUtils.createButton( saslSectionComposite, Messages.getString( "OpenLDAPSecurityPage.Edit" ), 1 ); saslSecPropsEditButton.setLayoutData( new GridData( SWT.RIGHT, SWT.CENTER, false, false ) ); saslSecPropsEditButton.addSelectionListener( saslSecPropsEditSelectionListener ); } /** * Creates the Misc section. This section is a grid with 4 columns, * <ul> * <li>olcLocalSsf</li> * <li>olcPasswordCryptSaltFormat</li> * <li>olcPasswordHash</li> * <li>olcSecurity</li> * </ul> * * <pre> * .-------------------------------------------------------------------------------. * |V Miscellaneous Security Parameters | * +-------------------------------------------------------------------------------+ * | Local SSF : [ ] Password Crypt Salt format : [ ] | * | | * | Password Hash : | * | +-----------------------------------------------------------------+ | * | | | (Add) | * | | | (Delete) | * | | | | * | +-----------------------------------------------------------------+ | * | Security : | * | +-----------------------------------------------------------------+ | * | | | (Add) | * | | | (Edit) | * | | | (Delete) | * | +-----------------------------------------------------------------+ | * +-------------------------------------------------------------------------------+ * </pre> * * * @param toolkit the toolkit * @param parent the parent composite */ private void createMiscSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPSecurityPage.MiscSection" ) ); // The content Composite miscSectionComposite = createSectionComposite( toolkit, section, 4, false ); // The LocalSSF parameter toolkit.createLabel( miscSectionComposite, Messages.getString( "OpenLDAPSecurityPage.LocalSSF" ) ); //$NON-NLS-1$ localSsfText = toolkit.createText( miscSectionComposite, "" ); addModifyListener( localSsfText, localSsfListener ); // The PasswordCryptSaltFormat parameter toolkit.createLabel( miscSectionComposite, Messages.getString( "OpenLDAPSecurityPage.PasswordCryptSaltFormat" ) ); //$NON-NLS-1$ passwordCryptSaltFormatText = toolkit.createText( miscSectionComposite, "" ); addModifyListener( passwordCryptSaltFormatText, passwordCryptSaltFormatListener ); // A blank line toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); // The PasswordHash widget Label passwordHashLabel = toolkit.createLabel( miscSectionComposite, Messages.getString( "OpenLDAPSecurityPage.PasswordHash" ) ); //$NON-NLS-1$ passwordHashLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 4, 1 ) ); passwordHashTableWidget = new TableWidget<>( new PasswordHashDecorator( miscSectionComposite.getShell() ) ); passwordHashTableWidget.createWidgetNoEdit( miscSectionComposite, toolkit ); passwordHashTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) ); addModifyListener( passwordHashTableWidget, passwordHashListener ); // A blank line toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); toolkit.createLabel( miscSectionComposite, "" ); // The Security widget Label securityLabel = toolkit.createLabel( miscSectionComposite, Messages.getString( "OpenLDAPSecurityPage.Security" ) ); //$NON-NLS-1$ securityLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 4, 1 ) ); securityTableWidget = new TableWidget<>( new SsfDecorator( miscSectionComposite.getShell() ) ); securityTableWidget.createWidgetWithEdit( miscSectionComposite, toolkit ); securityTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) ); addModifyListener( securityTableWidget, securityListener ); } /** * {@inheritDoc} */ public void refreshUI() { removeListeners(); // Getting the global configuration object OlcGlobal global = getConfiguration().getGlobal(); if ( global != null ) { // // Assigning values to UI Controls //
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverlayType.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverlayType.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; /** * This enum describes the various type of overlays. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum OverlayType { /** None */ NONE, /** Acess Log */ ACCESS_LOG, /** Audit Log */ AUDIT_LOG, /** Chain */ CHAIN, /** Dist Proc */ DIST_PROC, /** PBind */ PBIND, /** Password Policy */ PASSWORD_POLICY, /** SyncProv */ SYNC_PROV; }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/LoadingPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/LoadingPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import org.apache.directory.studio.openldap.config.editor.Messages; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.editor.FormPage; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; /** * This class represents the Loading Page of the Server Configuration Editor. It is * just a plain page which expose a progress bar and a message : * * <pre> * .---------------------------------------------. * | Loading Configuration... | * +---------------------------------------------+ * | | * | | * | [ \\ \\ \\ \\ \\ ] | * | Loading the configuration, please wait... | * | | * | | * +---------------------------------------------+ * </pre> * * Once the configuration is loaded, this page is closed. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LoadingPage extends FormPage { /** The Page ID*/ public static final String ID = LoadingPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "LoadingPage.LoadingConfiguration" ); /** * Creates a new instance of LoadingPage. * * @param editor the associated editor */ public LoadingPage( FormEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} */ @Override protected void createFormContent( IManagedForm managedForm ) { ScrolledForm form = managedForm.getForm(); form.setText( Messages.getString( "LoadingPage.LoadingConfigurationEllipsis" ) ); Composite parent = form.getBody(); parent.setLayout( new GridLayout() ); FormToolkit toolkit = managedForm.getToolkit(); toolkit.decorateFormHeading( form.getForm() ); Composite composite = toolkit.createComposite( parent ); composite.setLayout( new GridLayout() ); composite.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, true ) ); ProgressBar progressBar = new ProgressBar( composite, SWT.INDETERMINATE ); progressBar.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) ); Label label = toolkit.createLabel( composite, Messages.getString( "LoadingPage.LoadingTheConfigurationPleaseWait" ) ); label.setLayoutData( new GridData( SWT.CENTER, SWT.NONE, false, false ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OpenLDAPServerConfigurationEditorPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OpenLDAPServerConfigurationEditorPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import org.apache.directory.studio.common.ui.CommonUIConstants; import org.apache.directory.studio.common.ui.CommonUIPlugin; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.openldap.config.actions.EditorExportConfigurationAction; import org.apache.directory.studio.openldap.config.actions.EditorImportConfigurationAction; import org.apache.directory.studio.openldap.config.editor.Messages; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormPage; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * This class represents the General Page of the Server Configuration Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class OpenLDAPServerConfigurationEditorPage extends FormPage { protected static final String TABULATION = " "; /** A flag to indicate if the page is initialized */ protected boolean isInitialized = false; /** * A listener used to set the dirty flag when a Text is updated */ protected ModifyListener dirtyModifyListener = event -> setEditorDirty(); /** * A listener used to set the dirty flag when a widget is selected */ private SelectionListener dirtySelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { setEditorDirty(); } }; /** * A listener used to set the dirty flag when a widget is updated */ protected WidgetModifyListener dirtyWidgetModifyListener = event -> setEditorDirty(); /** * Creates a new instance of GeneralPage. * * @param editor the associated editor */ public OpenLDAPServerConfigurationEditorPage( OpenLdapServerConfigurationEditor editor, String id, String title ) { super( editor, id, title ); } /** * Gets the ServerConfigurationEditor object associated with the page. * * @return the ServerConfigurationEditor object associated with the page */ public OpenLdapServerConfigurationEditor getServerConfigurationEditor() { return ( OpenLdapServerConfigurationEditor ) getEditor(); } /** * Sets the associated editor dirty. */ private void setEditorDirty() { getServerConfigurationEditor().setDirty( true ); } /** * Gets the configuration associated with the editor. * * @return the configuration associated with the editor */ public OpenLdapConfiguration getConfiguration() { OpenLdapConfiguration configuration = getServerConfigurationEditor().getConfiguration(); if ( configuration == null ) { configuration = new OpenLdapConfiguration(); getServerConfigurationEditor().setConfiguration( configuration ); } return configuration; } /** * {@inheritDoc} */ @Override protected void createFormContent( IManagedForm managedForm ) { ScrolledForm form = managedForm.getForm(); form.setText( getTitle() ); Composite parent = form.getBody(); parent.setLayout( new GridLayout() ); FormToolkit toolkit = managedForm.getToolkit(); toolkit.decorateFormHeading( form.getForm() ); OpenLdapServerConfigurationEditor editor = ( OpenLdapServerConfigurationEditor ) getEditor(); IToolBarManager toolbarManager = form.getToolBarManager(); toolbarManager.add( new EditorImportConfigurationAction( editor ) ); toolbarManager.add( new Separator() ); toolbarManager.add( new EditorExportConfigurationAction( editor ) ); toolbarManager.update( true ); createFormContent( parent, toolkit ); isInitialized = true; } /** * Subclasses must implement this method to create the content of their form. * * @param parent the parent element * @param toolkit the form toolkit */ protected abstract void createFormContent( Composite parent, FormToolkit toolkit ); /** * Refreshes the UI. */ public abstract void refreshUI(); /** * Indicates if the page is initialized. * * @return <code>true</code> if the page is initialized, * <code>false</code> if not. */ public boolean isInitialized() { return isInitialized; } /** * Creates a Text that can be used to enter a port number. * * @param toolkit the toolkit * @param parent the parent * @return a Text that can be used to enter a port number */ protected Text createPortText( FormToolkit toolkit, Composite parent ) { Text portText = toolkit.createText( parent, "" ); //$NON-NLS-1$ GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false ); gd.widthHint = 42; portText.setLayoutData( gd ); portText.addVerifyListener( event -> { if ( !event.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { event.doit = false; } } ); portText.setTextLimit( 5 ); return portText; } /** * A shared method used to create a Section, based on a GridLayout. * * @param toolkit The Form toolkit * @param parent The parent * @param title The Section title * @param nbColumns The number of columns for the inner grid * * @return The created Composite */ protected Composite createSection( FormToolkit toolkit, Composite parent, String title, int nbColumns, int style ) { Section section = toolkit.createSection( parent, style ); section.setText( Messages.getString( title ) ); section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout gridLayout = new GridLayout( nbColumns, false ); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; composite.setLayout( gridLayout ); section.setClient( composite ); return composite; } /** * Creates default value Label. * * @param toolkit the toolkit * @param parent the parent * @param text the text string * @return a default value Label */ protected Label createDefaultValueLabel( FormToolkit toolkit, Composite parent, String text ) { Label label = toolkit.createLabel( parent, NLS.bind( "(Default: {0})", text ) ); label.setForeground( CommonUIPlugin.getDefault().getColor( CommonUIConstants.KEYWORD_1_COLOR ) ); return label; } /** * Adds a modify listener to the given Text. * * @param text the Text control * @param listener the listener */ protected void addModifyListener( Text text, ModifyListener listener ) { if ( ( text != null ) && ( !text.isDisposed() ) && ( listener != null ) ) { text.addModifyListener( listener ); } } /** * Adds a selection listener to the given Button. * * @param button the Button control * @param listener the listener */ protected void addSelectionListener( Button button, SelectionListener listener ) { if ( ( button != null ) && ( !button.isDisposed() ) && ( listener != null ) ) { button.addSelectionListener( listener ); } } /** * Adds a selection listener to the given Combo. * * @param combo the Combo control * @param listener the listener */ protected void addSelectionListener( Combo combo, SelectionListener listener ) { if ( ( combo != null ) && ( !combo.isDisposed() ) && ( listener != null ) ) { combo.addSelectionListener( listener ); } } /** * Adds a modify listener to the given TableWidget. * * @param tableWidget the TableWidget control * @param listener the listener */ protected void addModifyListener( TableWidget<?> tableWidget, WidgetModifyListener listener ) { if ( ( tableWidget != null ) && ( listener != null ) ) { tableWidget.addWidgetModifyListener( listener ); } } /** * Removes a modify listener to the given Text. * * @param text the Text control * @param listener the listener */ protected void removeModifyListener( Text text, ModifyListener listener ) { if ( ( text != null ) && ( !text.isDisposed() ) && ( listener != null ) ) { text.removeModifyListener( listener ); } } /** * Removes a selection listener to the given Button. * * @param button the Button control * @param listener the listener */ protected void removeSelectionListener( Button button, SelectionListener listener ) { if ( ( button != null ) && ( !button.isDisposed() ) && ( listener != null ) ) { button.removeSelectionListener( listener ); } } /** * Removes a selection listener to the given Combo. * * @param combo the Combo control * @param listener the listener */ protected void removeSelectionListener( Combo combo, SelectionListener listener ) { if ( ( combo != null ) && ( !combo.isDisposed() ) && ( listener != null ) ) { combo.removeSelectionListener( listener ); } } /** * Removes a modify listener to the given TableWidget. * * @param tableWidget the TableWidget control * @param listener the listener */ protected void removeModifyListener( TableWidget<?> tableWidget, WidgetModifyListener listener ) { if ( ( tableWidget != null ) && ( listener != null ) ) { tableWidget.removeWidgetModifyListener( listener ); } } /** * Adds a 'dirty' listener to the given Text. * * @param text the Text control */ protected void addDirtyListener( Text text ) { addModifyListener( text, dirtyModifyListener ); } /** * Adds a 'dirty' listener to the given Button. * * @param button the Button control */ protected void addDirtyListener( Button button ) { addSelectionListener( button, dirtySelectionListener ); } /** * Adds a 'dirty' listener to the given Combo. * * @param button the Button control */ protected void addDirtyListener( Combo combo ) { addSelectionListener( combo, dirtySelectionListener ); } /** * Adds a 'dirty' listener to the given TableWidget. * * @param tableWidget the TableWidget control */ protected void addDirtyListener( TableWidget<?> tableWidget ) { addModifyListener( tableWidget, dirtyWidgetModifyListener ); } /** * Removes a 'dirty' listener to the given Text. * * @param text the Text control */ protected void removeDirtyListener( Text text ) { removeModifyListener( text, dirtyModifyListener ); } /** * Removes a 'dirty' listener to the given Button. * * @param button the Button control */ protected void removeDirtyListener( Button button ) { removeSelectionListener( button, dirtySelectionListener ); } /** * Removes a 'dirty' listener to the given Combo. * * @param combo the Combo control */ protected void removeDirtyListener( Combo combo ) { removeSelectionListener( combo, dirtySelectionListener ); } /** * Removes a 'dirty' listener to the given TableWidget. * * @param tableWidget the TableWidget control */ protected void removeDirtyListener( TableWidget<?> tableWidget ) { removeModifyListener( tableWidget, dirtyWidgetModifyListener ); } /** * Sets the selection state of the button widget. * <p> * Verifies that the button exists and is not disposed * before applying the new selection state. * * @param button the button * @param selected the new selection state */ protected void setSelection( Button button, boolean selected ) { if ( ( button != null ) && ( !button.isDisposed() ) ) { button.setSelection( selected ); } } /** * Sets the contents of the text widget. * <p> * Verifies that the button exists and is not disposed * before applying the new text. * * @param text the text * @param string the new text */ protected void setText( Text text, String string ) { if ( ( text != null ) && ( !text.isDisposed() ) ) { text.setText( string ); } } protected void setFocus( Control control ) { if ( ( control != null ) && ( !control.isDisposed() ) ) { control.setFocus(); } } /** * Create an expandable Section with a title */ protected Section createSection( FormToolkit toolkit, Composite parent, String title ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED); section.setText( title ); //$NON-NLS-1$ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); return section; } /** * Creates a composite for the given section. * * @param toolkit the toolkit * @param section the section * @param numColumns the number of columns in the grid * @param makeColumnsEqualWidth whether or not the columns will have equal width * * @return a composite for the given section. */ protected Composite createSectionComposite( FormToolkit toolkit, Section section, int numColumns, boolean makeColumnsEqualWidth ) { Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout gridLayout = new GridLayout( numColumns, makeColumnsEqualWidth ); gridLayout.marginHeight = gridLayout.marginWidth = 0; composite.setLayout( gridLayout ); section.setClient( composite ); return composite; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.openldap.common.ui.model.LogLevelEnum; import org.apache.directory.studio.openldap.common.ui.dialogs.LogLevelDialog; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapper; import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapperLabelProvider; import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapperViewerSorter; import org.apache.directory.studio.openldap.config.editor.pages.OverlaysPage; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperLabelProvider; import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperViewerComparator; import org.apache.directory.studio.openldap.config.editor.wrappers.ServerIdDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.ServerIdWrapper; import org.apache.directory.studio.openldap.config.model.OlcGlobal; import org.apache.directory.studio.openldap.config.model.OlcModuleList; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; /** * This class represents the General Page of the Server Configuration Editor. It exposes some * of the configured elements, and allow the user to configure some basic parameters : * <ul> * <li>olcServerID</li> * <li>olcConfigDir</li> * <li>olcConfigFile</li> * <li>olcPidFile</li> * <li>olcLogFile</li> * <li>olcLogLevel</li> * </ul> * * The olcConfigFile is not handled, it's deprecated. * <pre> * .-----------------------------------------------------------------------------------. * | Overview | * +-----------------------------------------------------------------------------------+ * | .-------------------------------------------------------------------------------. | * | |V Global parameters | | * | +-------------------------------------------------------------------------------+ | * | | Server ID : | | * | | +-----------------------------------------------------------------+ | | * | | | | (Add) | | * | | | | (Edit) | | * | | | | (Delete) | | * | | +-----------------------------------------------------------------+ | | * | | | | * | | Configuration Dir : [ ] Pid File : [ ] | | * | | Log File : [ ] Log Level : [ ] (edit)| | * | +-------------------------------------------------------------------------------+ | * | | * | .---------------------------------------. .------------------------------------. | * | |V Databases | |V Overlays | | * | +---------------------------------------+ +------------------------------------+ | * | | +----------------------------------+ | | +--------------------------------+ | | * | | | abc | | | | module 1 | | | * | | | xyz | | | | module 2 | | | * | | +----------------------------------+ | | +--------------------------------+ | | * | | <Advanced databases configuration> | | <Overlays configuration> | | * | +---------------------------------------+ +------------------------------------+ | * | | * | .-------------------------------------------------------------------------------. | * | |V Configuration detail | | * | +-------------------------------------------------------------------------------+ | * | | <Security configuration> <Tunning configuration> | | * | | <Schemas configuration> <Options configuration> | | * | +-------------------------------------------------------------------------------+ | * +-----------------------------------------------------------------------------------+ * </pre> * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OverviewPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = OverviewPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "OpenLDAPOverviewPage.Title" ); //$NON-NLS-1$ // UI Controls /** The serverID wrapper */ private List<ServerIdWrapper> serverIdWrappers = new ArrayList<>(); /** The Widget used to manage ServerID */ private TableWidget<ServerIdWrapper> serverIdTableWidget; /** olcConfigDir */ private Text configDirText; /** olcPidFile */ private Text pidFileText; /** olcLogFile */ private Text logFileText; /** olcLogLevel */ private Text logLevelText; private Button logLevelEditButton; /** The table listing all the existing databases */ private TableViewer databaseViewer; /** The database wrappers */ private List<DatabaseWrapper> databaseWrappers = new ArrayList<>(); /** This link opens the Databases configuration tab */ private Hyperlink databasesPageLink; /** The table listing all the existing modules */ private TableViewer moduleViewer; /** The module wrappers */ private List<ModuleWrapper> moduleWrappers = new ArrayList<>(); /** This link opens the Overlays configuration tab */ private Hyperlink overlaysPageLink; /** This link opens the Security configuration tab */ private Hyperlink securityPageLink; /** This link opens the Tuning configuration tab */ private Hyperlink tuningPageLink; /** This link opens the Schema configuration tab */ private Hyperlink schemaPageLink; /** This link opens the Options configuration tab */ private Hyperlink optionsPageLink; /** * The olcLogFile listener */ private ModifyListener logFileTextListener = event -> getConfiguration().getGlobal().setOlcLogFile( logFileText.getText() ); /** * The olcConfigDir listener */ private ModifyListener configDirTextListener = event -> getConfiguration().getGlobal().setOlcConfigDir( configDirText.getText() ); /** * The olcPidFile listener */ private ModifyListener pidFileTextListener = event -> getConfiguration().getGlobal().setOlcPidFile( pidFileText.getText() ); /** * The olcLogLevl listener */ private SelectionListener logLevelEditButtonSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { // Creating and opening a LogLevel dialog String logLevelStr = logLevelText.getText(); int logLevelValue = LogLevelEnum.NONE.getValue(); if ( !Strings.isEmpty( logLevelStr ) ) { logLevelValue = LogLevelEnum.parseLogLevel( logLevelStr ); } LogLevelDialog dialog = new LogLevelDialog( logLevelEditButton.getShell(), logLevelValue ); if ( LogLevelDialog.OK == dialog.open() ) { logLevelStr = LogLevelEnum.getLogLevelText( dialog.getLogLevelValue() ); logLevelText.setText( logLevelStr ); List<String> logLevelList = new ArrayList<>(); logLevelList.add( logLevelStr ); getConfiguration().getGlobal().setOlcLogLevel( logLevelList ); } } }; /** * Creates a new instance of GeneralPage. * * @param editor the associated editor */ public OverviewPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * Databases configuration hyper link adapter */ private HyperlinkAdapter databasesPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { getServerConfigurationEditor().showPage( DatabasesPage.class ); } }; /** * Overlays configuration hyper link adapter */ private HyperlinkAdapter overlaysPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { getServerConfigurationEditor().showPage( OverlaysPage.class ); } }; /** * Security configuration hyper link adapter */ private HyperlinkAdapter securityPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { getServerConfigurationEditor().showPage( SecurityPage.class ); } }; /** * Tuning configuration hyper link adapter */ private HyperlinkAdapter tuningPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { getServerConfigurationEditor().showPage( TuningPage.class ); } }; /** * Schema configuration hyper link adapter */ private HyperlinkAdapter schemaPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { //getServerConfigurationEditor().showPage( SchemaPage.class ); } }; /** * Options configuration hyper link adapter */ private HyperlinkAdapter optionsPageLinkListener = new HyperlinkAdapter() { @Override public void linkActivated( HyperlinkEvent e ) { getServerConfigurationEditor().showPage( OptionsPage.class ); } }; // The listener for the ServerIdTableWidget private WidgetModifyListener serverIdTableWidgetListener = event -> { // Process the parameter modification TableWidget<ServerIdWrapper> serverIdWrapperTable = (TableWidget<ServerIdWrapper>)event.getSource(); List<String> serverIds = new ArrayList<>(); for ( Object serverIdWrapper : serverIdWrapperTable.getElements() ) { String str = serverIdWrapper.toString(); serverIds.add( str ); } getConfiguration().getGlobal().setOlcServerID( serverIds ); }; /** * Creates the global Overview OpenLDAP config Tab. It contains 3 rows, with * one or two sections in each : * * <pre> * +---------------------------------------------------------------------+ * | | * | Global parameters | * | | * +-----------------------------------+---------------------------------+ * | | | * | Databases | Overlays | * | | | * +-----------------------------------+---------------------------------+ * | | * | Configuration links | * | | * +---------------------------------------------------------------------+ * </pre> * {@inheritDoc} */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { TableWrapLayout twl = new TableWrapLayout(); twl.numColumns = 2; parent.setLayout( twl ); // The upper part Composite upperComposite = toolkit.createComposite( parent ); upperComposite.setLayout( new GridLayout() ); TableWrapData leftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 2 ); leftCompositeTableWrapData.grabHorizontal = true; upperComposite.setLayoutData( leftCompositeTableWrapData ); // The middle left part Composite middleLeftComposite = toolkit.createComposite( parent ); middleLeftComposite.setLayout( new GridLayout() ); TableWrapData middleLeftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); middleLeftCompositeTableWrapData.grabHorizontal = true; middleLeftComposite.setLayoutData( middleLeftCompositeTableWrapData ); // The middle right part Composite middleRightComposite = toolkit.createComposite( parent ); middleRightComposite.setLayout( new GridLayout() ); TableWrapData middleRightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); middleRightCompositeTableWrapData.grabHorizontal = true; middleRightComposite.setLayoutData( middleRightCompositeTableWrapData ); // The lower part Composite lowerComposite = toolkit.createComposite( parent ); lowerComposite.setLayout( new GridLayout() ); TableWrapData lowerCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 2 ); lowerCompositeTableWrapData.grabHorizontal = true; lowerComposite.setLayoutData( lowerCompositeTableWrapData ); // Now, create the sections createGlobalSection( toolkit, upperComposite ); createDatabasesSection( toolkit, middleLeftComposite ); createOverlaysSection( toolkit, middleRightComposite ); createConfigDetailsLinksSection( toolkit, lowerComposite ); } /** * Creates the global section. This section is a grid with 4 columns, * where we configure the global options. We support the configuration * of those parameters : * <ul> * <li>olcServerID</li> * <li>olcConfigDir</li> * <li>olcPidFile</li> * <li>olcLogFile</li> * <li>olcLogLevel</li> * </ul> * * <pre> * .-------------------------------------------------------------------------------. * |V Global parameters | * +-------------------------------------------------------------------------------+ * | Server ID : | * | +-----------------------------------------------------------------+ | * | | | (Add) | * | | | (Edit) | * | | | (Delete) | * | +-----------------------------------------------------------------+ | * | | * | Configuration Dir : [ ] Pid File : [ ] | * | Log File : [ ] Log Level : [ ] (edit)| * +-------------------------------------------------------------------------------+ * </pre> * * * @param toolkit the toolkit * @param parent the parent composite */ private void createGlobalSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOverviewPage.GlobalSection" ) ); // The content Composite globalSectionComposite = toolkit.createComposite( section ); toolkit.paintBordersFor( globalSectionComposite ); GridLayout gridLayout = new GridLayout( 5, false ); gridLayout.marginHeight = gridLayout.marginWidth = 0; globalSectionComposite.setLayout( gridLayout ); section.setClient( globalSectionComposite ); // The ServerID parameter. Label serverIdLabel = toolkit.createLabel( globalSectionComposite, Messages.getString( "OpenLDAPOverviewPage.ServerID" ) ); //$NON-NLS-1$ serverIdLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 5, 1 ) ); // The ServerID widget serverIdTableWidget = new TableWidget<>( new ServerIdDecorator( section.getShell() ) ); serverIdTableWidget.createWidgetWithEdit( globalSectionComposite, toolkit ); serverIdTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 5, 1 ) ); serverIdTableWidget.addWidgetModifyListener( serverIdTableWidgetListener ); // One blank line for ( int i = 0; i < gridLayout.numColumns; i++ ) { toolkit.createLabel( globalSectionComposite, TABULATION ); } // The ConfigDir parameter toolkit.createLabel( globalSectionComposite, Messages.getString( "OpenLDAPOverviewPage.ConfigDir" ) ); //$NON-NLS-1$ configDirText = createConfigDirText( toolkit, globalSectionComposite ); // The PidFile parameter toolkit.createLabel( globalSectionComposite, Messages.getString( "OpenLDAPOverviewPage.PidFile" ) ); //$NON-NLS-1$ pidFileText = createPidFileText( toolkit, globalSectionComposite ); // The LogFile parameter toolkit.createLabel( globalSectionComposite, Messages.getString( "OpenLDAPOverviewPage.LogFile" ) ); //$NON-NLS-1$ logFileText = createLogFileText( toolkit, globalSectionComposite ); // The LogLevel parameter toolkit.createLabel( globalSectionComposite, Messages.getString( "OpenLDAPOverviewPage.LogLevel" ) ); logLevelText = BaseWidgetUtils.createText( globalSectionComposite, "", 1 ); logLevelText.setEditable( false ); logLevelEditButton = BaseWidgetUtils.createButton( globalSectionComposite, Messages.getString( "OpenLDAPSecurityPage.EditLogLevels" ), 1 ); logLevelEditButton.addSelectionListener( logLevelEditButtonSelectionListener ); } /** * Creates the Databases section. It only expose the existing databases, * they can't be changed. * * <pre> * .------------------------------------. * |V Databases | * +------------------------------------+ * | +-------------------------------+ | * | | abc | | * | | xyz | | * | +-------------------------------+ | * | <Advanced databases configuration> | * +------------------------------------+ * </pre> * * @param toolkit the toolkit * @param parent the parent composite */ private void createDatabasesSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOverviewPage.DatabasesSection" ) ); // The content Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout gridLayout = new GridLayout( 1, false ); gridLayout.marginHeight = gridLayout.marginWidth = 0; composite.setLayout( gridLayout ); section.setClient( composite ); // The inner composite Composite databaseComposite = toolkit.createComposite( section ); databaseComposite.setLayout( new GridLayout( 1, false ) ); toolkit.paintBordersFor( databaseComposite ); section.setClient( databaseComposite ); section.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); // Creating the Table and Table Viewer Table table = toolkit.createTable( databaseComposite, SWT.NONE ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 5 ); gd.heightHint = 100; gd.widthHint = 100; table.setLayoutData( gd ); databaseViewer = new TableViewer( table ); databaseViewer.setContentProvider( new ArrayContentProvider() ); databaseViewer.setLabelProvider( new DatabaseWrapperLabelProvider() ); databaseViewer.setComparator( new DatabaseWrapperViewerComparator() ); // Databases Page Link databasesPageLink = toolkit.createHyperlink( databaseComposite, Messages.getString( "OpenLDAPOverviewPage.DatabasesPageLink" ), SWT.NONE ); //$NON-NLS-1$ databasesPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); databasesPageLink.addHyperlinkListener( databasesPageLinkListener ); } /** * Creates the Overlays section. It only expose the existing overlays, * they can't be changed. * * <pre> * .------------------------------------. * |V Overlays | * +------------------------------------+ * | +-------------------------------+ | * | | abc | | * | | xyz | | * | +-------------------------------+ | * | <Advanced Overlays configuration> | * +------------------------------------+ * </pre> * * @param toolkit the toolkit * @param parent the parent composite */ private void createOverlaysSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOverviewPage.OverlaysSection" ) ); // The content Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout gridLayout = new GridLayout( 1, false ); gridLayout.marginHeight = gridLayout.marginWidth = 0; composite.setLayout( gridLayout ); section.setClient( composite ); // The inner composite Composite overlayComposite = toolkit.createComposite( section ); overlayComposite.setLayout( new GridLayout( 1, false ) ); toolkit.paintBordersFor( overlayComposite ); section.setClient( overlayComposite ); section.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); // Creating the Table and Table Viewer Table table = toolkit.createTable( overlayComposite, SWT.NONE ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 5 ); gd.heightHint = 100; gd.widthHint = 100; table.setLayoutData( gd ); moduleViewer = new TableViewer( table ); moduleViewer.setContentProvider( new ArrayContentProvider() ); moduleViewer.setLabelProvider( new ModuleWrapperLabelProvider() ); moduleViewer.setComparator( new ModuleWrapperViewerSorter() ); // Overlays Page Link overlaysPageLink = toolkit.createHyperlink( overlayComposite, Messages.getString( "OpenLDAPOverviewPage.OverlaysPageLink" ), SWT.NONE ); //$NON-NLS-1$ overlaysPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); overlaysPageLink.addHyperlinkListener( overlaysPageLinkListener ); } /** * Creates the configuration details section. It just links to some other pages * * <pre> * .----------------------------------------------------. * |V Configuration detail | * +----------------------------------------------------+ * | <Security configuration> <Tunning configuration> | * | <Schemas configuration> <Options configuration> | * +----------------------------------------------------+ * </pre> * * @param toolkit the toolkit * @param parent the parent composite */ private void createConfigDetailsLinksSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOverviewPage.ConfigDetailsSection" ) ); // The content Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout gridLayout = new GridLayout( 2, false ); gridLayout.marginHeight = gridLayout.marginWidth = 0; composite.setLayout( gridLayout ); section.setClient( composite ); // Security Page Link securityPageLink = toolkit.createHyperlink( composite, Messages.getString( "OpenLDAPOverviewPage.SecurityPageLink" ), SWT.NONE ); //$NON-NLS-1$ securityPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); securityPageLink.addHyperlinkListener( securityPageLinkListener ); // Tuning Page Link tuningPageLink = toolkit.createHyperlink( composite, Messages.getString( "OpenLDAPOverviewPage.TuningPageLink" ), SWT.NONE ); //$NON-NLS-1$ tuningPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); tuningPageLink.addHyperlinkListener( tuningPageLinkListener ); // Schema Page Link schemaPageLink = toolkit.createHyperlink( composite, Messages.getString( "OpenLDAPOverviewPage.SchemaPageLink" ), SWT.NONE ); //$NON-NLS-1$ schemaPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); schemaPageLink.addHyperlinkListener( schemaPageLinkListener ); // Options Page Link optionsPageLink = toolkit.createHyperlink( composite, Messages.getString( "OpenLDAPOverviewPage.OptionsPageLink" ), SWT.NONE ); //$NON-NLS-1$ optionsPageLink.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 1, 1 ) ); optionsPageLink.addHyperlinkListener( optionsPageLinkListener ); } /** * Creates a Text that can be used to enter an ConfigDir. * * @param toolkit the toolkit * @param parent the parent * @return a Text that can be used to enter a config Dir */ private Text createConfigDirText( FormToolkit toolkit, Composite parent ) { final Text configDirText = toolkit.createText( parent, "" ); //$NON-NLS-1$ GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false ); gd.widthHint = 300; configDirText.setLayoutData( gd ); // No more than 512 digits configDirText.setTextLimit( 512 ); // The associated listener addModifyListener( configDirText, configDirTextListener ); return configDirText; } /** * Creates a Text that can be used to enter a PID file. * * @param toolkit the toolkit * @param parent the parent * @return a Text that can be used to enter a PID file */ private Text createPidFileText( FormToolkit toolkit, Composite parent ) { final Text pidFileText = toolkit.createText( parent, "" ); //$NON-NLS-1$ GridData gd = new GridData( SWT.FILL, SWT.NONE, false, true, 2, 1 ); gd.widthHint = 300; pidFileText.setLayoutData( gd ); // No more than 512 digits pidFileText.setTextLimit( 512 ); // The associated listener addModifyListener( pidFileText, pidFileTextListener ); return pidFileText; } /** * Creates a Text that can be used to enter a Log file. * * @param toolkit the toolkit * @param parent the parent * @return a Text that can be used to enter a Log file */ private Text createLogFileText( FormToolkit toolkit, Composite parent ) { final Text logFileText = toolkit.createText( parent, "" ); //$NON-NLS-1$ GridData gd = new GridData( SWT.NONE, SWT.NONE, false, false ); gd.widthHint = 300; logFileText.setLayoutData( gd ); // No more than 512 digits logFileText.setTextLimit( 512 ); // The associated listener addModifyListener( logFileText, logFileTextListener ); return logFileText; } /** * Get the various LogLevel values, and concatenate them in a String */ private String getLogLevel() { List<String> logLevelList = getConfiguration().getGlobal().getOlcLogLevel(); if ( logLevelList == null ) { return "none"; } boolean isFirst = true; StringBuilder sb = new StringBuilder(); for ( String logLevel : logLevelList ) { if ( isFirst ) { isFirst = false; } else { sb.append( " " ); } sb.append( logLevel ); } return sb.toString(); } /** * {@inheritDoc} */ public void refreshUI() { if ( isInitialized() ) { removeListeners(); // Getting the global configuration object OlcGlobal global = getConfiguration().getGlobal(); if ( global != null ) { // Update the ServerIDText // Update the DatabaseTableViewer serverIdWrappers.clear(); for ( String serverIdWrapper : global.getOlcServerID() ) { serverIdWrappers.add( new ServerIdWrapper( serverIdWrapper ) ); } serverIdTableWidget.setElements( serverIdWrappers ); // Update the ConfigDirText
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/ErrorPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/ErrorPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.io.PrintWriter; import java.io.StringWriter; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.editor.FormPage; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; /** * This class represents the Error Page of the Server Configuration Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ErrorPage extends FormPage { /** The Page ID*/ public static final String ID = ErrorPage.class.getName(); /** The Page Title */ private static final String TITLE = "Error opening the editor"; private static final String DETAILS_CLOSED = NLS.bind( "{0} >>", "Details" ); private static final String DETAILS_OPEN = NLS.bind( "<< {0}", "Details" ); /** The exception */ private Exception exception; /** The flag indicating that the details are shown */ private boolean detailsShown = false; // UI Controls private FormToolkit toolkit; private Composite parent; private Button detailsButton; private Text detailsText; /** * Creates a new instance of ErrorPage. * * @param editor * the associated editor */ public ErrorPage( FormEditor editor, Exception exception ) { super( editor, ID, TITLE ); this.exception = exception; } /** * {@inheritDoc} */ @Override protected void createFormContent( IManagedForm managedForm ) { ScrolledForm form = managedForm.getForm(); form.setText( "Error opening the editor" ); form.setImage( Display.getCurrent().getSystemImage( SWT.ICON_ERROR ) ); parent = form.getBody(); GridLayout gl = new GridLayout( 2, false ); gl.marginHeight = 10; gl.marginWidth = 10; parent.setLayout( gl ); parent.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); toolkit = managedForm.getToolkit(); toolkit.decorateFormHeading( form.getForm() ); // Error Label Label errorLabel = toolkit.createLabel( parent, "" ); errorLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Details Button detailsButton = new Button( parent, SWT.PUSH ); detailsButton.setText( DETAILS_CLOSED ); detailsButton.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) ); detailsButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { showOrHideDetailsView(); } } ); // Initializing with the exception if ( exception == null ) { errorLabel.setText( "Could not open the editor." ); detailsButton.setVisible( false ); } else { errorLabel.setText( NLS.bind( "Could not open the editor: {0}", exception.getMessage() ) ); //$NON-NLS-1$ } } /** * Shows or hides the details view. */ private void showOrHideDetailsView() { if ( detailsShown ) { detailsButton.setText( DETAILS_CLOSED ); detailsText.dispose(); } else { detailsButton.setText( DETAILS_OPEN ); detailsText = toolkit.createText( parent, getStackTrace( exception ), SWT.H_SCROLL | SWT.V_SCROLL ); detailsText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) ); } parent.layout( true, true ); detailsShown = !detailsShown; } /** * Gets the stackTrace of the given exception as a string. * * @param e * the exception * @return * the stackTrace of the given exception as a string */ private String getStackTrace( Exception e ) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter( sw, true ); e.printStackTrace( pw ); pw.flush(); sw.flush(); return sw.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/Messages.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/Messages.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file for the OpenLDAP pages. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { private Messages() { //Nothing to do } /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog; import org.apache.directory.studio.openldap.config.editor.dialogs.SizeLimitDialog; import org.apache.directory.studio.openldap.config.editor.wrappers.LimitWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.TcpBufferDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.TcpBufferWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitWrapper; import org.apache.directory.studio.openldap.config.model.OlcGlobal; /** * This class represents the Tuning Page of the Server Configuration Editor. We * manage the global tuning of the server, and more specifically, those parameters : * <ul> * <li>Network : * <ul> * <li>olcTCPBuffers</li> * <li>olcSockbufMaxIncoming</li> * <li>olcSockbufMaxIncomingAuth</li> * </ul> * </li> * <li>Concurrency : * <ul> * <li>olcConcurrency</li> * <li>olcConnMaxPending</li> * <li>olcConnMaxPendingAuth</li> * <li>olcListenerThreads</li> * <li>olcThreads</li> * <li>olcToolThreads</li> * </ul> * </li> * <li>LDAP limits : * <ul> * <li>olcIdleTimeout</li> * <li>olcSizeLimit</li> * <li>olcTimeLimit</li> * <li>olcWriteTimeout</li> * </ul> * </li> * <li>Index limits : * <ul> * <li>olcIndexIntLen</li> * <li>olcIndexSubstrAnyLen</li> * <li>olcIndexSubstrAnyStep</li> * <li>olcIndexSubstrIfMaxLen</li> * <li>olcIndexSubstrIfMinLen</li> * </ul> * </li> * </ul> * * <pre> * +---------------------------------------------------------------------------------+ * | Tuning | * +---------------------------------------------------------------------------------+ * | .-------------------------------------. .-------------------------------------. | * | | TCP configuration                   | | Concurrency | | * | +-------------------------------------+ +-------------------------------------+ | * | | TCPBuffers                          | | | | * | | +-----------------------+           | | Concurrency : [      ] | | * | | | xyz                   | (Add)     | | Max Pending Conn  : [      ] | | * | | | abc                   | (Edit)    | | Max Pending Conn Auth  : [      ] | | * | | |                       | (Delete)  | | Nb Threads  : [      ] | | * | | +-----------------------+           | | Nb Threads Tool Mode : [      ] | | * | |                                     | | Nb Listener threads  : [      ] | | * | | Max Incoming Buffer      : [      ] | | | | * | | Max Incoming Buffer Auth : [      ] | | | | * | +-------------------------------------+ +-------------------------------------+ | * | .-------------------------------------. .-------------------------------------. | * | | LDAP Limits                    | | Index Limits | | * | +-------------------------------------+ +-------------------------------------+ | * | | Write Timeout : [      ]  | | Integer Indices Length : [      ] | | * | | Idle Timeout : [      ]  | | Subany Indices Length  : [      ] | | * | | Size Limit : [ ] (Edit) | | Subany Indices Step   : [      ] | | * | | Time Limit : [ ] (Edit) | | Sub indices Max length : [      ] | | * | | +-----------------------+           | | Sub indices Min length : [      ] | | * | | | xyz                   | (Add)     | +-------------------------------------+ | * | | | abc                   | (Edit)    | | * | | |                       | (Delete)  | | * | | +-----------------------+           | | * | +-------------------------------------+ | * +---------------------------------------------------------------------------------+ * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class TuningPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = TuningPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "OpenLDAPTuningPage.Title" ); // UI Controls for the Network part /** The olcSockbufMaxIncoming Text */ private Text sockbufMaxIncomingText; /** The olcSockbufMaxIncomingAuth Text */ private Text sockbufMaxIncomingAuthText; /** The olcTCPBuffer widget */ private TableWidget<TcpBufferWrapper> tcpBufferTableWidget; // UI Controls for the Concurrency part /** The olcConcurrency Text */ private Text concurrencyText; /** The olcConnMaxPending Text */ private Text connMaxPendingText; /** The olcConnMaxPendingAuth Text */ private Text connMaxPendingAuthText; /** The olcListenerThreads Text */ private Text listenerThreadsText; /** The olcThreads Text */ private Text threadsText; /** The olcToolThreads Text */ private Text toolThreadsText; // UI Controls for the LDAP Limits /** The olcSizeLimit */ private Text sizeLimitText; /** The SizeLimit edit Button */ private Button sizeLimitEditButton; /** The TimeLimit edit Button */ private TableWidget<TimeLimitWrapper> timeLimitTableViewer; /** The olcWriteTimeout */ private Text writeTimeoutText; /** The olcIdleTimeout */ private Text idleTimeoutText; // UI Controls for the Index Limits /** The olcIndexIntLenText Text */ private Text indexIntLenText; /** The olcIndexSubstrAnyLen Text */ private Text indexSubstrAnyLenText; /** The olcIndexSubstrAnyStep Text */ private Text indexSubstrAnyStepText; /** The olcIndexSubstrIfMaxLen Text */ private Text indexSubstrIfMaxLenText; /** The olcIndexSubstrIfMinLen Text */ private Text indexSubstrIfMinLenText; /** * Creates a new instance of TuningPage. * * @param editor the associated editor */ public TuningPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * The listener for the sockbufMaxIncomingText Text */ private ModifyListener sockbufMaxIncomingTextListener = event -> { Display display = sockbufMaxIncomingText.getDisplay(); try { int sockbufMaxIncomingValue = Integer.parseInt( sockbufMaxIncomingText.getText() ); // The value must be between 0 and 0x3FFFF if ( ( sockbufMaxIncomingValue < 0 ) || ( sockbufMaxIncomingValue > 0x3FFFF ) ) { sockbufMaxIncomingText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } sockbufMaxIncomingText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcSockbufMaxIncoming( sockbufMaxIncomingValue ); } catch ( NumberFormatException nfe ) { // Not even a number sockbufMaxIncomingText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the sockbufMaxIncomingAuthText Text */ private ModifyListener sockbufMaxIncomingAuthTextListener = event -> { Display display = sockbufMaxIncomingAuthText.getDisplay(); try { String sockbufMaxIncomingAuthstr = sockbufMaxIncomingAuthText.getText(); int sockbufMaxIncomingAuthValue = Integer.parseInt( sockbufMaxIncomingAuthstr ); // The value must be between 0 and 0x3FFFFF if ( ( sockbufMaxIncomingAuthValue < 0 ) || ( sockbufMaxIncomingAuthValue > 0x3FFFFF ) ) { sockbufMaxIncomingAuthText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } sockbufMaxIncomingAuthText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcSockbufMaxIncomingAuth( sockbufMaxIncomingAuthstr ); } catch ( NumberFormatException nfe ) { // Not even a number sockbufMaxIncomingAuthText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the concurrencyText Text */ private ModifyListener concurrencyTextListener = event -> { Display display = concurrencyText.getDisplay(); try { int concurrencyValue = Integer.parseInt( concurrencyText.getText() ); // The value must be >= 0 if ( concurrencyValue < 0 ) { concurrencyText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } concurrencyText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcConcurrency( concurrencyValue ); } catch ( NumberFormatException nfe ) { // Not even a number concurrencyText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the connMaxPendingText Text */ private ModifyListener connMaxPendingTextListener = event -> { Display display = connMaxPendingText.getDisplay(); try { int connMaxPendingValue = Integer.parseInt( connMaxPendingText.getText() ); // The value must be >= 0 if ( connMaxPendingValue < 0 ) { connMaxPendingText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } connMaxPendingText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcConnMaxPending( connMaxPendingValue ); } catch ( NumberFormatException nfe ) { // Not even a number connMaxPendingText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the connMaxPendingAuthText Text */ private ModifyListener connMaxPendingAuthTextListener = event -> { Display display = connMaxPendingAuthText.getDisplay(); try { int connMaxPendingAuthValue = Integer.parseInt( connMaxPendingAuthText.getText() ); // The value must be >= 0 if ( connMaxPendingAuthValue < 0 ) { connMaxPendingAuthText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } connMaxPendingAuthText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcConnMaxPendingAuth( connMaxPendingAuthValue ); } catch ( NumberFormatException nfe ) { // Not even a number connMaxPendingAuthText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the listenerThreadsText Text */ private ModifyListener listenerThreadsTextListener = event -> { Display display = listenerThreadsText.getDisplay(); try { int listenerThreadsValue = Integer.parseInt( listenerThreadsText.getText() ); // The value must be >= 0 if ( listenerThreadsValue < 0 ) { listenerThreadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } listenerThreadsText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcListenerThreads( listenerThreadsValue ); } catch ( NumberFormatException nfe ) { // Not even a number listenerThreadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the ThreadsText Text */ private ModifyListener threadsTextListener = event -> { Display display = threadsText.getDisplay(); try { int threadsValue = Integer.parseInt( threadsText.getText() ); // The value must be >= 0 if ( threadsValue < 0 ) { threadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } threadsText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcThreads( threadsValue ); } catch ( NumberFormatException nfe ) { // Not even a number threadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the ToolThreadsText Text */ private ModifyListener toolThreadsTextListener = event -> { Display display = toolThreadsText.getDisplay(); try { int toolThreadsValue = Integer.parseInt( toolThreadsText.getText() ); // The value must be >= 0 if ( toolThreadsValue < 0 ) { toolThreadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } toolThreadsText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcToolThreads( toolThreadsValue ); } catch ( NumberFormatException nfe ) { // Not even a number toolThreadsText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the IndexIntLenText Text */ private ModifyListener indexIntLenTextListener = event -> { Display display = indexIntLenText.getDisplay(); try { int indexIntLenValue = Integer.parseInt( indexIntLenText.getText() ); // The value must be >= 0 if ( indexIntLenValue < 0 ) { indexIntLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } indexIntLenText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIndexIntLen( indexIntLenValue ); } catch ( NumberFormatException nfe ) { // Not even a number indexIntLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the IndexSubstrAnyLenText Text */ private ModifyListener indexSubstrAnyLenTextListener = event -> { Display display = indexSubstrAnyLenText.getDisplay(); try { int indexSubstrAnyLenValue = Integer.parseInt( indexSubstrAnyLenText.getText() ); // The value must be >= 0 if ( indexSubstrAnyLenValue < 0 ) { indexSubstrAnyLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } indexSubstrAnyLenText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIndexSubstrAnyLen( indexSubstrAnyLenValue ); } catch ( NumberFormatException nfe ) { // Not even a number indexSubstrAnyLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the IndexSubstrAnyStepText Text */ private ModifyListener indexSubstrAnyStepTextListener = event -> { Display display = indexSubstrAnyStepText.getDisplay(); try { int indexSubstrAnyStepValue = Integer.parseInt( indexSubstrAnyStepText.getText() ); // The value must be >= 0 if ( indexSubstrAnyStepValue < 0 ) { indexSubstrAnyStepText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } indexSubstrAnyStepText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIndexSubstrAnyStep( indexSubstrAnyStepValue ); } catch ( NumberFormatException nfe ) { // Not even a number indexSubstrAnyStepText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the IndexSubstrIfMaxLenText Text */ private ModifyListener indexSubstrIfMaxLenTextListener = event -> { Display display = indexSubstrIfMaxLenText.getDisplay(); try { int indexSubstrIfMaxLenValue = Integer.parseInt( indexSubstrIfMaxLenText.getText() ); // The value must be >= 0 if ( indexSubstrIfMaxLenValue < 0 ) { indexSubstrIfMaxLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } indexSubstrIfMaxLenText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIndexSubstrIfMaxLen( indexSubstrIfMaxLenValue ); } catch ( NumberFormatException nfe ) { // Not even a number indexSubstrIfMaxLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the IndexSubstrIfMinLenText Text */ private ModifyListener indexSubstrIfMinLenTextListener = event -> { Display display = indexSubstrIfMinLenText.getDisplay(); try { int indexSubstrIfMinLenValue = Integer.parseInt( indexSubstrIfMinLenText.getText() ); // The value must be >= 0 if ( indexSubstrIfMinLenValue < 0 ) { indexSubstrIfMinLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } indexSubstrIfMinLenText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIndexSubstrIfMinLen( indexSubstrIfMinLenValue ); } catch ( NumberFormatException nfe ) { // Not even a number indexSubstrIfMinLenText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the writeTimeout Text */ private ModifyListener writeTimeoutTextListener = event -> { Display display = writeTimeoutText.getDisplay(); try { int writeTimeoutValue = Integer.parseInt( writeTimeoutText.getText() ); // The value must be >= 0 if ( writeTimeoutValue < 0 ) { writeTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } writeTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcWriteTimeout( writeTimeoutValue ); } catch ( NumberFormatException nfe ) { // Not even a number writeTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; /** * The listener for the idleTimeout Text */ private ModifyListener idleTimeoutTextListener = event -> { Display display = idleTimeoutText.getDisplay(); try { int idleTimeoutValue = Integer.parseInt( idleTimeoutText.getText() ); // The value must be >= 0 if ( idleTimeoutValue < 0 ) { idleTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); return; } idleTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) ); getConfiguration().getGlobal().setOlcIdleTimeout( idleTimeoutValue ); } catch ( NumberFormatException nfe ) { // Not even a number idleTimeoutText.setForeground( display.getSystemColor( SWT.COLOR_RED ) ); } }; private WidgetModifyListener timeLimitTableListener = event -> { List<String> timeLimits = new ArrayList<>(); for ( LimitWrapper limitWrapper : timeLimitTableViewer.getElements() ) { timeLimits.add( limitWrapper.toString() ); } getConfiguration().getGlobal().setOlcTimeLimit( timeLimits ); }; /** * The listener for the sizeLimit Text */ private SelectionListener sizeLimitEditSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { SizeLimitDialog dialog = new SizeLimitDialog( sizeLimitText.getShell(), sizeLimitText.getText() ); if ( dialog.open() == OverlayDialog.OK ) { String newSizeLimitStr = dialog.getNewLimit(); if ( newSizeLimitStr != null ) { sizeLimitText.setText( newSizeLimitStr ); getConfiguration().getGlobal().setOlcSizeLimit( newSizeLimitStr ); } } } }; // The listener for the TcpBufferTableWidget private WidgetModifyListener tcpBufferTableWidgetListener = event -> { // Process the parameter modification TableWidget<TcpBufferWrapper> tcpBufferWrapperTable = (TableWidget<TcpBufferWrapper>)event.getSource(); List<String> tcpBuffers = new ArrayList<>(); for ( Object tcpBufferWrapper : tcpBufferWrapperTable.getElements() ) { String str = tcpBufferWrapper.toString(); tcpBuffers.add( str ); } getConfiguration().getGlobal().setOlcTCPBuffer( tcpBuffers ); }; /** * Creates the OpenLDAP tuning config Tab. It contains 2 rows, with * 2 columns : * * <pre> * +-----------------------------------+---------------------------------+ * | | | * | Network | Concurrency | * | | | * +-----------------------------------+---------------------------------+ * | | | * | LDAP limits | Index limits | * | | | * +-----------------------------------+---------------------------------+ * </pre> * {@inheritDoc} */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { TableWrapLayout twl = new TableWrapLayout(); twl.numColumns = 2; twl.makeColumnsEqualWidth = true; parent.setLayout( twl ); // The Network part Composite networkComposite = toolkit.createComposite( parent ); networkComposite.setLayout( new GridLayout() ); TableWrapData networkCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); networkCompositeTableWrapData.grabHorizontal = true; networkComposite.setLayoutData( networkCompositeTableWrapData ); // The Concurrency part Composite concurrencyComposite = toolkit.createComposite( parent ); concurrencyComposite.setLayout( new GridLayout() ); TableWrapData concurrencyCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); concurrencyCompositeTableWrapData.grabHorizontal = true; concurrencyComposite.setLayoutData( concurrencyCompositeTableWrapData ); // The LDAP Limits part Composite ldapLimitsComposite = toolkit.createComposite( parent ); ldapLimitsComposite.setLayout( new GridLayout() ); TableWrapData ldapLimitsCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); ldapLimitsCompositeTableWrapData.grabHorizontal = true; ldapLimitsComposite.setLayoutData( ldapLimitsCompositeTableWrapData ); // The Index Limits part Composite indexLimitsComposite = toolkit.createComposite( parent ); indexLimitsComposite.setLayout( new GridLayout() ); TableWrapData indexLimitsCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); indexLimitsCompositeTableWrapData.grabHorizontal = true; indexLimitsComposite.setLayoutData( indexLimitsCompositeTableWrapData ); // Now, create the sections createNetworkSection( toolkit, networkComposite ); createConcurrencySection( toolkit, concurrencyComposite ); createLdapLimitsSection( toolkit, ldapLimitsComposite ); createIndexLimitsSection( toolkit, indexLimitsComposite ); } /** * Creates the Network section. We support the configuration * of those parameters : * <ul> * <li>olcSockbufMaxIncoming</li> * <li>olcSockbufMaxIncomingAuth</li> * <li>olcTCPBuffer</li> * </ul> * * <pre> * .-------------------------------------. * | TCP configuration                   | * +-------------------------------------+ * | TCPBuffers                          | * | +-----------------------+           | * | | xyz                   | (Add)     | * | | abc                   | (Edit)    | * | |                       | (Delete)  | * | +-----------------------+           | * |                                     | * | Max Incoming Buffer      : [      ] | * | Max Incoming Buffer Auth : [      ] | * +-------------------------------------+ * </pre> * * * @param toolkit the toolkit * @param parent the parent composite */ private void createNetworkSection( FormToolkit toolkit, Composite parent ) { // Creation of the section Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPTuningPage.NetworkSection" ) ); // The content Composite networkSectionComposite = createSectionComposite( toolkit, section, 2, false ); // The TCPBuffers Label Label serverIdLabel = toolkit.createLabel( networkSectionComposite, Messages.getString( "OpenLDAPTuningPage.TCPBuffers" ) ); //$NON-NLS-1$ serverIdLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 2, 1 ) ); // The TCPBuffers widget tcpBufferTableWidget = new TableWidget<>( new TcpBufferDecorator( networkSectionComposite.getShell() ) ); tcpBufferTableWidget.createWidgetWithEdit( networkSectionComposite, toolkit );
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverlaysPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverlaysPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.widgets.FormToolkit; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.overlays.OverlaysMasterDetailsBlock; /** * This class represents the General Page of the Server Configuration Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OverlaysPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = OverlaysPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = "Overlays"; // UI Controls /** * Creates a new instance of GeneralPage. * * @param editor * the associated editor */ public OverlaysPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { OverlaysMasterDetailsBlock masterDetailsBlock = new OverlaysMasterDetailsBlock( this ); masterDetailsBlock.createContent( getManagedForm() ); } /** * {@inheritDoc} */ public void refreshUI() { // Nothing to do } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.pages; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.TableWidget; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.common.ui.wrappers.StringValueWrapper; import org.apache.directory.studio.openldap.common.ui.model.AllowFeatureEnum; import org.apache.directory.studio.openldap.common.ui.model.AuthzPolicyEnum; import org.apache.directory.studio.openldap.common.ui.model.DisallowFeatureEnum; import org.apache.directory.studio.openldap.common.ui.model.RequireConditionEnum; import org.apache.directory.studio.openldap.common.ui.model.RestrictOperationEnum; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.editor.OpenLdapServerConfigurationEditor; import org.apache.directory.studio.openldap.config.editor.wrappers.AllowFeatureDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.DisallowFeatureDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.OrderedStringValueDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.OrderedStringValueWrapper; import org.apache.directory.studio.openldap.config.editor.wrappers.RequireConditionDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.RestrictOperationDecorator; import org.apache.directory.studio.openldap.config.editor.wrappers.StringValueDecorator; import org.apache.directory.studio.openldap.config.model.OlcGlobal; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; /** * This class represents the Options Page of the Server Configuration Editor. We manage the * following parameters : * <ul> * <li>Operations and features : * <ul> * <li>olcAllows</li> * <li>olcDisallows</li> * <li>olcRequires</li> * <li>olcRestrict</li> * </ul> * </li> * <li>Authorization regexp & rewrite rules : * <ul> * <li>olcAuthIDRewrite</li> * <li>olcAuthzRegexp</li> * </ul> * </li> * <li>Miscellaneous options : * <ul> * <li>olcArgsFile</li> * <li>olcPluginLogFile</li> * <li>olcReferral</li> * <li>olcAuthzPolicy</li> * <li>olcRootDSE</li> * <li>olcReadOnly</li> * <li>olcGentleHUP</li> * <li>olcReadOnly</li> * <li>olcReverseLookup</li> * </ul> * </li> * </ul> * Here is the content of this page : * <pre> * .--------------------------------------------------------------------------------------. * | Options | * +--------------------------------------------------------------------------------------+ * | .---------------------------------------. .----------------------------------------. | * | |V Features | |V Operations | | * | +---------------------------------------+ +----------------------------------------+ | * | | | | | | * | | Allowed Features : | | Required Conditions : | | * | | +--------------------------+ | | +--------------------------+ | | * | | | xyz | (Add...) | | | xyz | (Add...) | | * | | | abcde | | | | abcde | | | * | | | aaa | (Delete) | | | aaa | (Delete) | | * | | +--------------------------+ | | +--------------------------+ | | * | | | | | | * | | Disallowed Features : | | Restricted Operations : | | * | | +--------------------------+ | | +--------------------------+ | | * | | | xyz | (Add...) | | | xyz | (Add...) | | * | | | abcde | | | | abcde | | | * | | | aaa | (Delete) | | | aaa | (Delete) | | * | | +--------------------------+ | | +--------------------------+ | | * | +---------------------------------------+ +----------------------------------------+ | * | .---------------------------------------. .----------------------------------------. | * | |V Authentication ID rewrite rules | |V Authorisation Regexp | | * | +---------------------------------------+ +----------------------------------------+ | * | | +--------------------------+ | | +--------------------------+ | | * | | | xyz | (Add...) | | | xyz | (Add...) | | * | | | abcde | (Edit) | | | abcde | (Edit...) | | * | | | aaa | (Delete) | | | aaa | (Delete) | | * | | | | -------- | | | | --------- | | * | | | | (Up...) | | | | (Up...) | | * | | +--------------------------+ (Down) | | +--------------------------+ (Down...) | | * | +---------------------------------------+ +----------------------------------------+ | * | .----------------------------------------------------------------------------------. | * | |V Miscellaneous options | | * | +----------------------------------------------------------------------------------+ | * | | Args File : [///////////////////////] Plugin Log File : [//////////////////] | | * | | | | * | | Referral : [///////////////////////] Authz Policy : [------------------] | | * | | | | * | | Root DSE : Other : | | * | | +--------------------------+ .------------------------------------. | | * | | | xyz | (Add...) | [X] Read Only | | | * | | | abcde | (Edit) | [X] GentleHUP | | | * | | | aaa | (Delete) | [X] Reverse Lookup | | | * | | +--------------------------+ '------------------------------------' | | * | +----------------------------------------------------------------------------------+ | * +--------------------------------------------------------------------------------------+ * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OptionsPage extends OpenLDAPServerConfigurationEditorPage { /** The Page ID*/ public static final String ID = OptionsPage.class.getName(); //$NON-NLS-1$ /** The Page Title */ private static final String TITLE = Messages.getString( "OpenLDAPOptionsPage.Title" ); // UI Controls // Operations and features /** The olcAllows parameter */ private TableWidget<AllowFeatureEnum> allowFeatureTableWidget; /** The olcDisallows parameter */ private TableWidget<DisallowFeatureEnum> disallowFeatureTableWidget; /** The olcRequires parameter */ private TableWidget<RequireConditionEnum> requireConditionTableWidget; /** The olcRestrict parameter */ private TableWidget<RestrictOperationEnum> restrictOperationTableWidget; // The Authz regexp and rewrite rules /** The olcAuthIDRewrite parameter */ private TableWidget<OrderedStringValueWrapper> authIdRewriteTableWidget; /** The olcAuthzRegexp parameter */ private TableWidget<OrderedStringValueWrapper> authzRegexpTableWidget; // The miscellaneous parameters /** The olcArgsFile parameter */ private Text argsFileText; /** The olcPluginLogFile parameter */ private Text pluginLogFileText; /** The olcReferral parameter */ private Text referralText; /** The olcRootDSE parameter */ private TableWidget<StringValueWrapper> rootDseTableWidget; /** The olcAuthzPolicy parameter */ private Combo authzPolicyCombo; /** The olcGentleHUP parameter */ private Button gentleHupCheckbox; /** The olcReadOnly parameter */ private Button readOnlyCheckbox; /** The olcReverseLookup parameter */ private Button reverseLookupCheckbox; /** * The olcAllows listener */ private WidgetModifyListener allowFeatureListener = event -> { List<String> allowFeatures = new ArrayList<>(); for ( AllowFeatureEnum allowFeature : allowFeatureTableWidget.getElements() ) { allowFeatures.add( allowFeature.getName() ); } getConfiguration().getGlobal().setOlcAllows( allowFeatures ); }; /** * The olcDisallows listener */ private WidgetModifyListener disallowFeatureListener = event -> { List<String> disallowFeatures = new ArrayList<>(); for ( DisallowFeatureEnum disallowFeature : disallowFeatureTableWidget.getElements() ) { disallowFeatures.add( disallowFeature.getName() ); } getConfiguration().getGlobal().setOlcDisallows( disallowFeatures ); }; /** * The olcRequires listener */ private WidgetModifyListener requireConditionListener = event -> { List<String> requires = new ArrayList<>(); for ( RequireConditionEnum requireCondition : requireConditionTableWidget.getElements() ) { requires.add( requireCondition.getName() ); } getConfiguration().getGlobal().setOlcRequires( requires ); }; /** * The olcRestrict listener */ private WidgetModifyListener restrictOperationListener = event -> { List<String> restricts = new ArrayList<>(); for ( RestrictOperationEnum restrictOperation : restrictOperationTableWidget.getElements() ) { restricts.add( restrictOperation.getName() ); } getConfiguration().getGlobal().setOlcRestrict( restricts ); }; /** * The olcAuthIdRewrite listener */ private WidgetModifyListener authIdRewriteListener = event -> { List<String> authIdRewrites = new ArrayList<>(); for ( OrderedStringValueWrapper authIdRewrite : authIdRewriteTableWidget.getElements() ) { authIdRewrites.add( authIdRewrite.toString() ); } getConfiguration().getGlobal().setOlcAuthIDRewrite( authIdRewrites ); }; /** * The olcAuthzRegexp listener */ private WidgetModifyListener authzRegexpListener = event -> { List<String> authzRegexps = new ArrayList<>(); for ( OrderedStringValueWrapper authzRegexp : authzRegexpTableWidget.getElements() ) { authzRegexps.add( authzRegexp.toString() ); } getConfiguration().getGlobal().setOlcAuthzRegexp( authzRegexps ); }; /** * The olcArgsFile listener */ private ModifyListener argsFileTextListener = event -> getConfiguration().getGlobal().setOlcArgsFile( argsFileText.getText() ); /** * The olcPluginFileLog listener */ private ModifyListener pluginLogFileTextListener = event -> getConfiguration().getGlobal().setOlcPluginLogFile( pluginLogFileText.getText() ); /** * The olcReferral listener */ private ModifyListener referralTextListener = event -> getConfiguration().getGlobal().setOlcReferral( referralText.getText() ); /** * The olcRootDSE listener */ private WidgetModifyListener rootDseTableListener = event -> { List<String> rootDses = new ArrayList<>(); for ( StringValueWrapper rootDse : rootDseTableWidget.getElements() ) { rootDses.add( rootDse.getValue() ); } getConfiguration().getGlobal().setOlcRootDSE( rootDses ); }; /** * The olcAuthzPolicy listener */ private SelectionListener authzPolicyComboListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcAuthzPolicy( authzPolicyCombo.getText() ); } }; /** * The olcGentleHup listener */ private SelectionListener gentleHupCheckboxSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcGentleHUP( gentleHupCheckbox.getSelection() ); } }; /** * The olcReadOnly listener */ private SelectionListener readOnlyCheckboxSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcReadOnly( readOnlyCheckbox.getSelection() ); } }; /** * The olcReverseLookup listener */ private SelectionListener reverseLookupCheckboxSelectionListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e ) { getConfiguration().getGlobal().setOlcReverseLookup( reverseLookupCheckbox.getSelection() ); } }; /** * Creates a new instance of OptionsPage. * * @param editor the associated editor */ public OptionsPage( OpenLdapServerConfigurationEditor editor ) { super( editor, ID, TITLE ); } /** * {@inheritDoc} * Creates the OpenLDAP options config Tab. It contains 5 sections, in " * columns and 2 rows * * <pre> * +--------------+---------------+ * | | | * | Features | Operations | * | | | * +--------------+---------------+ * | | | * | rewrite | regexp | * | | | * +--------------+---------------+ * | | * | Miscellaneous | * | | * +------------------------------+ */ protected void createFormContent( Composite parent, FormToolkit toolkit ) { TableWrapLayout twl = new TableWrapLayout(); twl.numColumns = 2; parent.setLayout( twl ); // The upper left part Composite uperLeftComposite = toolkit.createComposite( parent ); uperLeftComposite.setLayout( new GridLayout() ); TableWrapData upperLeftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); upperLeftCompositeTableWrapData.grabHorizontal = true; uperLeftComposite.setLayoutData( upperLeftCompositeTableWrapData ); // The upper right part Composite upperRightComposite = toolkit.createComposite( parent ); upperRightComposite.setLayout( new GridLayout() ); TableWrapData upperRightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); upperRightCompositeTableWrapData.grabHorizontal = true; upperRightComposite.setLayoutData( upperRightCompositeTableWrapData ); // The middle left part Composite middleLeftComposite = toolkit.createComposite( parent ); middleLeftComposite.setLayout( new GridLayout() ); TableWrapData middleLeftCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); middleLeftCompositeTableWrapData.grabHorizontal = true; middleLeftComposite.setLayoutData( middleLeftCompositeTableWrapData ); // The middle right part Composite middleRightComposite = toolkit.createComposite( parent ); middleRightComposite.setLayout( new GridLayout() ); TableWrapData middleRightCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 1 ); middleRightCompositeTableWrapData.grabHorizontal = true; middleRightComposite.setLayoutData( middleRightCompositeTableWrapData ); // The lower part Composite lowerComposite = toolkit.createComposite( parent ); lowerComposite.setLayout( new GridLayout() ); TableWrapData lowerCompositeTableWrapData = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP, 1, 2 ); lowerCompositeTableWrapData.grabHorizontal = true; lowerComposite.setLayoutData( lowerCompositeTableWrapData ); createFeaturesSection( toolkit, middleLeftComposite ); createOperationsSection( toolkit, middleRightComposite ); createAuthIdRewriteSection( toolkit, middleLeftComposite ); createAuthzRegexpsSection( toolkit, middleRightComposite ); createMiscellaneousSection( toolkit, lowerComposite ); } /** * Creates the Features section. * *<pre> * .---------------------------------------. * |V Features | * +---------------------------------------+ * | | * | Allowed Features : | * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | | * | | aaa | (Delete) | * | +--------------------------+ | * | | * | Disallowed Features : | * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | | * | | aaa | (Delete) | * | +--------------------------+ | * +---------------------------------------+ *</pre> * @param toolkit the toolkit * @param parent the parent composite */ private void createFeaturesSection( FormToolkit toolkit, Composite parent ) { // The Features section, which can be expanded or compacted Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOptionsPage.FeaturesSection" ) ); Composite composite = createSectionComposite( toolkit, section, 2, false ); // The olcAllows parameter label Label allowFeatureLabel = toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.AllowFeature" ) ); //$NON-NLS-1$ allowFeatureLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 2, 1 ) ); // The olcAllows parameter table allowFeatureTableWidget = new TableWidget<>( new AllowFeatureDecorator( composite.getShell() ) ); allowFeatureTableWidget.createWidgetNoEdit( composite, toolkit ); allowFeatureTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( allowFeatureTableWidget, allowFeatureListener ); // The olcDisallows parameter label Label disallowFeatureLabel = toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.DisallowFeature" ) ); //$NON-NLS-1$ disallowFeatureLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 2, 1 ) ); // The olcDisallows parameter table disallowFeatureTableWidget = new TableWidget<>( new DisallowFeatureDecorator( composite.getShell() ) ); disallowFeatureTableWidget.createWidgetNoEdit( composite, toolkit ); disallowFeatureTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( disallowFeatureTableWidget, disallowFeatureListener ); } /** * Creates the Operations section. * <pre> * .----------------------------------------. * |V Operations | * +----------------------------------------+ * | | * | Required Conditions : | * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | | * | | aaa | (Delete) | * | +--------------------------+ | * | | * | Restricted Operations : | * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | | * | | aaa | (Delete) | * | +--------------------------+ | * +----------------------------------------+ * </pre> * @param toolkit the toolkit * @param parent the parent composite */ private void createOperationsSection( FormToolkit toolkit, Composite parent ) { // The Operations section, which can be expanded or compacted Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOptionsPage.OperationsSection" ) ); Composite composite = createSectionComposite( toolkit, section, 2, false ); // The olcRequires parameter label Label requireConditionLabel = toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.RequireCondition" ) ); //$NON-NLS-1$ requireConditionLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 2, 1 ) ); // The olcRequires parameter table requireConditionTableWidget = new TableWidget<>( new RequireConditionDecorator( composite.getShell() ) ); requireConditionTableWidget.createWidgetNoEdit( composite, toolkit ); requireConditionTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( requireConditionTableWidget, requireConditionListener ); // The olcRestrict parameter label Label restrictOperationLabel = toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.RestrictOperation" ) ); //$NON-NLS-1$ restrictOperationLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 2, 1 ) ); // The olcRestrict parameter table restrictOperationTableWidget = new TableWidget<>( new RestrictOperationDecorator( composite.getShell() ) ); restrictOperationTableWidget.createWidgetNoEdit( composite, toolkit ); restrictOperationTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( restrictOperationTableWidget, restrictOperationListener ); } /** * Creates the Authentication ID Rewrite Rules section. * <pre> * .----------------------------------------. * |V Authentication ID rewrite rules | * +----------------------------------------+ * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | (Edit...) | * | | aaa | (Delete) | * | | | --------- | * | | | (Up...) | * | +--------------------------+ (Down...) | * +----------------------------------------+ * </pre> * @param toolkit the toolkit * @param parent the parent composite */ private void createAuthIdRewriteSection( FormToolkit toolkit, Composite parent ) { Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOptionsPage.AuthIdRewrite" ) ); Composite composite = createSectionComposite( toolkit, section, 2, false ); // The olcAuthIdRewrite parameter table authIdRewriteTableWidget = new TableWidget<>( new OrderedStringValueDecorator( composite.getShell() , "authIdRewrite") ); authIdRewriteTableWidget.createOrderedWidgetWithEdit( composite, toolkit ); authIdRewriteTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( authIdRewriteTableWidget, authIdRewriteListener ); } /** * Creates the Authz Regexp section. * <pre> * .----------------------------------------. * |V Authorization Regexps | * +----------------------------------------+ * | +--------------------------+ | * | | xyz | (Add...) | * | | abcde | (Edit...) | * | | aaa | (Delete) | * | | | --------- | * | | | (Up...) | * | +--------------------------+ (Down...) | * +----------------------------------------+ * </pre> * @param toolkit the toolkit * @param parent the parent composite */ private void createAuthzRegexpsSection( FormToolkit toolkit, Composite parent ) { Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOptionsPage.AuthzRegexp" ) ); Composite composite = createSectionComposite( toolkit, section, 2, false ); // The olcAuthzRegexp parameter table authzRegexpTableWidget = new TableWidget<>( new OrderedStringValueDecorator( composite.getShell(), "AuthzRegexp" ) ); authzRegexpTableWidget.createOrderedWidgetWithEdit( composite, toolkit ); authzRegexpTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( authzRegexpTableWidget, authzRegexpListener ); } /** * Creates the miscellaneous section. * <pre> * .----------------------------------------------------------------------------------. * |V Miscellaneous options | * +----------------------------------------------------------------------------------+ * | Args File : [///////////////////////] Plugin Log File : [//////////////////] | * | | * | Referral : [///////////////////////] Authz Policy : [------------------] | * | | * | Root DSE : Other : | * | +--------------------------+ .------------------------------------. | * | | xyz | (Add...) | [X] Read Only | | * | | abcde | (Edit) | [X] GentleHUP | | * | | aaa | (Delete) | [X] Reverse Lookup | | * | +--------------------------+ '------------------------------------' | * +----------------------------------------------------------------------------------+ * </pre> * @param toolkit the toolkit * @param parent the parent composite */ private void createMiscellaneousSection( FormToolkit toolkit, Composite parent ) { Section section = createSection( toolkit, parent, Messages.getString( "OpenLDAPOptionsPage.Miscellaneous" ) ); Composite composite = createSectionComposite( toolkit, section, 5, false ); // The olcArgFile parameter. argsFileText = CommonUIUtils.createText( toolkit, composite, Messages.getString( "OpenLDAPOptionsPage.ArgsFile" ), "", -1, argsFileTextListener ); toolkit.createLabel( composite, "" ); // The olcPluginLogFile parameter. pluginLogFileText = CommonUIUtils.createText( toolkit, composite, Messages.getString( "OpenLDAPOptionsPage.PluginLogFile" ), "", -1, pluginLogFileTextListener ); // The olcReferral parameter. referralText = CommonUIUtils.createText( toolkit, composite, Messages.getString( "OpenLDAPOptionsPage.Referral" ), "", -1, referralTextListener ); toolkit.createLabel( composite, "" ); // The authzPolicy parameter toolkit.createLabel( composite, Messages.getString( "OpenLDAPSecurityPage.AuthzPolicy" ) ); //$NON-NLS-1$ authzPolicyCombo = BaseWidgetUtils.createCombo( composite, AuthzPolicyEnum.getNames(), -1, 1 ); authzPolicyCombo.addSelectionListener( authzPolicyComboListener ); // The olcRootDSE label. toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.RootDSEs" ) ); toolkit.createLabel( composite, "" ); toolkit.createLabel( composite, "" ); // The olcOther label. toolkit.createLabel( composite, Messages.getString( "OpenLDAPOptionsPage.Others" ) ); toolkit.createLabel( composite, "" ); // The olcRootDSE parameter. rootDseTableWidget = new TableWidget<>( new StringValueDecorator( composite.getShell(), Messages.getString( "OpenLDAPOptionsPage.RootDSE" ) ) ); rootDseTableWidget.createWidgetWithEdit( composite, toolkit ); rootDseTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); addModifyListener( rootDseTableWidget, rootDseTableListener ); toolkit.createLabel( composite, "" ); // A group for the others checkboxes Group othersGroup = BaseWidgetUtils.createGroup( composite, null, 2 ); GridLayout othersGroupGridLayout = new GridLayout( 3, false ); othersGroup.setLayout( othersGroupGridLayout ); othersGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); // The olcGentleHUP Button gentleHupCheckbox = BaseWidgetUtils.createCheckbox( othersGroup, Messages.getString( "OpenLDAPOptionsPage.GentleHUP" ), 1 ); gentleHupCheckbox.addSelectionListener( gentleHupCheckboxSelectionListener ); // The olcReadOnly Button readOnlyCheckbox = BaseWidgetUtils.createCheckbox( othersGroup,
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; /** * This class implements a Module wrapper used in the 'Overlays' page UI. A Module * has a name, a path and an order. We also have an additional index, which is * the ModuleList index (this is necessary as two modules might have the same name * but for a different path). * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModuleWrapper { /** The moduleList's name */ private String moduleListName; /** The wrapped moduleList index : we may have more than one moduleList */ private int moduleListIndex; /** The wrapped Module name */ private String moduleName; /** The wrapped module path */ private String path; /** The wrapped module order : we may have many modules for a given path*/ private int order; /** * Creates a new instance of ModuleWrapper. */ public ModuleWrapper() { } /** * Creates a new instance of ModuleWrapper. * * @param moduleListName The ModuleList's name * @param moduleListIndex the module's index * @param module the wrapped module * @param path the module's path * @param order the module's order */ public ModuleWrapper( String moduleListName, int moduleListIndex, String module, String path, int order ) { this.moduleListName = moduleListName; this.moduleName = module; this.path = path; this.moduleListIndex = moduleListIndex; this.order = order; } /** * @return the moduleListName */ public String getModuleListName() { return moduleListName; } /** * Gets the moduleList's index * * @return the moduleList's index */ public int getModuleListIndex() { return moduleListIndex; } /** * Gets the wrapped module's name * * @return the wrapped module's name */ public String getModuleName() { return moduleName; } /** * Gets the wrapped path * * @return the wrapped path */ public String getPath() { return path; } /** * Gets the wrapped order * * @return the wrapped order */ public int getOrder() { return order; } /** * Sets the wrapped module's name. * * @param moduleName the wrapped module's name */ public void setModuleName( String moduleName ) { this.moduleName = moduleName; } /** * Sets the moduleList's index. * * @param moduleListIndex the moduleList's index */ public void setModuleIndex( int moduleListIndex ) { this.moduleListIndex = moduleListIndex; } /** * Sets the wrapped path. * * @param path the wrapped path */ public void setPath( String path ) { this.path = path; } /** * @param moduleListName the moduleListName to set */ public void setModuleListName( String moduleListName ) { this.moduleListName = moduleListName; } /** * Sets the wrapped order. * * @param moduleListIndex the wrapped order */ public void setOrder( int order ) { this.order = order; } public String getModulePathName() { StringBuilder sb = new StringBuilder(); if ( path != null ) { sb.append( path ).append( "/" ); } sb.append( "{" ).append( order ).append( '}' ).append( moduleName ); return sb.toString(); } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append( moduleListName ).append( '{').append( moduleListIndex ).append( '}' ); sb.append( ':' ); if ( path != null ) { sb.append( path ).append( "/" ); } sb.append( "{" ).append( order ).append( '}' ).append( moduleName ); return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/PasswordPolicyOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/PasswordPolicyOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the Password Policy Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class PasswordPolicyOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public PasswordPolicyOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Database General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "ID:" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/DistProcOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/DistProcOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the Dist Proc Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DistProcOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public DistProcOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Database General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "ID:" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/AccessLogOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/AccessLogOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; 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.Spinner; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the Access Log Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AccessLogOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private Text databaseDnText; private Text filterText; private Text attributesText; private Button onlyLogSuccessOperationsCheckbox; private Button logAllOperationsRadioButton; private Button logSpecificOperationsRadioButton; private Button logWriteOperationsCheckbox; private Button logReadOperationsCheckbox; private Button logSessionOperationsCheckbox; private Button logAddOperationCheckbox; private Button logDeleteOperationCheckbox; private Button logModifyOperationCheckbox; private Button logModifyRdnOperationCheckbox; private Button logCompareOperationCheckbox; private Button logSearchOperationCheckbox; private Button logAbandonOperationCheckbox; private Button logBindOperationCheckbox; private Button logUnbindOperationCheckbox; private Spinner purgeAgeDaysSpinner; private Spinner purgeAgeHoursSpinner; private Spinner purgeAgeMinutesSpinner; private Spinner purgeAgeSecondsSpinner; private Spinner purgeIntervalDaysSpinner; private Spinner purgeIntervalHoursSpinner; private Spinner purgeIntervalMinutesSpinner; private Spinner purgeIntervalSecondsSpinner; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public AccessLogOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { FormToolkit toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); createLogOperationsSettingsSection( parent, toolkit ); createPurgeSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Audit Log General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // Database DN Text toolkit.createLabel( composite, "Database DN:" ); databaseDnText = toolkit.createText( composite, "" ); databaseDnText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Database DN Text toolkit.createLabel( composite, "Filter:" ); filterText = toolkit.createText( composite, "" ); filterText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Database DN Text toolkit.createLabel( composite, "Attributes:" ); attributesText = toolkit.createText( composite, "" ); attributesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Only Log Success Operations onlyLogSuccessOperationsCheckbox = toolkit.createButton( composite, "Only log success operations", SWT.CHECK ); onlyLogSuccessOperationsCheckbox.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) ); } /** * Creates the Log Operations Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createLogOperationsSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Log Operations Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout(); composite.setLayout( glayout ); section.setClient( composite ); // Log All Operations Radio Button logAllOperationsRadioButton = toolkit.createButton( composite, "All Operations", SWT.RADIO ); // Log Specific Operations Radio Button logSpecificOperationsRadioButton = toolkit.createButton( composite, "The following operations:", SWT.RADIO ); // Specific Operations Composite Composite specificOperationsComposite = toolkit.createComposite( composite ); GridLayout gl = new GridLayout( 3, true ); gl.marginHeight = gl.marginWidth = 0; gl.marginLeft = 20; specificOperationsComposite.setLayout( gl ); specificOperationsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Log Write Operations Checkbox logWriteOperationsCheckbox = toolkit.createButton( specificOperationsComposite, "Write Operations", SWT.CHECK ); // Log Reads Operations Checkbox logReadOperationsCheckbox = toolkit.createButton( specificOperationsComposite, "Read Operations", SWT.CHECK ); // Log Session Operations Checkbox logSessionOperationsCheckbox = toolkit.createButton( specificOperationsComposite, "Session Operations", SWT.CHECK ); // Write Operations Composite Composite writeOperationsComposite = toolkit.createComposite( specificOperationsComposite ); gl = new GridLayout(); gl.marginHeight = gl.marginWidth = 0; gl.marginLeft = 20; writeOperationsComposite.setLayout( gl ); writeOperationsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Log Add Operation Checkbox logAddOperationCheckbox = toolkit.createButton( writeOperationsComposite, "Add Operation", SWT.CHECK ); // Log Delete Operation Checkbox logDeleteOperationCheckbox = toolkit.createButton( writeOperationsComposite, "Delete Operation", SWT.CHECK ); // Log Modify Operation Checkbox logModifyOperationCheckbox = toolkit.createButton( writeOperationsComposite, "Modify Operation", SWT.CHECK ); // Log Modify RDN Operation Checkbox logModifyRdnOperationCheckbox = toolkit.createButton( writeOperationsComposite, "Modify RDN Operation", SWT.CHECK ); // Read Operations Composite Composite readOperationsComposite = toolkit.createComposite( specificOperationsComposite ); gl = new GridLayout(); gl.marginHeight = gl.marginWidth = 0; gl.marginLeft = 20; readOperationsComposite.setLayout( gl ); readOperationsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Log Compare Operation Checkbox logCompareOperationCheckbox = toolkit.createButton( readOperationsComposite, "Compare Operation", SWT.CHECK ); // Log Search Operation Checkbox logSearchOperationCheckbox = toolkit.createButton( readOperationsComposite, "Search Operation", SWT.CHECK ); // Session Operations Composite Composite sessionOperationsComposite = toolkit.createComposite( specificOperationsComposite ); gl = new GridLayout(); gl.marginHeight = gl.marginWidth = 0; gl.marginLeft = 20; sessionOperationsComposite.setLayout( gl ); sessionOperationsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Log Abandon Operation Checkbox logAbandonOperationCheckbox = toolkit.createButton( sessionOperationsComposite, "Abandon Operation", SWT.CHECK ); // Log Bind Operation Checkbox logBindOperationCheckbox = toolkit.createButton( sessionOperationsComposite, "Bind Operation", SWT.CHECK ); // Log Unbind Operation Checkbox logUnbindOperationCheckbox = toolkit.createButton( sessionOperationsComposite, "Unbind Operation", SWT.CHECK ); } /** * Creates the Purge Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createPurgeSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Purge Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 9, false ); composite.setLayout( glayout ); section.setClient( composite ); // Purge Age toolkit.createLabel( composite, "Purge Age:" ); purgeAgeDaysSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Days" ); purgeAgeHoursSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Hours" ); purgeAgeMinutesSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Minutes" ); purgeAgeSecondsSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Seconds" ); // Purge Interval toolkit.createLabel( composite, "Purge Interval:" ); purgeIntervalDaysSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Days" ); purgeIntervalHoursSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Hours" ); purgeIntervalMinutesSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Minutes" ); purgeIntervalSecondsSpinner = new Spinner( composite, SWT.BORDER ); toolkit.createLabel( composite, "Seconds" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/PBindAccessOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/PBindAccessOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the PBind Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class PBindAccessOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public PBindAccessOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent the parent composite * @param toolkit the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Database General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "ID:" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ChainOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ChainOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the Chain Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ChainOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public ChainOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Database General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "ID:" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; /** * This class defines a label provider for a module wrapper viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModuleWrapperLabelProvider extends LabelProvider { /** * Construct the label for a ModuleList. It's the type, followed by the suffixDN. */ @Override public String getText( Object element ) { if ( element instanceof ModuleWrapper ) { return ( ( ModuleWrapper ) element ).getModulePathName(); } return super.getText( element ); } /** * Get the ModuleList image, if it's a ModuleList */ @Override public Image getImage( Object element ) { if ( element instanceof ModuleWrapper ) { return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_DATABASE ); } return super.getImage( element ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/OverlaysMasterDetailsBlock.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/OverlaysMasterDetailsBlock.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import java.util.ArrayList; import java.util.List; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Table; import org.eclipse.ui.forms.DetailsPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.MasterDetailsBlock; import org.eclipse.ui.forms.SectionPart; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.apache.directory.studio.openldap.config.editor.pages.OverlaysPage; import org.apache.directory.studio.openldap.config.model.OlcChainConfig; import org.apache.directory.studio.openldap.config.model.OlcConfig; import org.apache.directory.studio.openldap.config.model.OlcDistProcConfig; import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig; import org.apache.directory.studio.openldap.config.model.OlcPBindConfig; import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; import org.apache.directory.studio.openldap.config.model.overlay.OlcAuditlogConfig; import org.apache.directory.studio.openldap.config.model.overlay.OlcSyncProvConfig; /** * This class represents the Overlays Master/Details Block used in the Overlays Page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OverlaysMasterDetailsBlock extends MasterDetailsBlock { /** The associated page */ private OverlaysPage page; // UI Fields private TableViewer overlaysTableViewer; private Button addButton; private Button deleteButton; /** * Creates a new instance of OverlaysMasterDetailsBlock. * * @param page the associated page */ public OverlaysMasterDetailsBlock( OverlaysPage page ) { super(); this.page = page; } /** * {@inheritDoc} */ @Override public void createContent( IManagedForm managedForm ) { super.createContent( managedForm ); // Giving the weights of both parts of the SashForm. sashForm.setWeights( new int[] { 1, 2 } ); } /** * {@inheritDoc} */ protected void createMasterPart( final IManagedForm managedForm, Composite parent ) { FormToolkit toolkit = managedForm.getToolkit(); // Creating the Section Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.setText( "All Overlays" ); section.marginWidth = 10; section.marginHeight = 5; Composite client = toolkit.createComposite( section, SWT.WRAP ); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.makeColumnsEqualWidth = false; layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout( layout ); toolkit.paintBordersFor( client ); section.setClient( client ); // Creating the Table and Table Viewer Table overlaysTable = toolkit.createTable( client, SWT.NULL ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 ); gd.heightHint = 20; gd.widthHint = 100; overlaysTable.setLayoutData( gd ); final SectionPart sectionPart = new SectionPart( section ); managedForm.addPart( sectionPart ); overlaysTableViewer = new TableViewer( overlaysTable ); overlaysTableViewer.addSelectionChangedListener( event -> managedForm.fireSelectionChanged( sectionPart, event.getSelection() ) ); overlaysTableViewer.setContentProvider( new ArrayContentProvider() ); overlaysTableViewer.setLabelProvider( new LabelProvider() { @Override public String getText( Object element ) { if ( element instanceof OlcOverlayConfig ) { OlcOverlayConfig overlay = ( OlcOverlayConfig ) element; return overlay.getOlcOverlay(); } return super.getText( element ); } @Override public Image getImage( Object element ) { if ( element instanceof OlcOverlayConfig ) { return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_OVERLAY ); } return super.getImage( element ); } } ); // Creating the button(s) addButton = toolkit.createButton( client, "Add", SWT.PUSH ); addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH ); deleteButton.setEnabled( false ); deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); initFromInput(); } /** * Initializes the page with the Editor input. */ private void initFromInput() { OpenLdapConfiguration configuration = page.getConfiguration(); List<OlcConfig> configurationElements = configuration.getConfigurationElements(); List<OlcOverlayConfig> overlayConfigurationElements = new ArrayList<>(); for ( OlcConfig configurationElement : configurationElements ) { if ( configurationElement instanceof OlcOverlayConfig ) { overlayConfigurationElements.add( ( OlcOverlayConfig ) configurationElement ); } } overlaysTableViewer.setInput( overlayConfigurationElements.toArray( new OlcOverlayConfig[0] ) ); } /** * {@inheritDoc} */ protected void registerPages( DetailsPart detailsPart ) { AccessLogOverlayDetailsPage olcAccessLogOverlayDetailsPage = new AccessLogOverlayDetailsPage( this ); detailsPart.registerPage( OlcAccessLogConfig.class, olcAccessLogOverlayDetailsPage ); AuditLogOverlayDetailsPage olcAuditLogOverlayDetailsPage = new AuditLogOverlayDetailsPage( this ); detailsPart.registerPage( OlcAuditlogConfig.class, olcAuditLogOverlayDetailsPage ); ChainOverlayDetailsPage olcChainOverlayDetailsPage = new ChainOverlayDetailsPage( this ); detailsPart.registerPage( OlcChainConfig.class, olcChainOverlayDetailsPage ); DistProcOverlayDetailsPage oldDistProcOverlayDetailsPage = new DistProcOverlayDetailsPage( this ); detailsPart.registerPage( OlcDistProcConfig.class, oldDistProcOverlayDetailsPage ); PasswordPolicyOverlayDetailsPage olcPasswordPolicyOverlayDetailsPage = new PasswordPolicyOverlayDetailsPage( this ); detailsPart.registerPage( OlcDistProcConfig.class, olcPasswordPolicyOverlayDetailsPage ); PBindAccessOverlayDetailsPage olcPBindAccessOverlayDetailsPage = new PBindAccessOverlayDetailsPage( this ); detailsPart.registerPage( OlcPBindConfig.class, olcPBindAccessOverlayDetailsPage ); SyncProvOverlayDetailsPage olcSyncProvOverlayDetailsPage = new SyncProvOverlayDetailsPage( this ); detailsPart.registerPage( OlcSyncProvConfig.class, olcSyncProvOverlayDetailsPage ); } /** * {@inheritDoc} */ protected void createToolBarActions( IManagedForm managedForm ) { // No toolbar actions } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/AuditLogOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/AuditLogOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the Audit Log Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AuditLogOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; private Text fileText; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public AuditLogOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Audit Log General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "File:" ); fileText = toolkit.createText( composite, "" ); fileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; /** * This class defines a sorter for a ModuleList wrapper viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModuleWrapperViewerSorter extends ViewerComparator { @Override public int compare( Viewer viewer, Object e1, Object e2 ) { if ( ( e1 instanceof ModuleWrapper ) && ( e2 instanceof ModuleWrapper ) ) { ModuleWrapper module1 = (ModuleWrapper)e1; ModuleWrapper module2 = (ModuleWrapper)e2; if ( e1 == e2 ) { // Short circuit... return 0; } // First, compare the moduleList int comp = module1.getModuleListName().compareToIgnoreCase( module2.getModuleListName() ); if ( comp == 0 ) { // Same ModuleList. Check the index if ( module1.getModuleListIndex() == module2.getModuleListIndex() ) { // Same index : check the modules' order if ( module1.getOrder() > module2.getOrder() ) { return 1; } else { return -1; } } else { // We can get out if ( module1.getModuleListIndex() > module2.getModuleListIndex() ) { return 1; } else { return -1; } } } else { // The are different, we can get out return comp; } } return super.compare( viewer, e1, e2 ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/SyncProvOverlayDetailsPage.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/SyncProvOverlayDetailsPage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.overlays; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IDetailsPage; import org.eclipse.ui.forms.IFormPart; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.apache.directory.studio.openldap.config.model.overlay.OlcAccessLogConfig; /** * This class represents the Details Page of the Server Configuration Editor for the SyncProv Overlay type * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SyncProvOverlayDetailsPage implements IDetailsPage { /** The associated Master Details Block */ private OverlaysMasterDetailsBlock masterDetailsBlock; /** The Managed Form */ private IManagedForm mform; /** The dirty flag */ private boolean dirty = false; /** The overlay */ private OlcAccessLogConfig overlay; // UI fields private FormToolkit toolkit; /** * Creates a new instance of PartitionDetailsPage. * * @param master * the associated Master Details Block */ public SyncProvOverlayDetailsPage( OverlaysMasterDetailsBlock master ) { masterDetailsBlock = master; } /* (non-Javadoc) * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite) */ public void createContents( Composite parent ) { toolkit = mform.getToolkit(); TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5; layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout( layout ); createGeneralSettingsSection( parent, toolkit ); } /** * Creates the General Settings Section * * @param parent * the parent composite * @param toolkit * the toolkit to use */ private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit ) { Section section = toolkit.createSection( parent, Section.TITLE_BAR ); section.marginWidth = 10; section.setText( "Database General Settings" ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); td.grabHorizontal = true; section.setLayoutData( td ); Composite composite = toolkit.createComposite( section ); toolkit.paintBordersFor( composite ); GridLayout glayout = new GridLayout( 2, false ); composite.setLayout( glayout ); section.setClient( composite ); // ID toolkit.createLabel( composite, "ID:" ); } /** * {@inheritDoc} */ public void selectionChanged( IFormPart part, ISelection selection ) { IStructuredSelection ssel = ( IStructuredSelection ) selection; if ( ssel.size() == 1 ) { overlay = ( OlcAccessLogConfig ) ssel.getFirstElement(); } else { overlay = null; } refresh(); } /** * {@inheritDoc} */ public void commit( boolean onSave ) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void initialize( IManagedForm form ) { this.mform = form; } /** * {@inheritDoc} */ public boolean isDirty() { return dirty; } /** * {@inheritDoc} */ public boolean isStale() { return false; } /** * {@inheritDoc} */ public void setFocus() { // idText.setFocus(); // TODO } /** * {@inheritDoc} */ public boolean setFormInput( Object input ) { return false; } /** * {@inheritDoc} */ public void refresh() { if ( overlay == null ) { // Blank out all fields // TODO } else { } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.config.editor.dialogs.SsfDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the SsfWrapper table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SsfDecorator extends TableDecorator<SsfWrapper> { /** * Create a new instance of SsfDecorator * @param parentShell The parent Shell */ public SsfDecorator( Shell parentShell ) { setDialog( new SsfDialog( parentShell ) ); } /** * Construct the label for a SSF. It can be one of : * */ @Override public String getText( Object element ) { if ( element instanceof SsfWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( SsfWrapper e1, SsfWrapper e2 ) { if ( e1 != null ) { return e1.compareTo( e2 ); } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.api.util.Strings; /** * This class wraps the SizeLimit parameter : * <pre> * size ::= 'size' sizeLimit size-e * size-e ::= ' size' sizeLimit size-e | e * sizeLimit ::= '.soft=' limit | '.hard=' hardLimit | '.pr=' prLimit | '.prtotal=' prTLimit * | '.unchecked=' uLimit | '=' limit * limit ::= 'unlimited' | 'none' | INT * hardLimit ::= 'soft' | limit * ulimit ::= 'disabled' | limit * prLimit ::= 'noEstimate' | limit * prTLimit ::= ulimit | 'hard' * </pre> * * Note : each of the limit is an Integer, so that we can have two states : * <ul> * <li>not existent</li> * <li>has a value</li> * </ul> * A -1 value means unlimited. Any other value is accepted, if > 0. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SizeLimitWrapper extends AbstractLimitWrapper { /** The unchecked limit */ private Integer uncheckedLimit; /** The PR limit */ private Integer prLimit; /** The PRTotal limit */ private Integer prTotalLimit; /** The noEstimate flag */ private boolean noEstimate; //Define some of the used constants public static final Integer PR_DISABLED = Integer.valueOf( -2 ); public static final Integer PR_HARD = Integer.valueOf( 0 ); public static final Integer UC_DISABLED = Integer.valueOf( 0 ); public static final String DISABLED_STR = "disabled"; public static final String UNCHECKED_STR = "unchecked"; /** * Create a SizeLimitWrapper instance */ protected SizeLimitWrapper() { super(); } /** * Create a SizeLimitWrapper instance * * @param globalLimit The global limit * @param hardLimit The hard limit * @param softLimit The soft limit * @param uncheckedLimit The unchecked limit * @param prLimit The pr limit * @param prTotalLimit The prTotal limit */ public SizeLimitWrapper( Integer globalLimit, Integer hardLimit, Integer softLimit, Integer uncheckedLimit, Integer prLimit, Integer prTotalLimit, boolean noEstimate ) { super( globalLimit, hardLimit, softLimit ); this.uncheckedLimit = uncheckedLimit; this.prLimit = prLimit; this.prTotalLimit = prTotalLimit; this.noEstimate = noEstimate; } /** * Create a SizeLimitWrapper instance from a String. * * @param sizeLimitStr The String that contain the value */ public SizeLimitWrapper( String sizeLimitStr ) { if ( !Strings.isEmpty( sizeLimitStr ) ) { // use a lowercase version of the string String lowerCaseSizeLimitStr = sizeLimitStr.toLowerCase(); SizeLimitWrapper tmp = new SizeLimitWrapper(); // Split the strings String[] limits = lowerCaseSizeLimitStr.split( " " ); if ( limits != null ) { // Parse each limit for ( String limit : limits ) { tmp.clear(); boolean result = parseLimit( tmp, limit ); if ( !result ) { // No need to continue if the value is wrong clear(); isValid = false; break; } else { if ( tmp.globalLimit != null ) { // replace the existing global limit, nullify the hard and soft limit globalLimit = tmp.globalLimit; hardLimit = null; softLimit = null; } else { // We don't set the soft and hard limit of the global limit is not null if ( globalLimit == null ) { if ( tmp.softLimit != null ) { softLimit = tmp.softLimit; if ( ( hardLimit != null ) && ( hardLimit.equals( HARD_SOFT ) || hardLimit.equals( softLimit ) ) ) { // Special case : we have had a size.hard=soft before, // or the hard and soft limit are equals : we set the global limit globalLimit = softLimit; softLimit = null; hardLimit = null; } } else if ( tmp.hardLimit != null ) { if ( ( tmp.hardLimit.equals( HARD_SOFT ) && ( softLimit != null ) ) || tmp.hardLimit.equals( softLimit ) ) { // special case, softLimit was set and hardLimit was size.hard=soft, // or is equal to softLimit globalLimit = softLimit; softLimit = null; hardLimit = null; } else { hardLimit = tmp.hardLimit; } } } // Deal with the unchecked parameter if ( tmp.uncheckedLimit != null ) { uncheckedLimit = tmp.uncheckedLimit; } // Deal with the PR limit if ( tmp.prLimit != null ) { prLimit = tmp.prLimit; } // Special case for noEstimate noEstimate = tmp.noEstimate; // Last, not least, prTotalLimit if ( tmp.prTotalLimit != null ) { prTotalLimit = tmp.prTotalLimit; } } } } } else { isValid = true; } } else { isValid = true; } } /** * Clear the SizeLimitWrapper (reset all the values to null) */ @Override public void clear() { super.clear(); uncheckedLimit = null; prLimit = null; prTotalLimit = null; noEstimate = false; } /** * Parse a single limit : * <pre> * size ::= 'size' sizeLimit size-e * size-e ::= ' size' sizeLimit size-e | e * sizeLimit ::= '.soft=' limit | '.hard=' hardLimit | '.pr=' prLimit | '.prtotal=' prTLimit * | '.unchecked=' uLimit | '=' limit * limit ::= 'unlimited' | 'none' | INT * ulimit ::= 'disabled' | limit * prLimit ::= 'noEstimate' | limit * prTLimit ::= ulimit | 'hard' * </pre> * @param slw * @param limitStr */ private static boolean parseLimit( SizeLimitWrapper slw, String limitStr ) { int pos = 0; // The sizelimit always starts with a "size" if ( limitStr.startsWith( "size" ) ) { pos += 4; // A global or hard/soft/pr/prtotal ? if ( limitStr.startsWith( "=", pos ) ) { // Global : get the limit pos++; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.globalLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.globalLimit = UNLIMITED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { pos += integer.length(); try { Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { slw.globalLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".hard=", pos ) ) { // Hard limit : get the hard limit pos += 6; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.hardLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.hardLimit = UNLIMITED; } else if ( limitStr.startsWith( SOFT_STR, pos ) ) { pos += 4; slw.globalLimit = HARD_SOFT; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { pos += integer.length(); try { Integer value = Integer.valueOf( integer ); if ( value >= UNLIMITED ) { slw.hardLimit = value; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".soft=", pos ) ) { // Soft limit : get the limit pos += 6; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.softLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.softLimit = UNLIMITED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { try { pos += integer.length(); Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { slw.softLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".unchecked=", pos ) ) { // Unchecked limit : get the limit pos += 11; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.uncheckedLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.uncheckedLimit = UNLIMITED; } else if ( limitStr.startsWith( DISABLED_STR, pos ) ) { pos += 8; slw.uncheckedLimit = UC_DISABLED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { try { pos += integer.length(); Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { slw.uncheckedLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".pr=", pos ) ) { // pr limit : get the limit pos += 4; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.prLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.prLimit = UNLIMITED; } else if ( limitStr.startsWith( "noestimate", pos ) ) { pos += 10; slw.noEstimate = true; } else if ( limitStr.startsWith( DISABLED_STR, pos ) ) { pos += 8; slw.prLimit = PR_DISABLED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { try { pos += integer.length(); Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { slw.prLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".prtotal=", pos ) ) { // prTotal limit : get the limit pos += 9; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; slw.prTotalLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; slw.prTotalLimit = UNLIMITED; } else if ( limitStr.startsWith( DISABLED_STR, pos ) ) { pos += 8; slw.prTotalLimit = PR_DISABLED; } else if ( limitStr.startsWith( HARD_STR, pos ) ) { pos += 4; slw.prTotalLimit = PR_HARD; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { try { pos += integer.length(); Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { slw.prTotalLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else { // This is wrong return false; } } else { // This is wrong return false; } // last check : the pos should be equal to the limitStr length return ( pos == limitStr.length() ); } /** * @return the prLimit */ public Integer getPrLimit() { return prLimit; } /** * @param prLimit the prLimit to set */ public void setPrLimit( Integer prLimit ) { this.prLimit = prLimit; } /** * @return the prTotalLimit */ public Integer getPrTotalLimit() { return prTotalLimit; } /** * @param prTotalLimit the prTotalLimit to set */ public void setPrTotalLimit( Integer prTotalLimit ) { this.prTotalLimit = prTotalLimit; } /** * @return the uncheckedLimit */ public Integer getUncheckedLimit() { return uncheckedLimit; } /** * @param uncheckedLimit the uncheckedLimit to set */ public void setUncheckedLimit( Integer uncheckedLimit ) { this.uncheckedLimit = uncheckedLimit; } /** * @return the noEstimate */ public boolean isNoEstimate() { return noEstimate; } /** * @param noEstimate the noEstimate to set */ public void setNoEstimate( boolean noEstimate ) { this.noEstimate = noEstimate; } /** * @return The Limit's type */ public String getType() { return "size"; } /** * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( super.toString() ); // process the unchecked limit if ( uncheckedLimit != null ) { // Eventually add a space at the end if we have had some size limit if ( sb.length() > 0 ) { sb.append( ' ' ); } sb.append( "size.unchecked=" ); if ( uncheckedLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( uncheckedLimit.equals( UC_DISABLED ) ) { sb.append( DISABLED_STR ); } else { sb.append( uncheckedLimit ); } } // Process the pr limit if ( prLimit != null ) { // Eventually add a space at the end if we have had some size limit if ( sb.length() > 0 ) { sb.append( ' ' ); } sb.append( "size.pr=" ); if ( prLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else { sb.append( prLimit ); } } // Process the prTotal limit if ( prTotalLimit != null ) { // Eventually add a space at the end if we have had some size limit if ( sb.length() > 0 ) { sb.append( ' ' ); } sb.append( "size.prtotal=" ); if ( prTotalLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( prTotalLimit.intValue() == PR_HARD ) { sb.append( HARD_STR ); } else if ( prTotalLimit.intValue() == PR_DISABLED ) { sb.append( DISABLED_STR ); } else { sb.append( prTotalLimit ); } } // Last, not least, the noEstimate flag if ( noEstimate ) { // Eventually add a space at the end if we have had some size limit if ( sb.length() > 0 ) { sb.append( ' ' ); } sb.append( "size.pr=noEstimate" ); } return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.config.editor.dialogs.TimeLimitDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the TimeLimitWrapper class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class TimeLimitDecorator extends TableDecorator<TimeLimitWrapper> { /** * Create a new instance of TImeLimitDecorator * @param parentShell The parent Shell */ public TimeLimitDecorator( Shell parentShell ) { setDialog( new TimeLimitDialog( parentShell ) ); } /** * Construct the label for a TimeLimit. It can be one of : * */ @Override public String getText( Object element ) { if ( element instanceof TimeLimitWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none (may be we could add one for URLs ?) */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( TimeLimitWrapper e1, TimeLimitWrapper e2 ) { if ( e1 != null ) { return e1.compareTo( e2 ); } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.openldap.common.ui.model.SsfFeatureEnum; /** * This class wraps the olcSecurity parameter : * <pre> * olcSecurity ::= (<feature>=<size>)* * <feature> ::= 'ssf' | 'transport' | 'tls' | 'sasl' | 'simple_bind' | * 'update_ssf' | 'update_transport' | 'update_tls' | 'update_sasl' * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SsfWrapper implements Cloneable, Comparable<SsfWrapper> { /** The feature */ private SsfFeatureEnum feature; /** The number of bits for this feature */ private int nbBits = 0; /** * Creates an instance using a name of a feature and its size * * @param feature The feature to use * @param nbBits The number of bits */ public SsfWrapper( String feature, int nbBits ) { this.feature = SsfFeatureEnum.getSsfFeature( feature ); if ( this.feature == SsfFeatureEnum.NONE ) { this.nbBits = 0; } else { this.nbBits = nbBits; } if ( nbBits < 0 ) { this.nbBits = 0; } } /** * Creates an instance using a String representation, which format is * feature = <nbBits> * * @param feature The feature to use */ public SsfWrapper( String feature ) { if ( Strings.isEmpty( feature ) ) { this.feature = SsfFeatureEnum.NONE; this.nbBits = 0; } else { int pos = feature.indexOf( '=' ); if ( pos < 0 ) { this.feature = SsfFeatureEnum.NONE; this.nbBits = 0; } String name = Strings.trim( feature.substring( 0, pos ) ); this.feature = SsfFeatureEnum.getSsfFeature( name ); if ( this.feature == SsfFeatureEnum.NONE ) { this.nbBits = 0; } else { String value = Strings.trim( feature.substring( pos + 1 ) ); try { this.nbBits = Integer.parseInt( value ); } catch ( NumberFormatException nfe ) { this.nbBits = 0; } } } } /** * Tells if this is a valid SSF. The format is : * feature = <nbBits> where nbBits >= 0. * * @return true if valid */ public boolean isValid() { return ( feature != null ) && ( feature != SsfFeatureEnum.NONE ) && ( nbBits >= 0 ); } /** * Tells if the String is a valid SSF. The format is : * feature = <nbBits> * * @param ssf The feature to check * @return true if valid */ public static boolean isValid( String ssf ) { if ( Strings.isEmpty( ssf ) ) { return false; } else { int pos = ssf.indexOf( '=' ); if ( pos < 0 ) { return false; } String name = Strings.trim( ssf.substring( 0, pos ) ); SsfFeatureEnum ssfFeature = SsfFeatureEnum.getSsfFeature( name ); if ( ssfFeature == SsfFeatureEnum.NONE ) { return false; } else { String value = Strings.trim( ssf.substring( pos + 1 ) ); try { return Integer.parseInt( value ) >= 0 ; } catch ( NumberFormatException nfe ) { return false; } } } } /** * @return the feature */ public SsfFeatureEnum getFeature() { return feature; } /** * @param feature the feature to set */ public void setFeature( SsfFeatureEnum feature ) { this.feature = feature; } /** * @return the nbBits */ public int getNbBits() { return nbBits; } /** * @param nbBits the nbBits to set */ public void setNbBits( int nbBits ) { this.nbBits = nbBits; } /** * @see Object#equals() */ public boolean equals( Object that ) { if ( that == this ) { return true; } if ( ! ( that instanceof SsfWrapper ) ) { return false; } // We don't use the nbBits return ( feature == ((SsfWrapper)that).getFeature() ); } /** * @see Object#hashCode() */ public int hashCode() { int h = 37; // We don't use the nbBits h += h*17 + feature.hashCode(); return h; } /** * @see Object#clone() */ public SsfWrapper clone() { try { return (SsfWrapper)super.clone(); } catch ( CloneNotSupportedException cnse ) { return null; } } /** * @see Comparable#compareTo() */ public int compareTo( SsfWrapper that ) { // Compare by feature first then by nbBits if ( that == null ) { return 1; } int comp = feature.getName().compareTo( that.feature.getName() ); if ( comp == 0 ) { return nbBits - that.nbBits; } else { return comp; } } /** * @see Object#toString() */ public String toString() { if ( feature != SsfFeatureEnum.NONE ) { return feature.getName() + '=' + nbBits; } else { return ""; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import org.apache.directory.api.util.Strings; /** * This class wraps the TCPBuffer parameter : * <pre> * [listener=<URL>] [{read|write}=]<size> * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class TcpBufferWrapper implements Cloneable, Comparable<TcpBufferWrapper> { /** The maximum buffer size (2^32-1) */ public static final long MAX_TCP_BUFFER_SIZE = 0xFFFFFFFFL; /** The two kind of TCP buffer we can configure */ public enum TcpTypeEnum { READ( "read" ), WRITE( "write" ), BOTH( "" ); private String value; private TcpTypeEnum( String value ) { this.value = value; } private String getValue() { return value; } } /** The TCP listener (optional) */ private URI listener; /** The type of TCP buffer (either read or write, or both ) (optional) */ private TcpTypeEnum tcpType; /** The TCP Buffer size (between 0 and 2^32-1) */ private long size; /** * Create a TcpBufferWrapper instance * * @param size The TcpBuffer size * @param tcpType read or write, but can be null for both * @param url The listener */ public TcpBufferWrapper( long size, TcpTypeEnum tcpType, String url ) { this.size = size; this.tcpType = tcpType; if ( !Strings.isEmpty( url ) ) { try { listener = new URI( url ); } catch ( URISyntaxException e ) { e.printStackTrace(); } } } /** * Create a TcpBufferWrapper instance from a String * * @param tcpBufferStr The String that contain the value */ public TcpBufferWrapper( String tcpBufferStr ) { if ( tcpBufferStr != null ) { // use a lowercase version of the string String lowerCaseTcpBuffer = tcpBufferStr.toLowerCase(); int pos = 0; if ( lowerCaseTcpBuffer.startsWith( "listener=" ) ) { // Fine, we have an URL, it's before the first space int spacePos = lowerCaseTcpBuffer.indexOf( ' ' ); if ( spacePos == -1 ) { // This is wrong... } else { String urlStr = tcpBufferStr.substring( 9, spacePos ); try { this.setListener( new URI( urlStr ) ); } catch ( URISyntaxException e ) { e.printStackTrace(); } // Get rid of the following spaces pos = spacePos; while ( pos < lowerCaseTcpBuffer.length() ) { if ( lowerCaseTcpBuffer.charAt( pos ) != ' ' ) { break; } pos++; } } } // We might have a 'read' or 'write' prefix if ( lowerCaseTcpBuffer.startsWith( "read=", pos ) ) { tcpType = TcpTypeEnum.READ; pos += 5; } else if ( lowerCaseTcpBuffer.startsWith( "write=", pos ) ) { tcpType = TcpTypeEnum.WRITE; pos += 6; } // get the integer String sizeStr = lowerCaseTcpBuffer.substring( pos ); if ( !Strings.isEmpty( sizeStr ) ) { size = Long.valueOf( sizeStr ); if ( ( size < 0L ) || ( size > MAX_TCP_BUFFER_SIZE ) ) { // This is wrong } } } } /** * @return the listener */ public URI getListener() { return listener; } /** * @param listener the listener to set */ public void setListener( URI listener ) { this.listener = listener; } /** * @return the tcpType */ public TcpTypeEnum getTcpType() { return tcpType; } /** * @param tcpType the tcpType to set */ public void setTcpType( TcpTypeEnum tcpType ) { this.tcpType = tcpType; } /** * @return the size */ public long getSize() { return size; } /** * @param size the size to set */ public void setSize( long size ) { this.size = size; } /** * Tells if the TcpBuffer element is valid or not * @param sizeStr the TCP buffer size * @param urlStr The listener as a String * @return true if the values are correct, false otherwise */ public static boolean isValid( String sizeStr, String urlStr ) { // the size must be positive and below 2^32-1 if ( ( sizeStr != null ) && ( sizeStr.length() > 0 ) ) { try { long size = Long.parseLong( sizeStr ); if ( ( size < 0L ) || ( size > MAX_TCP_BUFFER_SIZE ) ) { return false; } } catch ( NumberFormatException nfe ) { return false; } } // Check the URL if ( ( urlStr != null ) && ( urlStr.length() > 0 ) ) { try { new URL( urlStr ); } catch ( MalformedURLException mue ) { return false; } } return true; } /** * Clone the current object */ public TcpBufferWrapper clone() { try { return (TcpBufferWrapper)super.clone(); } catch ( CloneNotSupportedException e ) { return null; } } /** * @see Object#equals(Object) */ public boolean equals( Object that ) { // Quick test if ( this == that ) { return true; } if ( that instanceof TcpBufferWrapper ) { TcpBufferWrapper thatInstance = (TcpBufferWrapper)that; if ( size != thatInstance.size ) { return false; } if ( tcpType != thatInstance.tcpType ) { return false; } if ( listener != null ) { return listener.equals( thatInstance.listener ); } else { return thatInstance.listener == null; } } else { return false; } } /** * @see Object#hashCode() */ public int hashCode() { int h = 37; h += h*17 + Long.hashCode( size ); h += h*17 + tcpType.hashCode(); h += h*17 + listener.hashCode(); return h; } /** * @see Comparable#compareTo() */ public int compareTo( TcpBufferWrapper that ) { // Compare by size first then by URL if ( that == null ) { return 1; } if ( size > that.size ) { return 1; } else if ( size < that.size ) { return -1; } // The URL, as a String if ( listener == null ) { if ( that.listener == null ) { return 0; } else { return -1; } } else { if ( that.listener == null ) { return 1; } else { String thisListener = listener.toString(); String thatListener = that.listener.toString(); return thisListener.compareToIgnoreCase( thatListener ); } } } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); if ( listener != null ) { sb.append( "listener=" ).append( listener ).append( " "); } if ( ( tcpType != null ) && ( tcpType != TcpTypeEnum.BOTH ) ) { sb.append( tcpType.getValue() ).append( "=" ); } sb.append( size ); return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AuthzRegexpDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AuthzRegexpDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the AuthzRegexp table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AuthzRegexpDecorator extends TableDecorator<AuthzRegexpWrapper> { /** * Create a new instance of AuthzRegexpDecorator * @param parentShell The parent Shell */ public AuthzRegexpDecorator( Shell parentShell ) { // Nothing to do } /** * Construct the label for an AuthIdRewriteWrapper. * */ @Override public String getText( Object element ) { if ( element instanceof AuthzRegexpWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( AuthzRegexpWrapper e1, AuthzRegexpWrapper e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.compareTo( e2 ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AllowFeatureDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AllowFeatureDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.common.ui.model.AllowFeatureEnum; import org.apache.directory.studio.openldap.config.editor.dialogs.AllowFeatureDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the AllowFeature table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AllowFeatureDecorator extends TableDecorator<AllowFeatureEnum> { /** * Create a new instance of AllowFeatureDecorator * @param parentShell The parent Shell */ public AllowFeatureDecorator( Shell parentShell ) { setDialog( new AllowFeatureDialog( parentShell ) ); } /** * Construct the label for an AllowFeature. * */ @Override public String getText( Object element ) { if ( element instanceof AllowFeatureEnum ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( AllowFeatureEnum e1, AllowFeatureEnum e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.getName().compareTo( e2.getName() ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.api.util.Strings; /** * This class wraps the TimeLimit parameter : * <pre> * time ::= 'time' timeLimit time-e * time-e ::= ' time' timeLimit time-e | e * timeLimit ::= '.soft=' limit | '.hard=' hardLimit | '=' limit * limit ::= 'unlimited' | 'none' | INT * hardLimit ::= 'soft' | limit * </pre> * * Note : each of the limit is an Integer, so that we can have two states : * <ul> * <li>not existent</li> * <li>has a value</li> * </ul> * A -1 value means unlimited. Any other value is accepted, if > 0. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class TimeLimitWrapper extends AbstractLimitWrapper { /** * Create a TimeLimitWrapper instance */ protected TimeLimitWrapper() { super(); } /** * Create a TimeLimitWrapper instance * * @param globalLimit The global limit * @param hardLimit The hard limit * @param softLimit The soft limit */ public TimeLimitWrapper( Integer globalLimit, Integer hardLimit, Integer softLimit ) { super( globalLimit, hardLimit, softLimit ); } /** * Create a TimeLimitWrapper instance from a String. * * @param timeLimitStr The String that contain the value */ public TimeLimitWrapper( String timeLimitStr ) { if ( !Strings.isEmpty( timeLimitStr ) ) { // use a lowercase version of the string String lowerCaseTimeLimitStr = timeLimitStr.toLowerCase(); TimeLimitWrapper tmp = new TimeLimitWrapper(); // Split the strings String[] limits = lowerCaseTimeLimitStr.split( " " ); if ( limits != null ) { // Parse each limit for ( String limit : limits ) { tmp.clear(); boolean result = parseLimit( tmp, limit ); if ( !result ) { clear(); isValid = false; break; } else { if ( tmp.globalLimit != null ) { // replace the existing global limit, nullify the hard and soft limit globalLimit = tmp.globalLimit; hardLimit = null; softLimit = null; } else { // We don't set the soft and hard limit of the global limit is not null if ( globalLimit == null ) { if ( tmp.softLimit != null ) { softLimit = tmp.softLimit; if ( hardLimit != null ) { if ( hardLimit.equals( HARD_SOFT ) || hardLimit.equals( softLimit ) ) { // Special case : we have had a time.hard=soft before, // or the hard and soft limit are equals : we set the global limit globalLimit = softLimit; softLimit = null; hardLimit = null; } } } else if ( tmp.hardLimit != null ) { if ( ( tmp.hardLimit.equals( HARD_SOFT ) && ( softLimit != null ) ) || tmp.hardLimit.equals( softLimit ) ) { // special case, softLimit was set and hardLimit was time.hard=soft, // or is equal to softLimit globalLimit = softLimit; softLimit = null; hardLimit = null; } else { hardLimit = tmp.hardLimit; } } } } } } } } } /** * Parse a single limit : * <pre> * timeLimit ::= 'time' ( '.hard=' hardLimit | '.soft=' limit | '=' limit ) * limit ::= 'unlimited' | 'none' | INT * hardLimit ::= 'soft' | limit * </pre> * @param tlw * @param limitStr */ private static boolean parseLimit( TimeLimitWrapper tlw, String limitStr ) { int pos = 0; // The timelimit always starts with a "time" if ( limitStr.startsWith( "time" ) ) { pos += 4; // A global or hard/soft ? if ( limitStr.startsWith( "=", pos ) ) { // Global : get the limit pos++; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; tlw.globalLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; tlw.globalLimit = UNLIMITED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { pos += integer.length(); try { Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { tlw.globalLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".hard=", pos ) ) { // Hard limit : get the hard limit pos += 6; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; tlw.hardLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; tlw.hardLimit = UNLIMITED; } else if ( limitStr.startsWith( SOFT_STR, pos ) ) { pos += 4; tlw.globalLimit = HARD_SOFT; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { pos += integer.length(); try { Integer value = Integer.valueOf( integer ); if ( value >= UNLIMITED ) { tlw.hardLimit = value; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else if ( limitStr.startsWith( ".soft=", pos ) ) { // Soft limit : get the limit pos += 6; if ( limitStr.startsWith( UNLIMITED_STR, pos ) ) { pos += 9; tlw.softLimit = UNLIMITED; } else if ( limitStr.startsWith( NONE_STR, pos ) ) { pos += 4; tlw.softLimit = UNLIMITED; } else { String integer = getInteger( limitStr, pos ); if ( integer != null ) { pos += integer.length(); try { Integer value = Integer.valueOf( integer ); if ( value > UNLIMITED ) { tlw.softLimit = value; } else { return false; } } catch ( NumberFormatException nfe ) { return false; } } else { return false; } } } else { // This is wrong return false; } } else { // This is wrong return false; } // last check : the pos should be equal to the limitStr length return ( pos == limitStr.length() ); } /** * @return The Limit's type */ public String getType() { return "time"; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import java.util.List; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.CommonUIConstants; import org.apache.directory.studio.common.ui.CommonUIPlugin; import org.apache.directory.studio.openldap.common.ui.model.DatabaseTypeEnum; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants; import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.StyledString; import org.eclipse.jface.viewers.StyledString.Styler; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.TextStyle; /** * This class defines a label provider for a database wrapper viewer. We use a StyledCellLabelProvider * parent, to be able to grey the disabled databases. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DatabaseWrapperLabelProvider extends StyledCellLabelProvider { /** The Style to use when a database is disabled */ private static final Styler grayedStyle = new Styler() { @Override public void applyStyles( TextStyle textStyle ) { textStyle.foreground = CommonUIPlugin.getDefault().getColor( CommonUIConstants.DISABLED_COLOR ); } }; /** * Get the Database image, if it's a Database. We can show two different icons, depending * on the Database status : enabled or disabled. */ public Image getImage( Object element ) { if ( element instanceof DatabaseWrapper ) { // the olcDisabled AT is only present in 2.5 // TODO : check with the schemaManager /* DatabaseWrapper database = (DatabaseWrapper) element; Boolean disabled = database.getDatabase().getOlcDisabled(); if ( ( disabled == null ) || !disabled ) { return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_DATABASE ); } else { return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_DISABLED_DATABASE ); } */ return OpenLdapConfigurationPlugin.getDefault().getImage( OpenLdapConfigurationPluginConstants.IMG_DATABASE ); } return null; } /** * Shows the Database name, and grey it if it's disabled. * * {@inheritDoc} */ @Override public void update( ViewerCell cell ) { Object element = cell.getElement(); if ( element instanceof DatabaseWrapper ) { DatabaseWrapper database = (DatabaseWrapper) element; OlcDatabaseConfig databaseConfig = database.getDatabase(); String databaseType = getDatabaseType( databaseConfig ); String databaseSuffix = getSuffix( databaseConfig ); String databaseName = new StringBuilder( databaseType ).append( " (" ).append( databaseSuffix ).append( ")" ).toString(); // the olcDisabled AT is only present in 2.5 // TODO : check with the schemaManager /* Boolean disabled = database.getDatabase().getOlcDisabled(); StyledString styledString = null; // Grey the database if it's disabled. if ( ( disabled == null ) || !disabled ) { styledString = new StyledString( databaseName, grayedStyle ); } else { styledString = new StyledString( databaseName, null ); } */ StyledString styledString = new StyledString( databaseName, null ); cell.setText( styledString.toString() ); cell.setStyleRanges( styledString.getStyleRanges() ); cell.setImage( getImage( database ) ); } super.update(cell); } /** * Return the database type. */ private String getDatabaseType( OlcDatabaseConfig database ) { if ( database != null ) { String databaseType = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() ); DatabaseTypeEnum databasetype = DatabaseTypeEnum.getDatabaseType( databaseType ); if ( databaseType != null ) { return databasetype.name(); } else { return DatabaseTypeEnum.NONE.name(); } } return null; } /** * Return the Database suffix DN */ private String getSuffix( OlcDatabaseConfig database ) { if ( database != null ) { List<Dn> suffixes = database.getOlcSuffix(); if ( ( suffixes != null ) && !suffixes.isEmpty() ) { return suffixes.get( 0 ).toString(); } } return DatabaseTypeEnum.NONE.getName(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.config.editor.dialogs.ServerIdDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the ServerID table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ServerIdDecorator extends TableDecorator<ServerIdWrapper> { /** * Create a new instance of ServerIdDecorator * @param parentShell The parent Shell */ public ServerIdDecorator( Shell parentShell ) { setDialog( new ServerIdDialog( parentShell ) ); } /** * Construct the label for a ServerID. It can be a number in [0..999], or an URL */ @Override public String getText( Object element ) { if ( element instanceof ServerIdWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none (may be we could add one for URLs ?) */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( ServerIdWrapper e1, ServerIdWrapper e2 ) { if ( e1 != null ) { return e1.compareTo( e2 ); } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; /** * An interface for the TimeLimitWrapper and SizeLimitWrapper * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public interface LimitWrapper extends Comparable<LimitWrapper> { // Define some of the used constants Integer HARD_SOFT = Integer.valueOf( -3 ); Integer UNLIMITED = Integer.valueOf( -1 ); String HARD_STR = "hard"; String NONE_STR = "none"; String SOFT_STR = "soft"; String UNLIMITED_STR = "unlimited"; /** * Clear the TimeLimitWrapper (reset all the values to null) */ void clear(); /** * @return the globalLimit */ Integer getGlobalLimit(); /** * @param globalLimit the globalLimit to set */ void setGlobalLimit( Integer globalLimit ); /** * @return the softLimit */ Integer getSoftLimit(); /** * @param softLimit the softLimit to set */ void setSoftLimit( Integer softLimit ); /** * @return the hardLimit */ Integer getHardLimit(); /** * @param hardLimit the hardLimit to set */ void setHardLimit( Integer hardLimit ); /** * @return The Limit's type */ String getType(); /** * Tells if the LimitWrapper instance is valid * @return True if this is a valid instance */ boolean isValid(); }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.common.ui.wrappers.StringValueWrapper; import org.apache.directory.studio.openldap.config.editor.dialogs.OrderedStringValueDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for a String Value table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OrderedStringValueDecorator extends TableDecorator<OrderedStringValueWrapper> { /** * Create a new instance of StringValueDecorator * @param parentShell The parent Shell */ public OrderedStringValueDecorator( Shell parentShell, String attributeName ) { setDialog( new OrderedStringValueDialog( parentShell, attributeName ) ); } /** * Construct the label for a String. * */ @Override public String getText( Object element ) { if ( element instanceof StringValueWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( OrderedStringValueWrapper e1, OrderedStringValueWrapper e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.compareTo( e2 ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import java.util.ArrayList; import java.util.List; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.widgets.OrderedElement; import org.apache.directory.studio.openldap.common.ui.model.DnSpecStyleEnum; import org.apache.directory.studio.openldap.common.ui.model.DnSpecTypeEnum; import org.apache.directory.studio.openldap.common.ui.model.LimitSelectorEnum; /** * This class wraps the olcLimits parameter : * <pre> * olcLimits ::= selector limit limit-e * selector ::= '*' | 'anonymous' | 'users' | dnspec '=' pattern | group '=' pattern * dnspec ::= 'dn' type-e style-e * type-e ::= '.self' | '.this' | e * style-e ::= '.exact' | '.base' | '.one' | '.onelevel' | '.sub' | '.subtree' | '.children' | '.regex' | '.anonymous' | e * pattern ::= '*' | '.*' | '"' REGEXP '"' * group ::= 'group' group-oc * group-oc ::= '/' OBJECT_CLASS group-at | e * group-at ::= '/' ATTRIBUTE_TYPE | e * limit ::= 'time' time-limit | 'size' size-limit * time-limit ::= '.soft=' limit-value| '.hard=' time-hard | '=' limit-value * time-hard ::= limit-value | 'soft' * size-limit ::= '.soft=' limit-value | '.hard=' size-hard | '.unchecked=' | '=' limit-value * size-hard ::= limit-value | 'soft' | 'disable' * limit-value ::= INT | 'unlimited' * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LimitsWrapper implements Cloneable, Comparable<LimitsWrapper>, OrderedElement { /** Prefix, as the Limits are ordered */ private int prefix; /** The selector */ private LimitSelectorEnum selector; /** The pattern if the selector is a dnspec or a group */ private String selectorPattern; /** The type if the selector is a DnSpec */ private DnSpecTypeEnum dnSpecType; /** The style if the selector is a DnSpec */ private DnSpecStyleEnum dnSpecStyle; /** The group ObjectClass */ private String objectClass; /** The group AttributeType */ private String attributeType; /** The list of limits, as Strings */ private List<LimitWrapper> limits = new ArrayList<>(); /** A flag to tell if the limits is valid or not */ private boolean isValid = true; /** A flag used when the limit is invalid */ private static final int ERROR = -1; /** A flag used when the parsing is completed */ private static final int EOL = Integer.MIN_VALUE; /** * Create a LimitsrWrapper instance */ public LimitsWrapper() { } /** * Create a LimitsrWrapper instance from a String * * @param limitsStr The String that contain the value */ public LimitsWrapper( String limitsStr ) { if ( limitsStr != null ) { // use a lowercase version of the string String lowerCaseLimits = limitsStr.toLowerCase(); int pos = 0; // It's ordered : process the prefix if ( Strings.isCharASCII( lowerCaseLimits, pos, '{' ) ) { pos++; prefix = 0; while ( pos < lowerCaseLimits.length() ) { char c = lowerCaseLimits.charAt( pos ); if ( ( c >= '0' ) && ( c <= '9' ) ) { prefix = prefix * 10 + ( c - '0' ); pos++; } else if ( c == '}' ) { pos++; break; } else { isValid = false; break; } } } if ( isValid ) { lowerCaseLimits = lowerCaseLimits.substring( pos ); // Process the selector if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANY.getName() ) ) { selector = LimitSelectorEnum.ANY; pos += LimitSelectorEnum.ANY.getName().length(); } if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANONYMOUS.getName() ) ) { selector = LimitSelectorEnum.ANONYMOUS; pos += LimitSelectorEnum.ANONYMOUS.getName().length(); } else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.USERS.getName() ) ) { selector = LimitSelectorEnum.USERS; pos += LimitSelectorEnum.USERS.getName().length(); } else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.DNSPEC.getName() ) ) { selector = LimitSelectorEnum.DNSPEC; pos += LimitSelectorEnum.DNSPEC.getName().length(); // parse the type pos = parseDnSpec( lowerCaseLimits, pos ); if ( pos == ERROR ) { isValid = false; } } else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.GROUP.getName() ) ) { selector = LimitSelectorEnum.GROUP; pos += LimitSelectorEnum.GROUP.getName().length(); pos = parseGroup( lowerCaseLimits, pos ); if ( pos == ERROR ) { // This is an error isValid = false; } } } // Process the limits, only if the selector was valid if ( isValid ) { boolean noLimit = true; while ( pos >= 0 ) { pos = parseLimit( lowerCaseLimits, pos ); if ( noLimit ) { if ( pos == EOL ) { // We must have at least one limit { isValid = false; break; } } else { noLimit = false; } } if ( pos == ERROR ) { isValid = false; break; } } } } } /** * Parse the DNSpec part : * <pre> * dnspec ::= 'dn' type-e style-e '=' pattern * type-e ::= '.self' | '.this' | e * style-e ::= '.exact' | '.base' | '.one' | '.onelevel' | '.sub' | '.subtree' | '.children' | '.regex' | '.anonymous' | e * </pre> */ private int parseDnSpec( String str, int pos ) { // The type if ( str.startsWith( ".self", pos ) ) { dnSpecType = DnSpecTypeEnum.SELF; pos += 5; } else if ( str.startsWith( ".this", pos ) ) { dnSpecType = DnSpecTypeEnum.THIS; pos += 5; } // The style if ( str.startsWith( ".exact", pos ) ) { dnSpecStyle = DnSpecStyleEnum.EXACT; pos += 6; } else if ( str.startsWith( ".base", pos ) ) { dnSpecStyle = DnSpecStyleEnum.BASE; pos += 5; } else if ( str.startsWith( ".onelevel", pos ) ) { dnSpecStyle = DnSpecStyleEnum.ONE_LEVEL; pos += 9; } else if ( str.startsWith( ".one", pos ) ) { dnSpecStyle = DnSpecStyleEnum.ONE_LEVEL; pos += 4; } else if ( str.startsWith( ".subtree", pos ) ) { dnSpecStyle = DnSpecStyleEnum.SUBTREE; pos += 8; } else if ( str.startsWith( ".sub", pos ) ) { dnSpecStyle = DnSpecStyleEnum.SUBTREE; pos += 4; } else if ( str.startsWith( ".children", pos ) ) { dnSpecStyle = DnSpecStyleEnum.CHILDREN; pos += 9; } else if ( str.startsWith( ".regex", pos ) ) { dnSpecStyle = DnSpecStyleEnum.REGEXP; pos += 6; } else if ( str.startsWith( ".anonymous", pos ) ) { dnSpecStyle = DnSpecStyleEnum.ANONYMOUS; pos += 10; } // The pattern return parsePattern( str, pos ); } /** * Parse the group part : * <pre> * group ::= 'group' group-oc '=' pattern * group-oc ::= '/' OBJECT_CLASS group-at | e * group-at ::= '/' ATTRIBUTE_TYPE | e * </pre> */ private int parseGroup( String str, int pos ) { // Check if we have an ObjectClass if ( Strings.isCharASCII( str, pos, '/' ) ) { int i = pos + 1; for ( ; i < str.length(); i++ ) { char c = str.charAt( i ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( ( c >= '0' ) && ( c <= '9' ) ) || ( c == '.' ) || ( c == '-' ) || ( c == '_' ) ) { continue; } } if ( i > pos + 1 ) { // An ObjectClass objectClass = str.substring( pos + 1, i ); } pos = i; } // Check if we have an AttributeType if ( Strings.isCharASCII( str, pos, '/' ) ) { int i = pos + 1; for ( ; i < str.length(); i++ ) { char c = str.charAt( i ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( ( c >= '0' ) && ( c <= '9' ) ) || ( c == '.' ) || ( c == '-' ) || ( c == '_' ) ) { continue; } } if ( i > pos + 1 ) { // An AttributeType attributeType = str.substring( pos + 1, i ); } pos = i; } // The pattern return parsePattern( str, pos ); } /** * Search for a pattern */ private int parsePattern( String str, int pos ) { if ( !Strings.isCharASCII( str, pos, '=' ) ) { return ERROR; } pos++; if ( !Strings.isCharASCII( str, pos, '"' ) ) { return ERROR; } pos++; boolean escapeSeen = false; for ( int i = pos; i < str.length(); i++ ) { if ( str.charAt( i ) == '\\' ) { escapeSeen = !escapeSeen; } else { if ( str.charAt( i ) == '"' ) { if ( escapeSeen ) { escapeSeen = false; } else { // This is the end of the patter selectorPattern = str.substring( pos, i ); return i + 1; } } else { escapeSeen = false; } } } // The final '"' has not been found, this is an error. return ERROR; } /** * Parses the limit. * <pre> * limit ::= 'time' time-limit | 'size' size-limit * time-limit ::= '.soft=' limit-value| '.hard=' time-hard | '=' limit-value * time-hard ::= limit-value | 'soft' * size-limit ::= '.soft=' limit-value | '.hard=' size-hard | '.unchecked=' | '=' limit-value * size-hard ::= limit-value | 'soft' | 'disable' * limit-value ::= INT | 'unlimited' | 'none' * </pre> */ private int parseLimit( String str, int pos ) { // Remove spaces while ( Strings.isCharASCII( str, pos, ' ' ) ) { pos++; } String limitStr = str.substring( pos ); if ( Strings.isEmpty( limitStr ) ) { return EOL; } int i = 0; if ( limitStr.startsWith( "time" ) ) { // fetch the time limit (everything that goes up to a space or the end of the string for ( ; i < limitStr.length(); i++ ) { if ( limitStr.charAt( i ) == ' ' ) { break; } } if ( i == 0 ) { return ERROR; } TimeLimitWrapper timeLimitWrapper = new TimeLimitWrapper( limitStr.substring( 0, i ) ); if ( timeLimitWrapper.isValid() ) { limits.add( timeLimitWrapper ); return pos + i; } else { return ERROR; } } else if ( limitStr.startsWith( "size" ) ) { // fetch the size limit (everything that goes up to a space or the end of the string for ( ;i < limitStr.length(); i++ ) { if ( limitStr.charAt( i ) == ' ' ) { break; } } if ( i == 0 ) { return ERROR; } SizeLimitWrapper sizeLimitWrapper = new SizeLimitWrapper( limitStr.substring( 0, i ) ); if ( sizeLimitWrapper.isValid() ) { limits.add( sizeLimitWrapper ); return pos + i; } else { return ERROR; } } else { return ERROR; } } /** * Sets a new prefix * * @param prefix the prefix to set */ public void setPrefix( int prefix ) { this.prefix = prefix; } /** * @return the prefix */ public int getPrefix() { return prefix; } /** * {@inheritDoc} */ public void decrementPrefix() { prefix--; } /** * {@inheritDoc} */ public void incrementPrefix() { prefix++; } /** * @return the selector */ public LimitSelectorEnum getSelector() { return selector; } /** * @param selector the selector to set */ public void setSelector( LimitSelectorEnum selector ) { this.selector = selector; } /** * @return the selectorPattern */ public String getSelectorPattern() { return selectorPattern; } /** * @param selectorPattern the selectorPattern to set */ public void setSelectorPattern( String selectorPattern ) { this.selectorPattern = selectorPattern; } /** * @return the dnSpecType */ public DnSpecTypeEnum getDnSpecType() { return dnSpecType; } /** * @param dnSpecType the dnSpecType to set */ public void setDnSpecType( DnSpecTypeEnum dnSpecType ) { this.dnSpecType = dnSpecType; } /** * @return the dnSpecStyle */ public DnSpecStyleEnum getDnSpecStyle() { return dnSpecStyle; } /** * @param dnSpecStyle the dnSpecStyle to set */ public void setDnSpecStyle( DnSpecStyleEnum dnSpecStyle ) { this.dnSpecStyle = dnSpecStyle; } /** * @return the objectClass */ public String getObjectClass() { return objectClass; } /** * @param objectClass the objectClass to set */ public void setObjectClass( String objectClass ) { this.objectClass = objectClass; } /** * @return the attributeType */ public String getAttributeType() { return attributeType; } /** * @param attributeType the attributeType to set */ public void setAttributeType( String attributeType ) { this.attributeType = attributeType; } /** * @return the limits */ public List<LimitWrapper> getLimits() { return limits; } /** * @param limits the limits to set */ public void setLimits( List<LimitWrapper> limits ) { this.limits = limits; } /** * Tells if the Limits element is valid or not * @return true if the values are correct, false otherwise */ public boolean isValid() { return isValid; } /** * Clone the current object */ public LimitsWrapper clone() { try { return (LimitsWrapper)super.clone(); } catch ( CloneNotSupportedException e ) { return null; } } /** * LimitsWrapper are ordered objects * @see Object#equals(Object) */ public boolean equals( Object that ) { // Quick test if ( this == that ) { return true; } if ( that instanceof LimitsWrapper ) { LimitsWrapper thatInstance = (LimitsWrapper)that; // Check the prefix first if ( prefix != thatInstance.prefix ) { return false; } // The selector if ( selector != thatInstance.selector ) { return false; } // Same selector. Depending on the type, check the two instance switch ( selector ) { case DNSPEC : if ( ( dnSpecStyle != thatInstance.dnSpecStyle ) || ( dnSpecType != thatInstance.dnSpecType ) ) { return false; } // Check the pattern if ( selectorPattern != thatInstance.selectorPattern ) { return false; } break; case GROUP : // If we have an ObjectClass, check it if ( ( objectClass != null ) && ( !objectClass.equals( thatInstance.objectClass ) ) ) { return false; } else if ( thatInstance.objectClass != null ) { return false; } // If we have an AttributeType, check it if ( ( attributeType != null ) && ( !attributeType.equals( thatInstance.attributeType ) ) ) { return false; } else if ( thatInstance.attributeType != null ) { return false; } // Check the pattern if ( selectorPattern != thatInstance.selectorPattern ) { return false; } break; case ANY : case ANONYMOUS : case USERS : break; } // Check the limits now if ( limits.size() != thatInstance.limits.size() ) { return false; } // Iterate on both limits (they are not ordered... This is a O(n2) loop. for ( LimitWrapper limit : limits ) { boolean found = false; for ( LimitWrapper thatLimit : thatInstance.limits ) { if ( limit.equals( thatLimit ) ) { found = true; break; } } if ( !found ) { return false; } } return true; } else { return false; } } /** * @see Object#hashCode() */ public int hashCode() { int h = 37; h += h*17 + selector.hashCode(); // The selector switch ( selector ) { case DNSPEC : if ( dnSpecType != null ) { h += h*17 + dnSpecType.hashCode(); } if ( dnSpecStyle != null ) { h += h*17 + dnSpecStyle.hashCode(); } break; case GROUP : if ( selectorPattern != null ) { h += h*17 + selectorPattern.hashCode(); } break; } // The limits for ( LimitWrapper limit : limits ) { h += h*17 + limit.hashCode(); } return h; } /** * @see Comparable#compareTo() */ public int compareTo( LimitsWrapper that ) { if ( that == null ) { return 1; } // Check the prefix if ( prefix < that.prefix ) { return -1; } else if ( prefix > that.prefix ) { return 1; } else { return 0; } } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append( '{' ).append( prefix ).append( '}' ); sb.append( selector.getName() ); // The selector switch ( selector ) { case ANY : case ANONYMOUS : case USERS : break; case DNSPEC : if ( dnSpecType != null ) { sb.append( '.' ).append( dnSpecType.getName() ); } if ( dnSpecStyle != null ) { sb.append( '.' ).append( dnSpecStyle.getName() ); } sb.append( "=\"" ); sb.append( selectorPattern ); sb.append( '\"' ); break; case GROUP : if ( objectClass != null ) { sb.append( '/' ).append( objectClass ); } if ( attributeType != null ) { sb.append( '/' ).append( attributeType ); } sb.append( "=\"" ); sb.append( selectorPattern ); sb.append( '\"' ); break; } // The limits for ( LimitWrapper limit : limits ) { sb.append( ' ' ); sb.append( limit ); } return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DnWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DnWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.api.ldap.model.name.Dn; /** * A wrapper for DNs. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DnWrapper implements Cloneable, Comparable<DnWrapper> { /** The interned DN */ private Dn dn; /** * Build a DnWrapper from a String containing the DN * * @param dn The DN to store */ public DnWrapper( Dn dn ) { this.dn = dn; } /** * @return the dn */ public Dn getDn() { return dn; } /** * @param dn the dn to set */ public void setDn( Dn dn ) { this.dn = dn; } /** * @see Object#clone() */ public DnWrapper clone() { // No need to clone, DN is immutable return this; } /** * @see Object#hashCode() */ public int hashCode() { return dn.hashCode(); } /** * @see Object#equals() */ public boolean equals( Object that ) { if ( that == this ) { return true; } if ( ! ( that instanceof DnWrapper ) ) { return false; } return compareTo( (DnWrapper)that ) == 0; } /** * @see Comparable#compareTo() */ public int compareTo( DnWrapper that ) { if ( that == null ) { return 1; } if ( dn.equals( that.dn ) ) { return 0; } if ( dn.isDescendantOf( that.dn ) ) { return 1; } else if ( that.dn.isDescendantOf( dn ) ) { return -1; } else { // Find the common ancestor, if any int upperBound = Math.min( dn.size(), that.dn.size() ); int result = 0; for ( int i = 0; i < upperBound; i++ ) { result = dn.getRdn( i ).compareTo( that.dn.getRdn( i ) ); if ( result != 0 ) { return result; } } // We have exhausted one of the DN if ( dn.size() > upperBound ) { return 1; } else { return -1; } } } /** * @see Object#toString() */ public String toString() { return dn.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig; /** * This class implements a database wrapper used in the 'Databases' page UI. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DatabaseWrapper { /** The wrapped database */ private OlcDatabaseConfig database; /** * Creates a new instance of DatabaseWrapper. */ public DatabaseWrapper() { } /** * Creates a new instance of DatabaseWrapper. * * @param database the wrapped database */ public DatabaseWrapper( OlcDatabaseConfig database ) { this.database = database; } /** * Gets the wrapped database. * * @return the wrapped database */ public OlcDatabaseConfig getDatabase() { return database; } /** * Sets the wrapped database. * * @param database the wrapped database */ public void setDatabase( OlcDatabaseConfig database ) { this.database = database; } /** * @see Object#toString() */ public String toString() { return database.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DisallowFeatureDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DisallowFeatureDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.common.ui.model.DisallowFeatureEnum; import org.apache.directory.studio.openldap.config.editor.dialogs.DisallowFeatureDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the DisallowFeature table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DisallowFeatureDecorator extends TableDecorator<DisallowFeatureEnum> { /** * Create a new instance of DisallowFeatureDecorator * @param parentShell The parent Shell */ public DisallowFeatureDecorator( Shell parentShell ) { setDialog( new DisallowFeatureDialog( parentShell ) ); } /** * Construct the label for an DisallowFeature. * */ @Override public String getText( Object element ) { if ( element instanceof DisallowFeatureEnum ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( DisallowFeatureEnum e1, DisallowFeatureEnum e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.getName().compareTo( e2.getName() ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AbstractLimitWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AbstractLimitWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; /** * A shared class with the TimeLimitWrapper and SizeLimitWrapper * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractLimitWrapper implements LimitWrapper, Comparable<LimitWrapper> { /** The global limit */ protected Integer globalLimit; /** The soft limit */ protected Integer softLimit; /** The hard limit */ protected Integer hardLimit; /** A flag that tells if the Limit is valid */ protected boolean isValid = true; /** The length of the parsed String, if any */ protected int parsedLength = 0; /** * Create a AbstractLimitWrapper instance */ public AbstractLimitWrapper() { } /** * Create an AbstractLimitWrapper instance * * @param globalLimit The global limit * @param hardLimit The hard limit * @param softLimit The soft limit */ public AbstractLimitWrapper( Integer globalLimit, Integer hardLimit, Integer softLimit ) { this.globalLimit = globalLimit; this.hardLimit = hardLimit; this.softLimit = softLimit; } /** * Clear the TimeLimitWrapper (reset all the values to null) */ public void clear() { globalLimit = null; softLimit = null; hardLimit = null; } /** * Get an integer out of a String. Return null if we don't find any. */ protected static String getInteger( String str, int pos ) { for ( int i = pos; i < str.length(); i++ ) { char c = str.charAt( i ); if ( ( c < '0') && ( c > '9' ) ) { if ( i == pos ) { return null; } else { return str.substring( pos, i ); } } } return str.substring( pos ); } /** * @return the globalLimit */ public Integer getGlobalLimit() { return globalLimit; } /** * @param globalLimit the globalLimit to set */ public void setGlobalLimit( Integer globalLimit ) { this.globalLimit = globalLimit; } /** * @return the softLimit */ public Integer getSoftLimit() { return softLimit; } /** * @param softLimit the softLimit to set */ public void setSoftLimit( Integer softLimit ) { this.softLimit = softLimit; } /** * @return the hardLimit */ public Integer getHardLimit() { return hardLimit; } /** * @param hardLimit the hardLimit to set */ public void setHardLimit( Integer hardLimit ) { this.hardLimit = hardLimit; } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); String limitType = getType(); if ( globalLimit != null ) { // The globalLimit overrides the soft and hard limit sb.append( limitType ); if ( globalLimit.intValue() >= 0 ) { sb.append( "=" ).append( globalLimit ); } else if ( globalLimit.equals( UNLIMITED ) ) { sb.append( "=" ).append( UNLIMITED_STR ); } else if ( globalLimit.equals( HARD_SOFT ) ) { sb.append( ".hard=" ).append( SOFT_STR ); } } else { if ( hardLimit != null ) { // First check the hard limit, has it can be set to be equal to soft limit if ( softLimit != null ) { if ( hardLimit.equals( softLimit ) ) { // If hard and soft are set and equals, we use the global limit instead sb.append( limitType ).append( "=" ); if ( hardLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( hardLimit.intValue() >= 0 ) { sb.append( hardLimit ); } } else { // We have both values, the aren't equal. if ( hardLimit.equals( UNLIMITED ) ) { sb.append( limitType ).append( ".hard=unlimited " ); sb.append( limitType ).append( ".soft=" ); sb.append( softLimit ); } else if ( hardLimit.intValue() == 0 ) { // Special cases : hard = soft sb.append( limitType ).append( "=" ).append( softLimit ); } else if ( hardLimit.intValue() < softLimit.intValue() ) { // when the hard limit is lower than the soft limit : use the hard limit sb.append( limitType ).append( "=" ).append( hardLimit ); } else { // Special case : softLimit is -1 if ( softLimit.equals( UNLIMITED ) ) { // We use the hard limit sb.append( limitType ).append( "=" ).append( hardLimit ); } else { sb.append( limitType ).append( ".hard=" ); if ( hardLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( hardLimit.intValue() > 0 ) { sb.append( hardLimit ); } sb.append( ' ' ).append( limitType ).append( ".soft=" ); if ( softLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( softLimit.intValue() >= 0 ) { sb.append( softLimit ); } } } } } else { // Only an hard limit sb.append( limitType ).append( ".hard=" ); if ( hardLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( hardLimit.intValue() >= 0 ) { sb.append( hardLimit ); } } } else if ( softLimit != null ) { // Only a soft limit sb.append( limitType ).append( ".soft=" ); if ( softLimit.equals( UNLIMITED ) ) { sb.append( UNLIMITED_STR ); } else if ( softLimit.intValue() >= 0 ) { sb.append( softLimit ); } } } return sb.toString(); } /** * @see Comparable#compareTo() */ public int compareTo( LimitWrapper that ) { if ( that == null ) { return 1; } return toString().compareTo( that.toString() ); } /** * Tells if the TimeLimit element is valid or not * @return true if the values are correct, false otherwise */ public boolean isValid() { return isValid; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SaslSecPropsWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SaslSecPropsWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import java.util.HashSet; import java.util.Set; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.openldap.common.ui.model.SaslSecPropEnum; /** * A wrapper for the olcSaslSecProps parameter. The syntax is the following : * * <pre> * saslSecProp ::= ( 'none' | 'noplain' | 'noactive' | 'nodict' | 'noanonymous' | 'forwardsec' | * 'passcred' | 'minssf' '=' INT | 'maxssf' '=' INT | 'maxbufsuze' '=' INT )* * </pre> * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SaslSecPropsWrapper implements Cloneable { /** The flags for properties with no arguments */ private Set<SaslSecPropEnum> flags = new HashSet<>(); /** The value of the minSSF parameter */ private Integer minSsf; /** The value of the maxSSF parameter */ private Integer maxSsf; /** The max buffer size parameter */ private Integer maxBufSize; /** * Creates an instance of a SaslSecProps **/ public SaslSecPropsWrapper() { } /** * Creates an instance of a SaslSecProps parameter using a String. * * @param parameters The list of parameters to parse */ public SaslSecPropsWrapper( String parameters ) { if ( !Strings.isEmpty( Strings.trim( parameters ) ) ) { // Split the string along the spaces String[] properties = parameters.split( "," ); for ( String property : properties ) { if ( Strings.isEmpty( Strings.trim( property ) ) ) { continue; } int pos = property.indexOf( '=' ); if ( pos == -1 ) { // No value SaslSecPropEnum flag = SaslSecPropEnum.getSaslSecProp( Strings.trim( property ) ); switch ( flag ) { case FORWARD_SEC : case NO_ACTIVE : case NO_ANONYMOUS : case NO_DICT : case NO_PLAIN : case PASS_CRED : case NONE : flags.add( flag ); break; case MAX_BUF_SIZE : case MAX_SSF : case MIN_SSF : case UNKNOWN : // Nothing to do... } } else { // Fetch the name String name = property.substring( 0, pos ); SaslSecPropEnum flag = SaslSecPropEnum.getSaslSecProp( Strings.trim( name ) ); try { int value = Integer.parseInt( Strings.trim( property.substring( pos + 1 ) ) ); if ( value >= 0 ) { switch ( flag ) { case MAX_BUF_SIZE : maxBufSize = Integer.valueOf( value ); break; case MAX_SSF : maxSsf = Integer.valueOf( value ); break; case MIN_SSF : minSsf = Integer.valueOf( value ); break; case FORWARD_SEC : case NO_ACTIVE : case NO_ANONYMOUS : case NO_DICT : case NO_PLAIN : case PASS_CRED : case NONE : case UNKNOWN : // Nothing to do... This is an error } } } catch ( NumberFormatException nfe ) { // Nothing to do } } } } } /** * Check if a given String is a valid SaslSecProp parameter * * @param str The string to check * @return true if the string is a valid SaslSecProp parameter */ public static boolean isValid( String str ) { if ( !Strings.isEmpty( Strings.trim( str ) ) ) { // Split the string along the spaces String[] properties = str.split( "," ); if ( ( properties == null ) || ( properties.length == 0 ) ) { return true; } for ( String property : properties ) { if ( Strings.isEmpty( Strings.trim( property ) ) ) { continue; } int pos = property.indexOf( '=' ); if ( pos == -1 ) { // No value SaslSecPropEnum flag = SaslSecPropEnum.getSaslSecProp( Strings.trim( property ) ); switch ( flag ) { case FORWARD_SEC : case NO_ACTIVE : case NO_ANONYMOUS : case NO_DICT : case NO_PLAIN : case PASS_CRED : case NONE : break; default : return false; } } else { // Fetch the name String name = property.substring( 0, pos ); SaslSecPropEnum flag = SaslSecPropEnum.getSaslSecProp( Strings.trim( name ) ); try { int value = Integer.parseInt( Strings.trim( property.substring( pos + 1 ) ) ); if ( value < 0 ) { return false; } switch ( flag ) { case MAX_BUF_SIZE : case MAX_SSF : case MIN_SSF : break; default : return false; } } catch ( NumberFormatException nfe ) { // wrong return false; } } } return true; } else { return true; } } /** * @return the flag */ public Set<SaslSecPropEnum> getFlags() { return flags; } /** * @param flag the flag to set */ public void addFlag( SaslSecPropEnum flag ) { this.flags.add( flag ); } /** * @param flag the flag to remove */ public void removeFlag( SaslSecPropEnum flag ) { this.flags.remove( flag ); } /** * Clear the flag's set */ public void clearFlags() { this.flags.clear(); } /** * @return the minSsf */ public Integer getMinSsf() { return minSsf; } /** * @param minSsf the minSsf to set */ public void setMinSsf( Integer minSsf ) { this.minSsf = minSsf; } /** * @return the maxSsf */ public Integer getMaxSsf() { return maxSsf; } /** * @param maxSsf the maxSsf to set */ public void setMaxSsf( Integer maxSsf ) { this.maxSsf = maxSsf; } /** * @return the maxBufSize */ public Integer getMaxBufSize() { return maxBufSize; } /** * @param maxBufSize the maxBufSize to set */ public void setMaxBufSize( Integer maxBufSize ) { this.maxBufSize = maxBufSize; } /** * Compare two Integer instance and return true if they are equal */ private boolean equals( Integer int1, Integer int2 ) { if ( int1 == null ) { return int2 == null; } return int1.equals( int2 ); } /** * @see Object#equals(Object) */ public boolean equals( Object that ) { if ( this == that ) { return true; } if ( !( that instanceof SaslSecPropsWrapper ) ) { return false; } SaslSecPropsWrapper thatInstance = (SaslSecPropsWrapper)that; return ( ( flags.size() == thatInstance.flags.size() ) && ( thatInstance.flags.containsAll( flags ) ) && ( equals( minSsf, thatInstance.minSsf ) ) && ( equals( maxSsf, thatInstance.maxSsf ) ) && ( equals( maxBufSize, thatInstance.maxBufSize ) ) ); } /** * @see Object#hashCode() */ public int hashCode() { int h = 37; if ( minSsf != null ) { h += h*17 + minSsf.intValue(); } if ( maxSsf != null ) { h += h*17 + maxSsf.intValue(); } if ( maxBufSize != null ) { h += h*17 + maxBufSize.intValue(); } for ( SaslSecPropEnum saslSecProp : flags ) { h += h*17 + saslSecProp.hashCode(); } return h; } /** * Clone the current object */ public SaslSecPropsWrapper clone() { try { return (SaslSecPropsWrapper)super.clone(); } catch ( CloneNotSupportedException e ) { return null; } } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for ( SaslSecPropEnum saslSecProp : flags ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( saslSecProp.getName() ); } // The minSSF properties if ( minSsf != null ) { if ( sb.length() > 0 ) { sb.append( ',' ); } sb.append( SaslSecPropEnum.MIN_SSF.getName() ).append( '=' ).append( minSsf.intValue() ); } // The maxSSF properties if ( maxSsf != null ) { if ( sb.length() > 0 ) { sb.append( ',' ); } sb.append( SaslSecPropEnum.MAX_SSF.getName() ).append( '=' ).append( maxSsf.intValue() ); } // The maxbufsize properties if ( maxBufSize != null ) { if ( sb.length() > 0 ) { sb.append( ',' ); } sb.append( SaslSecPropEnum.MAX_BUF_SIZE.getName() ).append( '=' ).append( maxBufSize.intValue() ); } return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DbIndexWrapper.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DbIndexWrapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.openldap.common.ui.model.DbIndexTypeEnum; /** * A wrapper for the Databse indexes. It's used by the BDB, MDB, or HDB/BDB. Here is the * index value's syntax : * <pre> * <olcDbIndex> ::= ATTR <attr-list> <index-types-e> | 'default' <index-types> * <attr-list> ::= ',' ATTR <attr-list> | e * <index-types> ::= <type> <types-e> * <types-e> ::= ',' <type> <types-e> | e * <type> ::= 'pres' | 'eq' | 'sub' | 'approx' | 'sub' | 'subinitial' | 'subany' | * 'subfinal' | 'substr' | 'notags' | 'nolang' | 'nosubtypes' * <index-types-e> ::= <index-types> | e * </pre> * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DbIndexWrapper implements Cloneable, Comparable<DbIndexWrapper> { /** A flag set when the 'default' special attribute is used */ private boolean isDefault; /** The set of configured attributes */ private Set<String> attributes = new TreeSet<>( ( string1, string2 ) -> { if ( string1 == null ) { return -1; } else if ( string2 == null ) { return 1; } return string1.compareTo( string2 ); } ); /** The set of configured attributes */ private Set<DbIndexTypeEnum> indexTypes = new TreeSet<>(); /** * Build a DbIndexWrapper from a String containing the description of the index. * * @param indexStr The String that describes the index */ public DbIndexWrapper( String indexStr ) { // We first have to parse the attributes. It's a list of Strings, or OIDs, separated // by ',' and that ends at the first ' ' or the end of the line. int pos = 0; int startPos = 0; boolean endAttributes = false; // Valid chars are 'a'-'z', 'A'-'Z', '0'-'9', '.', '-' and '_' for ( pos = 0; pos < indexStr.length(); pos++ ) { char c = indexStr.charAt( pos ); endAttributes = c == ' '; if ( ( c == ',' ) || endAttributes ) { // This is the end of the attribute String attrStr = indexStr.substring( startPos, pos ); if ( "default".equalsIgnoreCase( attrStr ) ) { isDefault = true; startPos = pos + 1; break; } // Check that it's a valid Attribute attributes.add( Strings.toLowerCaseAscii( attrStr ) ); startPos = pos + 1; } if ( endAttributes ) { break; } } // If the 'default' special attribute is present, we can discard all the other attributes if ( isDefault ) { attributes.clear(); } if ( endAttributes ) { pos++; // Ok, we are done with the attributes, let's process the indexTypes now, // starting where we left for ( ; pos < indexStr.length(); pos++ ) { char c = indexStr.charAt( pos ); if ( c == ',' ) { String indexTypeName = indexStr.substring( startPos, pos ); // Check if we have this indexType DbIndexTypeEnum indexType = DbIndexTypeEnum.getIndexType( indexTypeName ); if ( indexType != DbIndexTypeEnum.NONE ) { indexTypes.add( indexType ); } startPos = pos + 1; } } if ( pos != startPos ) { // Search for the index type String indexTypeName = indexStr.substring( startPos, pos ); // Check if we have this indexType DbIndexTypeEnum indexType = DbIndexTypeEnum.getIndexType( indexTypeName ); if ( indexType != DbIndexTypeEnum.NONE ) { indexTypes.add( indexType ); } } } } /** * @return the isDefault */ public boolean isDefault() { return isDefault; } /** * @param isDefault the isDefault to set */ public void setDefault( boolean isDefault ) { this.isDefault = isDefault; } /** * @return The set of attributes */ public Set<String> getAttributes() { return attributes; } /** * @return the indexTypes */ public Set<DbIndexTypeEnum> getIndexTypes() { return indexTypes; } /** * @return The set of index types */ public Set<DbIndexTypeEnum> getTypes() { return indexTypes; } /** * @see Object#clone() */ public DbIndexWrapper clone() { try { DbIndexWrapper clone = (DbIndexWrapper)super.clone(); // Clone the attributes clone.attributes = new TreeSet<>(); clone.attributes.addAll( attributes ); // Clone the indexTypes clone.indexTypes = new TreeSet<>(); clone.indexTypes.addAll( indexTypes ); return clone; } catch ( CloneNotSupportedException cnse ) { return null; } } /** * @see Object#hashCode() */ public int hashCode() { int h = 37; // Only iterate on Attributes for ( String attribute : attributes ) { h += h*17 + attribute.hashCode(); } return h; } /** * @see Object#equals() */ public boolean equals( Object that ) { if ( that == this ) { return true; } if ( ! ( that instanceof DbIndexWrapper ) ) { return false; } return compareTo( (DbIndexWrapper)that ) == 0; } /** * @see Comparable#compareTo() */ public int compareTo( DbIndexWrapper that ) { // Compare by attributes only. if ( that == null ) { return 1; } // we will iterate on the two sets in parallel. int limit = Math.min( attributes.size(), that.attributes.size() ); Iterator<String> thisIterator = attributes.iterator(); Iterator<String> thatIterator = that.attributes.iterator(); for ( int i = 0; i < limit; i++ ) { int result = thisIterator.next().compareTo( thatIterator.next() ); if ( result != 0) { return result; } } return attributes.size() - that.attributes.size(); } /** * @see Object#toString() */ public String toString() { StringBuilder sb = new StringBuilder(); // first, the Attribute, if it's not default if ( isDefault ) { if ( indexTypes.isEmpty() ) { // No types either ? return a blank String return ""; } sb.append( "default" ); } else { boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( attribute ); } } // A space before the indexTypes sb.append( ' ' ); if ( indexTypes.isEmpty() ) { // No type ? Use default sb.append( "default" ); } else { boolean isFirst = true; for ( DbIndexTypeEnum indexType : indexTypes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( indexType.getName() ); } } return sb.toString(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.config.editor.dialogs.LimitsDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the TimeLimitWrapper class. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LimitsDecorator extends TableDecorator<LimitsWrapper> { /** * Create a new instance of LimitDecorator * @param parentShell The parent Shell */ public LimitsDecorator( Shell parentShell, String title ) { setDialog( new LimitsDialog( parentShell ) ); } /** * Construct the label for a Limit. * */ @Override public String getText( Object element ) { if ( element instanceof LimitWrapper ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( LimitsWrapper e1, LimitsWrapper e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.compareTo( e2 ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/PasswordHashDecorator.java
plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/PasswordHashDecorator.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.openldap.config.editor.wrappers; import org.apache.directory.studio.common.ui.TableDecorator; import org.apache.directory.studio.openldap.common.ui.model.PasswordHashEnum; import org.apache.directory.studio.openldap.config.editor.dialogs.PasswordHashDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; /** * A decorator for the PasswordHash table. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class PasswordHashDecorator extends TableDecorator<PasswordHashEnum> { /** * Create a new instance of PasswordHashDecorator * @param parentShell The parent Shell */ public PasswordHashDecorator( Shell parentShell ) { setDialog( new PasswordHashDialog( parentShell ) ); } /** * Construct the label for a PasswordHash. * */ @Override public String getText( Object element ) { if ( element instanceof PasswordHashEnum ) { return element.toString(); } return super.getText( element ); } /** * Get the image. We have none (may be we could add one for URLs ?) */ @Override public Image getImage( Object element ) { return null; } /** * {@inheritDoc} */ @Override public int compare( PasswordHashEnum e1, PasswordHashEnum e2 ) { if ( e1 != null ) { if ( e2 == null ) { return 1; } else { return e1.getName().compareTo( e2.getName() ); } } else { if ( e2 == null ) { return 0; } else { return 1; } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false