You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2015/06/02 19:01:47 UTC
[3/4] directory-fortress-core git commit: FC-109 - move utils
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/ldap/suffix/Suffix.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/Suffix.java b/src/main/java/org/apache/directory/fortress/core/ldap/suffix/Suffix.java
deleted file mode 100755
index ff8ded7..0000000
--- a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/Suffix.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.fortress.core.ldap.suffix;
-
-
-/**
- * A class storing the suffix information
- */
-public class Suffix
-{
- /** Top level domain component */
- private String dc;
-
- /** top level domain component specifier */
- private String dc2;
-
- /** Second level domain component name */
- private String name;
-
- /** The suffix description */
- private String description;
-
-
- /**
- * Generate instance of suffix to be loaded as domain component ldap object.
- *
- * @param dc top level domain component maps to 'dc' (i.e. 'com') attribute in 'dcObject' object class.
- * @param name second level domain component name maps to attribute in 'dcObject' object class.
- * @param description maps to 'o' attribute in 'dcObject' object class.
- */
- public Suffix( String dc, String name, String description )
- {
- this.dc = dc;
- this.name = name;
- this.description = description;
- }
-
-
- /**
- * Default constructor used by {@link org.apache.directory.fortress.core.ant.FortressAntTask}
- */
- public Suffix()
- {
- }
-
-
- /**
- * Get the second level qualifier on the domain component. This attribute is required.
- *
- * @return name maps to 'dcObject' object class.
- */
- public String getName()
- {
- return name;
- }
-
-
- /**
- * Set the second level qualifier on the domain component. This attribute is required.
- *
- * @param name maps to 'dcObject' object class.
- */
- public void setName( String name )
- {
- this.name = name;
- }
-
-
- /**
- * Get the description for the domain component. This value is not required or constrained
- * but is validated on reasonability.
- *
- * @return field maps to 'o' attribute on 'dcObject'.
- */
- public String getDescription()
- {
- return description;
- }
-
-
- /**
- * Set the description for the domain component. This value is not required or constrained
- * but is validated on reasonability.
- *
- * @param description maps to 'o' attribute on 'dcObject'.
- */
- public void setDescription( String description )
- {
- this.description = description;
- }
-
-
- /**
- * Get top level domain component specifier, i.e. dc=com. This attribute is required.
- *
- * @return dc maps to 'dc' in 'dcObject' object class.
- */
- public String getDc()
- {
- return dc;
- }
-
-
- /**
- * Set top level domain component specifier, i.e. dc=com. This attribute is required.
- *
- * @param dc maps to 'dc' in 'dcObject' object class.
- */
- public void setDc( String dc )
- {
- this.dc = dc;
- }
-
-
- /**
- * Get top level domain component specifier, i.e. dc=com for a three part dc structure. This attribute is optional.
- *
- * @return dc maps to 'dc' in 'dcObject' object class.
- */
- public String getDc2()
- {
- return dc2;
- }
-
-
- /**
- * Get top level domain component specifier, i.e. dc=com for three part dc structure. This attribute is optional.
- *
- */
- public void setDc2( String dc2 )
- {
- this.dc2 = dc2;
- }
-
-
- /**
- * @see Object#toString()
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "Suffix object: \n" );
-
- sb.append( " dc :" ).append( dc ).append( '\n' );
- sb.append( " dc2 :" ).append( dc2 ).append( '\n' );
- sb.append( " name :" ).append( name ).append( '\n' );
- sb.append( " description :" ).append( description ).append( '\n' );
-
- return sb.toString();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixDAO.java b/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixDAO.java
index bd39df1..bd45a25 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixDAO.java
@@ -26,6 +26,7 @@ import org.apache.directory.api.ldap.model.cursor.CursorException;
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.fortress.core.model.Suffix;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.fortress.core.ldap.ApacheDsDataProvider;
import org.slf4j.Logger;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixP.java b/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixP.java
index 1785f66..9b1f537 100755
--- a/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixP.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/suffix/SuffixP.java
@@ -22,22 +22,23 @@ package org.apache.directory.fortress.core.ldap.suffix;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.fortress.core.ValidationException;
+import org.apache.directory.fortress.core.model.Suffix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
/**
* Process module for the suffix or root node of Fortress directory structure. The suffix represents the topmost node in a directory information
- * tree. For example dc=companyName,dc=com. The suffix data is passed using {@link Suffix} class. This class does perform simple data validations.
+ * tree. For example dc=companyName,dc=com. The suffix data is passed using {@link org.apache.directory.fortress.core.model.Suffix} class. This class does perform simple data validations.
* The {@link org.apache.directory.fortress.core.ant.FortressAntTask#addSuffixes()} method calls the {@link #add} from this class during initial base loads.
* Removal {@link org.apache.directory.fortress.core.ant.FortressAntTask#deleteSuffixes()} is performed during regression tests and should never
* be executed targeting production directory systems.<BR>
- * This class will accept {@link Suffix}, and forward on to it's corresponding DAO class {@link SuffixDAO} for add/delete of suffix.
+ * This class will accept {@link org.apache.directory.fortress.core.model.Suffix}, and forward on to it's corresponding DAO class {@link SuffixDAO} for add/delete of suffix.
* <p>
* Class will throw {@link org.apache.directory.fortress.core.SecurityException} to caller in the event of security policy, data constraint violation or system
* error internal to DAO object. This class will forward DAO exceptions ({@link org.apache.directory.fortress.core.FinderException},
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/AdminRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/AdminRole.java b/src/main/java/org/apache/directory/fortress/core/model/AdminRole.java
index 24287fb..47c7970 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/AdminRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/AdminRole.java
@@ -29,7 +29,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.attr.VUtil;
import org.apache.directory.fortress.core.util.time.CUtil;
import org.apache.directory.fortress.core.util.time.Constraint;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/Group.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/Group.java b/src/main/java/org/apache/directory/fortress/core/model/Group.java
new file mode 100755
index 0000000..a268054
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/model/Group.java
@@ -0,0 +1,432 @@
+/*
+ * 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.fortress.core.model;
+
+
+import org.apache.directory.fortress.core.util.attr.AttrHelper;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+
+@XmlRootElement(name = "fortGroup")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "group", propOrder =
+ {
+ "name",
+ "description",
+ "protocol",
+ "members",
+ "props",
+})
+public class Group extends FortEntity implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private String description;
+ private String protocol;
+ private List<String> members;
+ private Props props = new Props();
+ private boolean memberDn;
+
+
+ /**
+ * Default constructor used by {@link org.apache.directory.fortress.core.ant.FortressAntTask}
+ */
+ public Group()
+ {
+ }
+
+
+ /**
+ * Generate instance of group to be loaded as ldap object.
+ *
+ * @param name maps to 'cn' attribute in group object class.
+ */
+ public Group( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Generate instance of group to be loaded as ldap object.
+ *
+ * @param name maps to 'cn' attribute in group object class.
+ * @param description maps to 'description' attribute in group object class.
+ */
+ public Group( String name, String description )
+ {
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Get the second level qualifier on the domain component. This attribute is required.
+ *
+ * @return name maps to 'dcObject' object class.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Set the second level qualifier on the domain component. This attribute is required.
+ *
+ * @param name maps to 'dcObject' object class.
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Get the description for the domain component. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @return field maps to 'o' attribute on 'dcObject'.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Set the description for the domain component. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @param description maps to 'o' attribute on 'dcObject'.
+ */
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Get protocol qualifier for this entity.
+ *
+ * @return protocol.
+ */
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+
+ /**
+ * Set the protocol qualifier for this entity.
+ *
+ * @param protocol contains protocol qualifier for this entity.
+ */
+ public void setProtocol( String protocol )
+ {
+ this.protocol = protocol;
+ }
+
+
+ /**
+ * Add a single userId as member of this entity.
+ *
+ * @param userId
+ */
+ public void setMember( String userId )
+ {
+ if ( members == null )
+ {
+ members = new ArrayList<>();
+ }
+ members.add( userId );
+ }
+
+
+ /**
+ * Return the members
+ *
+ * @return List of type String containing userIds.
+ */
+ public List<String> getMembers()
+ {
+ return members;
+ }
+
+
+ /**
+ * Set a member on this entity using a comma delimited String.
+ *
+ * @param members String contains one or more userids in comma delimited format.
+ */
+ public void setMembers( String members )
+ {
+ if ( members != null )
+ {
+ StringTokenizer tkn = new StringTokenizer( members, "," );
+ if ( tkn.countTokens() > 0 )
+ {
+ while ( tkn.hasMoreTokens() )
+ {
+ String member = tkn.nextToken();
+ setMember( member );
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Set members onto this entity using a List of userIds.
+ *
+ * @param members List of type String contains userIds to be associated as members of this group.
+ */
+ public void setMembers( List<String> members )
+ {
+ this.members = members;
+ }
+
+
+ /**
+ * Add name/value pair to list of properties associated with PermObj. These values are not constrained by Fortress.
+ * Properties are optional.
+ *
+ * @param key contains property name and maps to 'ftProps' attribute in 'ftProperties' aux object class.
+ * @param value
+ */
+ public void addProperty( String key, String value )
+ {
+ Props.Entry entry = new Props.Entry();
+ entry.setKey( key );
+ entry.setValue( value );
+ this.props.getEntry().add( entry );
+ }
+
+
+ /**
+ * Get a name/value pair attribute from list of properties associated with PermObj. These values are not constrained by Fortress.
+ * Properties are optional.
+ *
+ * @param key contains property name and maps to 'ftProps' attribute in 'ftProperties' aux object class.
+ * @return value containing name/value pair that maps to 'ftProps' attribute in 'ftProperties' aux object class.
+ */
+ public String getProperty( String key )
+ {
+ List<Props.Entry> props = this.props.getEntry();
+ Props.Entry keyObj = new Props.Entry();
+ keyObj.setKey( key );
+
+ String value = null;
+ int indx = props.indexOf( keyObj );
+ if ( indx != -1 )
+ {
+ Props.Entry entry = props.get( props.indexOf( keyObj ) );
+ value = entry.getValue();
+ }
+
+ return value;
+ }
+
+
+ /**
+ * Replace teh collection of name/value pairs to attributes associated with Group entity. These values are not constrained by Fortress.
+ * Properties are optional.
+ *
+ * @param properties contains collection of name/value pairs and maps to 'ftProps' attribute in 'ftProperties' aux object class.
+ */
+ public void setProperties( Properties properties )
+ {
+ if ( properties != null )
+ {
+ // reset the existing properties stored in this entity.
+ props = new Props();
+
+ for ( Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); )
+ {
+ // This LDAP attr is stored as a name-value pair separated by a ':'.
+ String key = ( String ) e.nextElement();
+ String val = properties.getProperty( key );
+ addProperty( key, val );
+ }
+ }
+ }
+
+
+ /**
+ * Add new collection of name=value pairs to attributes associated with Group. These values are not constrained by Fortress.
+ * Properties are optional.
+ *
+ * @param properties contains name=value pairs that are comma delmited.
+ */
+ public void setProperties( String properties )
+ {
+ setProperties( AttrHelper.getProperties( properties, '=', "," ) );
+ }
+
+
+ /**
+ * Return the collection of name/value pairs to attributes associated with PermObj. These values are not constrained by Fortress.
+ * Properties are optional.
+ *
+ * @return Properties contains collection of name/value pairs and maps to 'ftProps' attribute in 'ftProperties' aux object class.
+ */
+ public Properties getProperties()
+ {
+ Properties properties = null;
+ List<Props.Entry> props = this.props.getEntry();
+ if ( props.size() > 0 )
+ {
+ properties = new Properties();
+ for ( Props.Entry entry : props )
+ {
+ String key = entry.getKey();
+ String val = entry.getValue();
+ properties.setProperty( key, val );
+ }
+ }
+ return properties;
+ }
+
+
+ public List<String> getPropList()
+ {
+ List<Props.Entry> props = this.props.getEntry();
+ List<String> propList = null;
+ if ( props.size() > 0 )
+ {
+ propList = new ArrayList<>();
+ for ( Props.Entry entry : props )
+ {
+ String key = entry.getKey();
+ String val = entry.getValue();
+ String prop = key + "=" + val;
+ propList.add( prop );
+ }
+ }
+ return propList;
+ }
+
+
+ /**
+ * Gets the value of the Props property. This method is used by Fortress and En Masse and should not be called by external programs.
+ *
+ * @return {@link Props }
+ *
+ */
+ public Props getProps()
+ {
+ return props;
+ }
+
+
+ /**
+ * Sets the value of the Props property. This method is used by Fortress and En Masse and should not be called by external programs.
+ *
+ * @param props
+ * allowed object is
+ * {@link Props }
+ *
+ */
+ public void setProps( Props props )
+ {
+ this.props = props;
+ }
+
+
+ /**
+ * Set if userDn's are loaded in dn format.
+ *
+ * @return true indicates members are in dn format.
+ */
+ public boolean isMemberDn()
+ {
+ return memberDn;
+ }
+
+
+ /**
+ * Set to 'true' if members are in dn format.
+ *
+ * @param memberDn boolean value, set to 'true' if distinguished name (dn) format, 'false' if relative distinguished name (rdn) format.
+ */
+ public void setMemberDn( boolean memberDn )
+ {
+ this.memberDn = memberDn;
+ }
+
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ Group group = ( Group ) o;
+
+ if ( name == null )
+ {
+ return false;
+ }
+
+ if ( !name.equals( group.name ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public int hashCode()
+ {
+ int result = name.hashCode();
+ result = 31 * result + ( description != null ? description.hashCode() : 0 );
+ result = 31 * result + ( protocol != null ? protocol.hashCode() : 0 );
+ result = 31 * result + ( members != null ? members.hashCode() : 0 );
+ result = 31 * result + ( props != null ? props.hashCode() : 0 );
+ return result;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "Group{" +
+ "name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java b/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
index 05fba58..72d3850 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/ObjectFactory.java
@@ -20,8 +20,6 @@
package org.apache.directory.fortress.core.model;
-import org.apache.directory.fortress.core.ldap.group.Group;
-
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
@@ -336,7 +334,7 @@ public class ObjectFactory
/**
- * Create an instance of {@link JAXBElement }{@code <}{@link org.apache.directory.fortress.core.ldap.group.Group }{@code >}}
+ * Create an instance of {@link JAXBElement }{@code <}{@link Group }{@code >}}
*/
@XmlElementDecl(namespace = "", name = "fortGroup")
public JAXBElement<Group> createFortGroup( Group value )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/OrganizationalUnit.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/OrganizationalUnit.java b/src/main/java/org/apache/directory/fortress/core/model/OrganizationalUnit.java
new file mode 100755
index 0000000..6ddcb23
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/model/OrganizationalUnit.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.core.model;
+
+
+/**
+ * This class contains the container node for the OpenLDAP Directory Information Tree. A container node is used to
+ * group other related nodes, i.e. 'ou=People' or 'ou'Roles'.
+ * <br />The organizational unit object class is 'organizationalUnit' <br />
+ * <p/>
+ * organizational unit structural object class is used to organize groups of nodes within the DIT.
+ * <ul>
+ * <li> ------------------------------------------
+ * <li> <code>#Standard object class from RFC2256</code>
+ * <li> <code>objectclass ( 2.5.6.5 NAME 'organizationalUnit'</code>
+ * <li> <code>DESC 'RFC2256: an organizational unit'</code>
+ * <li> <code>SUP top STRUCTURAL</code>
+ * <li> <code>MUST ou</code>
+ * <li> <code>MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $</code>
+ * <li> <code>x121Address $ registeredAddress $ destinationIndicator $</code>
+ * <li> <code>preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $</code>
+ * <li> <code>telephoneNumber $ internationaliSDNNumber $</code>
+ * <li> <code>facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $</code>
+ * <li> <code>postalAddress $ physicalDeliveryOfficeName $ st $ l $ description ) )</code>
+ * <li> ------------------------------------------
+ * </ul>
+ * <p/>
+
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OrganizationalUnit
+{
+ private String name;
+ private String parent;
+ private String description;
+ private String contextId = "";
+
+
+ public String getContextId()
+ {
+ return this.contextId;
+ }
+
+
+ public void setContextId( String contextId )
+ {
+ this.contextId = contextId;
+ }
+
+
+ /**
+ * Generate instance of organizational unit object to be loaded as container node.
+ *
+ * @param name required attribute must be unique for rDn level and maps to 'ou' attribute in 'organizationalUnit' object class.
+ * @param description maps optional attribute maps to name in 'organizationalUnit' object class.
+ */
+ public OrganizationalUnit( String name, String description )
+ {
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Default constructor generates instance of organizational unit object to be loaded as container node.
+ * The object cannot be used until 'name' value is set.
+ */
+ public OrganizationalUnit()
+ {
+ }
+
+
+ /**
+ * Get the required name attribute from the entity. This attribute must be unique for the level of tree it is
+ * set.
+ *
+ * @return required attribute must be unique for rDn level and maps to 'ou' attribute in 'organizationalUnit' object class.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Set the required name attribute in the entity. This attribute must be unique for the level of tree it is
+ * set.
+ *
+ * @param name is required attribute and must be unique for rDn level and maps to 'ou' attribute in 'organizationalUnit' object class.
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Get the description for the organizational unit object. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @return field maps to same name attribute on 'organizationalUnit'.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Set the description for the organizational unit object. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @param description field maps to same name attribute on 'organizationalUnit'.
+ */
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Get the optional parent attribute allows nesting of container nodes two levels below suffix. For example, if parent
+ * node is created it may be used to subdivide collections of related nodes, dn=ou=Roles, ou=RBAC, dc=companyName, dc=com.
+ *
+ * @return attribute that contains name of parent node that is used to construct the dn.
+ */
+ public String getParent()
+ {
+ return parent;
+ }
+
+
+ /**
+ * Set the optional parent attribute allows nesting of container nodes two levels below suffix. For example, if parent
+ * node is created it may be used to subdivide collections of related nodes, dn=ou=Roles, ou=RBAC, dc=companyName, dc=com.
+ *
+ * @param parent attribute that contains name of parent node that is used to construct the dn. This maps to 'ou'
+ * attribute in parent node's 'organizationalUnit' object class.
+ */
+ public void setParent( String parent )
+ {
+ this.parent = parent;
+ }
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "OrganizationalUnit[" );
+ sb.append( name ).append( ", " );
+ sb.append( description ).append( ", " );
+ sb.append( parent ).append( ", " );
+ sb.append( contextId ).append( ']' );
+
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/RegExUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/RegExUtil.java b/src/main/java/org/apache/directory/fortress/core/model/RegExUtil.java
new file mode 100755
index 0000000..8aba97e
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/model/RegExUtil.java
@@ -0,0 +1,87 @@
+/*
+ * 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.fortress.core.model;
+
+
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.ValidationException;
+import org.apache.directory.fortress.core.util.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * Regular expression utilities to perform data validations on Fortress attributes. These utils use the standard
+ * java regular expression library.
+ *
+ * @author Shawn McKinney
+ */
+final class RegExUtil
+{
+ private static final String CLS_NM = RegExUtil.class.getName();
+ private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static final String SAFE_TEXT_PATTERN_STRING = Config.getProperty( GlobalIds.REG_EX_SAFE_TEXT );
+ private static Pattern safeTextPattern;
+
+ static
+ {
+ if ( ( SAFE_TEXT_PATTERN_STRING != null ) && ( SAFE_TEXT_PATTERN_STRING.length() != 0 ) )
+ {
+ safeTextPattern = Pattern.compile( SAFE_TEXT_PATTERN_STRING );
+ }
+ }
+
+ /**
+ * Private constructor
+ *
+ */
+ private RegExUtil()
+ {
+ }
+
+ /**
+ * Perform safe text validation on character string.
+ *
+ * @param value Contains the string to check.
+ * @exception org.apache.directory.fortress.core.ValidationException In the event the data validation fails.
+ */
+ public static void safeText( String value ) throws ValidationException
+ {
+ if ( Strings.isEmpty( SAFE_TEXT_PATTERN_STRING ) )
+ {
+ LOG.debug( "safeText can't find safeText regular expression pattern. Check your Fortress cfg" );
+ }
+ else
+ {
+ Matcher safeTextMatcher = safeTextPattern.matcher( value );
+
+ if ( !safeTextMatcher.find() )
+ {
+ String error = "safeText has detected invalid value [" + value + "]";
+ throw new ValidationException( GlobalErrIds.CONST_INVLD_TEXT, error );
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/Suffix.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/Suffix.java b/src/main/java/org/apache/directory/fortress/core/model/Suffix.java
new file mode 100755
index 0000000..ce73eb8
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/model/Suffix.java
@@ -0,0 +1,170 @@
+/*
+ * 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.fortress.core.model;
+
+
+/**
+ * A class storing the suffix information
+ */
+public class Suffix
+{
+ /** Top level domain component */
+ private String dc;
+
+ /** top level domain component specifier */
+ private String dc2;
+
+ /** Second level domain component name */
+ private String name;
+
+ /** The suffix description */
+ private String description;
+
+
+ /**
+ * Generate instance of suffix to be loaded as domain component ldap object.
+ *
+ * @param dc top level domain component maps to 'dc' (i.e. 'com') attribute in 'dcObject' object class.
+ * @param name second level domain component name maps to attribute in 'dcObject' object class.
+ * @param description maps to 'o' attribute in 'dcObject' object class.
+ */
+ public Suffix( String dc, String name, String description )
+ {
+ this.dc = dc;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Default constructor used by {@link org.apache.directory.fortress.core.ant.FortressAntTask}
+ */
+ public Suffix()
+ {
+ }
+
+
+ /**
+ * Get the second level qualifier on the domain component. This attribute is required.
+ *
+ * @return name maps to 'dcObject' object class.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Set the second level qualifier on the domain component. This attribute is required.
+ *
+ * @param name maps to 'dcObject' object class.
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Get the description for the domain component. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @return field maps to 'o' attribute on 'dcObject'.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Set the description for the domain component. This value is not required or constrained
+ * but is validated on reasonability.
+ *
+ * @param description maps to 'o' attribute on 'dcObject'.
+ */
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Get top level domain component specifier, i.e. dc=com. This attribute is required.
+ *
+ * @return dc maps to 'dc' in 'dcObject' object class.
+ */
+ public String getDc()
+ {
+ return dc;
+ }
+
+
+ /**
+ * Set top level domain component specifier, i.e. dc=com. This attribute is required.
+ *
+ * @param dc maps to 'dc' in 'dcObject' object class.
+ */
+ public void setDc( String dc )
+ {
+ this.dc = dc;
+ }
+
+
+ /**
+ * Get top level domain component specifier, i.e. dc=com for a three part dc structure. This attribute is optional.
+ *
+ * @return dc maps to 'dc' in 'dcObject' object class.
+ */
+ public String getDc2()
+ {
+ return dc2;
+ }
+
+
+ /**
+ * Get top level domain component specifier, i.e. dc=com for three part dc structure. This attribute is optional.
+ *
+ */
+ public void setDc2( String dc2 )
+ {
+ this.dc2 = dc2;
+ }
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "Suffix object: \n" );
+
+ sb.append( " dc :" ).append( dc ).append( '\n' );
+ sb.append( " dc2 :" ).append( dc2 ).append( '\n' );
+ sb.append( " name :" ).append( name ).append( '\n' );
+ sb.append( " description :" ).append( description ).append( '\n' );
+
+ return sb.toString();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/model/VUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/VUtil.java b/src/main/java/org/apache/directory/fortress/core/model/VUtil.java
new file mode 100755
index 0000000..93b6855
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/model/VUtil.java
@@ -0,0 +1,605 @@
+/*
+ * 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.fortress.core.model;
+
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.fortress.core.util.ObjUtil;
+import org.slf4j.LoggerFactory;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.ValidationException;
+import org.apache.directory.fortress.core.util.Config;
+
+
+/**
+ * This class contains simple data validation utilities. The data validations include null, length
+ * and simple reasonability checking. All utilities will throw {@link ValidationException} for failures.
+ */
+public final class VUtil
+{
+ private static final String CLS_NM = VUtil.class.getName();
+ private static final org.slf4j.Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static int maximumFieldLen = 130;
+ private static final String VALIDATE_LENGTH = "field.length";
+
+ static
+ {
+ String lengthProp = Config.getProperty( VALIDATE_LENGTH );
+ try
+ {
+ if ( lengthProp != null )
+ {
+ Integer len = Integer.valueOf( lengthProp );
+ maximumFieldLen = len;
+ }
+ }
+ catch ( java.lang.NumberFormatException nfe )
+ {
+ //ignore
+ }
+ }
+
+ private static final int MAXIMUM_FIELD_LEN = maximumFieldLen;
+ private static final int maxFieldLength = MAXIMUM_FIELD_LEN;
+ private static final int TIME_LEN = 4;
+ private static final int DATE_LEN = 8;
+ private static final int DAYMASK_LEN = 7;
+ private static final String TIME_FORMAT = "HHmm";
+ private static final String DATE_FORMAT = "yyyyMMdd";
+ private static final char SUNDAY = '1';
+ private static final char SATURDAY = '7';
+ private static final SimpleDateFormat TIME_FORMATER = new SimpleDateFormat( TIME_FORMAT );
+ private static final SimpleDateFormat DATE_FORMATER = new SimpleDateFormat( DATE_FORMAT );
+
+ static
+ {
+ String lengthProp = Config.getProperty( VALIDATE_LENGTH );
+
+ if ( lengthProp != null )
+ {
+ maximumFieldLen = Integer.parseInt( lengthProp );
+ }
+
+ TIME_FORMATER.setLenient( false );
+ DATE_FORMATER.setLenient( false );
+ }
+
+ /**
+ * Private constructor
+ *
+ */
+ private VUtil()
+ {
+ }
+
+ /**
+ * Simple length check on orgunit that uses {@link org.apache.directory.fortress.core.GlobalIds#OU_LEN}.
+ *
+ * @param orgUnitId contains the ou name.
+ * @throws ValidationException in the event of failure, {@link org.apache.directory.fortress.core.GlobalErrIds#ORG_LEN_INVLD}.
+ */
+ public static void orgUnit( String orgUnitId ) throws ValidationException
+ {
+ if ( !StringUtils.isNotEmpty( orgUnitId ) )
+ {
+ String error = "orgUnit is null";
+ throw new ValidationException( GlobalErrIds.ORG_NULL, error );
+ }
+ int length = orgUnitId.length();
+
+ if ( length > maxFieldLength )
+ {
+ String error = "orgUnit value [" + orgUnitId + "] invalid length [" + length + "]";
+ throw new ValidationException( GlobalErrIds.ORG_LEN_INVLD, error );
+ }
+ }
+
+
+ /**
+ * Simple length check on User password that uses {@link org.apache.directory.fortress.core.GlobalIds#PASSWORD_LEN}.
+ * @param password contains the User's password.
+ * @throws ValidationException in the event of failure, {@link org.apache.directory.fortress.core.GlobalErrIds#USER_PW_INVLD_LEN}.
+ */
+ public static void password( char[] password ) throws ValidationException
+ {
+ int length = password.length;
+
+ if ( length > GlobalIds.PASSWORD_LEN )
+ {
+ String error = "password invalid length [" + length + "]";
+ throw new ValidationException( GlobalErrIds.USER_PW_INVLD_LEN, error );
+ }
+ }
+
+
+ /**
+ * Simple length check and safe text validation on description field that uses {@link org.apache.directory.fortress.core.GlobalIds#DESC_LEN}.
+ *
+ * @param value contains the entity description.
+ * @throws org.apache.directory.fortress.core.ValidationException
+ * in the event of failure, {@link org.apache.directory.fortress.core.GlobalErrIds#CONST_DESC_LEN_INVLD}.
+ */
+ public static void description( String value ) throws ValidationException
+ {
+ int length = value.length();
+
+ if ( length > GlobalIds.DESC_LEN )
+ {
+ String error = "description value [" + value + "] invalid length [" + length + "]";
+ throw new ValidationException( GlobalErrIds.CONST_DESC_LEN_INVLD, error );
+ }
+
+ RegExUtil.safeText( value );
+ }
+
+
+ /**
+ * Perform a simple length and safe text validation.
+ *
+ * @param value contains the attribute to check.
+ * @param validLen contains the length to use.
+ * @throws ValidationException in the event of length {@link org.apache.directory.fortress.core.GlobalErrIds#CONST_INVLD_FIELD_LEN} or regex failure.
+ */
+ public static void safeText( String value, int validLen ) throws ValidationException
+ {
+ if ( !StringUtils.isNotEmpty( value ) )
+ {
+ String error = "safeText null value";
+ throw new ValidationException( GlobalErrIds.CONST_NULL_TEXT, error );
+ }
+
+ int length = value.length();
+
+ if ( length > validLen )
+ {
+ String error = "safeText value [" + value + "] invalid length [" + length + "]";
+ throw new ValidationException( GlobalErrIds.CONST_INVLD_FIELD_LEN, error );
+ }
+
+ RegExUtil.safeText( value );
+ }
+
+
+ /**
+ * Simple null, {@link org.apache.directory.fortress.core.GlobalErrIds#USER_ID_NULL}, and length checks, {@link org.apache.directory.fortress.core.GlobalErrIds#CONST_INVLD_FIELD_LEN}, on userId.
+ *
+ * @param userId contains the userId, maps to {@link org.apache.directory.fortress.core.model.User#userId}.
+ * @throws ValidationException in the event of failure, {@link GlobalErrIds#CONST_INVLD_FIELD_LEN}.
+ */
+ public static void userId( String userId ) throws ValidationException
+ {
+ if ( !StringUtils.isNotEmpty( userId ) )
+ {
+ String error = "userId validation failed, null or empty value";
+ throw new ValidationException( GlobalErrIds.USER_ID_NULL, error );
+ }
+
+ int length = userId.length();
+
+ if ( length > GlobalIds.USERID_LEN )
+ {
+ String error = "safeText value [" + userId + "] invalid length [" + length + "]";
+ throw new ValidationException( GlobalErrIds.CONST_INVLD_FIELD_LEN, error );
+ }
+ }
+
+
+ /**
+ * Perform simple length and safe text validations on collection of name-value pairs.
+ *
+ * @param props contains name-value pairs in {@code name:value} format.
+ * @throws ValidationException in the event of failure.
+ */
+ public static void properties( Properties props ) throws ValidationException
+ {
+ if ( ObjUtil.isNotNullOrEmpty( props ) )
+ {
+ for ( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); )
+ {
+ String key = ( String ) e.nextElement();
+ String val = props.getProperty( key );
+ safeText( key, GlobalIds.PROP_LEN );
+ safeText( val, GlobalIds.PROP_LEN );
+ }
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint timeout value.
+ *
+ * @param timeout must be greater than 0 and less than max value for {@link Integer#MAX_VALUE}
+ * @throws org.apache.directory.fortress.core.ValidationException
+ * in the event value falls out of range.
+ */
+ public static void timeout( Integer timeout ) throws ValidationException
+ {
+ if ( ( timeout < 0 ) || ( timeout >= Integer.MAX_VALUE ) )
+ {
+ String error = "timeout - invalid timeout value [" + timeout + "]";
+ throw new ValidationException( GlobalErrIds.CONST_TIMEOUT_INVLD, error );
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint beginTime value.
+ *
+ * @param beginTime if set, must be equal to {@link #TIME_LEN}.
+ * @throws org.apache.directory.fortress.core.ValidationException
+ * in the event value falls out of range.
+ */
+ public static void beginTime( String beginTime ) throws ValidationException
+ {
+ if ( ( beginTime != null ) && ( beginTime.length() == TIME_LEN ) )
+ {
+ if ( checkTime( beginTime ) )
+ {
+ String error = "beginTime - invalid beginTime value [" + beginTime + "]";
+ throw new ValidationException( GlobalErrIds.CONST_BEGINTIME_INVLD, error );
+ }
+ }
+ else
+ {
+ String error = "beginTime - null or invalid length (must be 4) for beginTime value";
+ throw new ValidationException( GlobalErrIds.CONST_BEGINTIME_LEN_ERR, error );
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint endTime value.
+ * @param endTime if set, must be equal to {@link #TIME_LEN}.
+ * @throws ValidationException in the event value falls out of range.
+ */
+ public static void endTime( String endTime ) throws ValidationException
+ {
+ if ( ( endTime != null ) && ( endTime.length() == TIME_LEN ) )
+ {
+ if ( checkTime( endTime ) )
+ {
+ String error = "endTime - invalid endTime value [" + endTime + "]";
+ throw new ValidationException( GlobalErrIds.CONST_ENDTIME_INVLD, error );
+ }
+ }
+ else
+ {
+ String error = "endTime - null or invalid length (must be 4) for endTime value";
+ throw new ValidationException( GlobalErrIds.CONST_ENDTIME_LEN_ERR, error );
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint beginDate value.
+ * @param beginDate if set, must be equal to {@link #DATE_LEN}.
+ * @throws ValidationException in the event value falls out of range.
+ */
+ public static void beginDate( String beginDate )
+ throws ValidationException
+ {
+ if ( StringUtils.isNotEmpty( beginDate ) )
+ {
+ if ( ( beginDate.compareToIgnoreCase( GlobalIds.NONE ) != 0 ) &&
+ ( ( beginDate.length() != DATE_LEN ) || checkDate( beginDate ) ) )
+ {
+ String error = "beginDate - invalid beginDate value [" + beginDate + "]";
+ throw new ValidationException( GlobalErrIds.CONST_BEGINDATE_INVLD, error );
+ }
+ }
+ else
+ {
+ String error = "beginDate - null or empty beginDate value";
+ throw new ValidationException( GlobalErrIds.CONST_BEGINDATE_NULL, error );
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint endDate value.
+ * @param endDate if set, must be equal to {@link #DATE_LEN}.
+ * @throws ValidationException in the event value falls out of range.
+ */
+ public static void endDate( String endDate ) throws ValidationException
+ {
+ if ( StringUtils.isNotEmpty( endDate ) )
+ {
+ if ( endDate.compareToIgnoreCase( GlobalIds.NONE ) != 0 )
+ {
+ if ( endDate.length() != DATE_LEN || checkDate( endDate ) )
+ {
+ String error = "endDate - invalid endDate value [" + endDate + "]";
+ throw new ValidationException( GlobalErrIds.CONST_ENDDATE_INVLD, error );
+ }
+ }
+ }
+ else
+ {
+ String error = "endDate - null or empty endDate value";
+ throw new ValidationException( GlobalErrIds.CONST_ENDDATE_NULL, error );
+ }
+ }
+
+
+ /**
+ * Perform simple reasonability check on contraint dayMask value.
+ * @param dayMask if set, will be validated.
+ * @throws ValidationException in the event value falls out of range.
+ */
+ public static void dayMask( String dayMask ) throws ValidationException
+ {
+ if ( StringUtils.isNotEmpty( dayMask ) )
+ {
+ if ( dayMask.compareToIgnoreCase( GlobalIds.ALL ) != 0 )
+ {
+ if ( dayMask.length() > DAYMASK_LEN || checkMask( dayMask ) )
+ {
+ String error = "dayMask - invalid dayMask value [" + dayMask + "]";
+ throw new ValidationException( GlobalErrIds.CONST_DAYMASK_INVLD, error );
+ }
+ }
+ }
+ else
+ {
+ String error = "dayMask - null or empty dayMask value";
+ throw new ValidationException( GlobalErrIds.CONST_DAYMASK_NULL, error );
+ }
+ }
+
+
+ /**
+ * @param time
+ * @return boolean
+ */
+ private static boolean checkTime( String time )
+ {
+ try
+ {
+ synchronized ( TIME_FORMATER )
+ {
+ TIME_FORMATER.parse( time );
+ return false;
+ }
+ }
+ catch ( ParseException pe )
+ {
+ String error = "checkTime - time [" + time + "] failed validation with ParseException=" + pe;
+ LOG.warn( error );
+ return true;
+ }
+ }
+
+
+ /**
+ * @param date
+ * @return boolean
+ */
+ private static boolean checkDate( String date )
+ {
+ try
+ {
+ synchronized ( DATE_FORMATER )
+ {
+ DATE_FORMATER.parse( date );
+ return false;
+ }
+ }
+ catch ( ParseException pe )
+ {
+ String error = "checkDate - date [" + date + "] failed validation with ParseException=" + pe;
+ LOG.warn( error );
+
+ return true;
+ }
+ }
+
+
+ /**
+ * @param mask
+ * @return boolean
+ */
+ private static boolean checkMask( String mask )
+ {
+ for ( char c : mask.toCharArray() )
+ {
+ if ( ( c < SUNDAY ) || ( c > SATURDAY ) )
+ {
+ String error = "checkMask - mask [" + mask + "] failed validation";
+ LOG.warn( error );
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Method will throw exception with supplied error id and object.method name if object reference is null.
+ *
+ * @param obj contains the reference to check.
+ * @param errorCode contains the error id to use if null.
+ * @param method contains the method name of caller.
+ * @throws ValidationException in the event object is null.
+ */
+ public static void assertNotNull( Object obj, int errorCode, String method )
+ throws ValidationException
+ {
+ if ( obj == null )
+ {
+ String error = "assertContext detected null entity for method [" + method + "], error code ["
+ + errorCode + "]";
+ throw new ValidationException( errorCode, error );
+ }
+ }
+
+
+ /**
+ * Method will throw exception with supplied error id and object.method name if string reference is null or empty.
+ *
+ * @param value contains the reference to check.
+ * @param errorCode contains the error id to use if null.
+ * @param method contains the method name of caller.
+ * @throws ValidationException in the event supplied string is null or empty.
+ */
+ public static void assertNotNullOrEmpty( String value, int errorCode, String method )
+ throws ValidationException
+ {
+ if ( !StringUtils.isNotEmpty( value ) )
+ {
+ String error = "assertContext detected null entity for method [" + method + "], error code ["
+ + errorCode + "]";
+ throw new ValidationException( errorCode, error );
+ }
+ }
+
+
+ /**
+ * Method will throw exception with supplied error id and object.method name if string reference is null or empty.
+ *
+ * @param value contains the reference to check.
+ * @param errorCode contains the error id to use if null.
+ * @param method contains the method name of caller.
+ * @throws ValidationException in the event supplied string is null or empty.
+ */
+ public static void assertNotNullOrEmpty( char[] value, int errorCode, String method )
+ throws ValidationException
+ {
+ if ( !ObjUtil.isNotNullOrEmpty( value ) )
+ {
+ String error = "assertContext detected null entity for method [" + method + "], error code ["
+ + errorCode + "]";
+ throw new ValidationException( errorCode, error );
+ }
+ }
+
+
+/*
+ */
+/**
+ * Method will return true if string array reference is not null or empty.
+ *
+ * @param value contains the reference to string array.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( String[] value )
+ {
+ return ( value != null ) && ( value.length > 0 );
+ }
+
+
+ */
+/**
+ * Method will return true if string reference is not null or empty.
+ *
+ * @param value contains the reference to string.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( char[] value )
+ {
+ return ( value != null ) && ( value.length > 0 );
+ }
+
+
+ */
+/**
+ * Method will return true if list is not null or empty.
+ *
+ * @param list contains the reference to list.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( Collection<?> list )
+ {
+ return ( list != null ) && ( list.size() > 0 );
+ }
+
+
+ */
+/**
+ * Method will return true if props is not null or empty.
+ *
+ * @param props contains the reference to props.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( Properties props )
+ {
+ return ( props != null ) && ( props.size() > 0 );
+ }
+
+
+ */
+/**
+ * Method will return true if input is not null or empty.
+ *
+ * @param iVal contains the reference to Integer variable.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( Integer iVal )
+ {
+ return ( iVal != null );
+ }
+
+
+ */
+/**
+ * Method will return true if input is not null or empty.
+ *
+ * @param bVal contains the reference to Boolean variable.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( Boolean bVal )
+ {
+ return ( bVal != null );
+ }
+
+
+ */
+/**
+ * Method will return true if byte array reference is not null or empty.
+ *
+ * @param value contains the reference to byte array.
+ * @return boolean if validation succeeds.
+ *//*
+
+ public static boolean isNotNullOrEmpty( byte[] value )
+ {
+ boolean result = false;
+ if ( value != null && value.length > 0 )
+ {
+ result = true;
+ }
+ return result;
+ }
+*/
+}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AccelMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AccelMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/AccelMgrImpl.java
index 6ca83ae..a823468 100644
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AccelMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AccelMgrImpl.java
@@ -29,7 +29,7 @@ import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AcceleratorDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AcceleratorDAO.java b/src/main/java/org/apache/directory/fortress/core/rbac/AcceleratorDAO.java
index 8b0ebd2..be782c8 100644
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AcceleratorDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AcceleratorDAO.java
@@ -28,6 +28,7 @@ import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.openldap.accelerator.api.addRole.RbacAddRoleRequest;
import org.openldap.accelerator.api.addRole.RbacAddRoleRequestImpl;
import org.openldap.accelerator.api.addRole.RbacAddRoleResponse;
@@ -50,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.ldap.ApacheDsDataProvider;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
import java.util.ArrayList;
@@ -103,7 +104,7 @@ final class AcceleratorDAO extends ApacheDsDataProvider
rbacCreateSessionRequest.setUserIdentity( user.getUserId() );
rbacCreateSessionRequest.setPassword( new String( user.getPassword() ) );
- if ( VUtil.isNotNullOrEmpty( user.getRoles() ) )
+ if ( ObjUtil.isNotNullOrEmpty( user.getRoles() ) )
{
for ( UserRole userRole : user.getRoles() )
{
@@ -371,7 +372,7 @@ final class AcceleratorDAO extends ApacheDsDataProvider
sessionRolesRequest );
LOG.debug( "sessionRoles result: {}", sessionRolesResponse.getLdapResult().getResultCode().getResultCode() );
- if ( VUtil.isNotNullOrEmpty( sessionRolesResponse.getRoles() ) )
+ if ( ObjUtil.isNotNullOrEmpty( sessionRolesResponse.getRoles() ) )
{
userRoleList = new ArrayList<UserRole>();
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AccessMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AccessMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/AccessMgrImpl.java
index ed49b11..406b919 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AccessMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AccessMgrImpl.java
@@ -30,7 +30,8 @@ import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.apache.directory.fortress.core.util.time.CUtil;
@@ -307,7 +308,7 @@ public class AccessMgrImpl extends Manageable implements AccessMgr
uRoles = ue.getRoles();
int indx;
// Is the role activation target valid for this user?
- if ( !VUtil.isNotNullOrEmpty( uRoles ) || ( ( indx = uRoles.indexOf( role ) ) == -1 ) )
+ if ( !ObjUtil.isNotNullOrEmpty( uRoles ) || ( ( indx = uRoles.indexOf( role ) ) == -1 ) )
{
String info = getFullMethodName( CLS_NM, methodName ) + " Role [" + role.getName() + "] User ["
+ session.getUserId() + "] role not authorized for user.";
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/AdminMgrImpl.java
index 1836eb2..89b7de4 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AdminMgrImpl.java
@@ -32,6 +32,7 @@ import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.SDSet;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import org.apache.directory.fortress.core.util.time.CUtil;
@@ -1149,7 +1150,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr
cRole2.setContextId( this.contextId );
setAdminData( CLS_NM, methodName, cRole2 );
// are there any parents left?
- if ( !VUtil.isNotNullOrEmpty( cRole2.getParents() ) )
+ if ( !ObjUtil.isNotNullOrEmpty( cRole2.getParents() ) )
{
// The updates only update non-empty multi-occurring attributes
// so if last parent assigned, so must remove the attribute completely:
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleDAO.java b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleDAO.java
index 2535dd5..d6fa79f 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleDAO.java
@@ -47,7 +47,8 @@ import org.apache.directory.fortress.core.ldap.ApacheDsDataProvider;
import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.Graphable;
import org.apache.directory.fortress.core.model.Role;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.apache.directory.fortress.core.util.time.CUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -226,7 +227,7 @@ final class AdminRoleDAO extends ApacheDsDataProvider
SchemaConstants.DESCRIPTION_AT, entity.getDescription() ) );
}
- if ( VUtil.isNotNullOrEmpty( entity.getOccupants() ) )
+ if ( ObjUtil.isNotNullOrEmpty( entity.getOccupants() ) )
{
for ( String name : entity.getOccupants() )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
index dad532b..fb0269b 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
@@ -28,6 +28,7 @@ import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.Graphable;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.UserAdminRole;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +37,7 @@ import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
/**
@@ -218,7 +219,7 @@ public final class AdminRoleP
void addOccupant( List<UserAdminRole> uRoles, String userDn, String contextId )
throws SecurityException
{
- if ( VUtil.isNotNullOrEmpty( uRoles ) )
+ if ( ObjUtil.isNotNullOrEmpty( uRoles ) )
{
for ( UserAdminRole uRole : uRoles )
{
@@ -392,12 +393,12 @@ public final class AdminRoleP
VUtil.endDate( entity.getEndLockDate() );
}
- if ( VUtil.isNotNullOrEmpty( entity.getOsU() ) )
+ if ( ObjUtil.isNotNullOrEmpty( entity.getOsU() ) )
{
validateOrgs( entity.getOsU(), OrgUnit.Type.USER, entity.getContextId() );
}
- if ( VUtil.isNotNullOrEmpty( entity.getOsP() ) )
+ if ( ObjUtil.isNotNullOrEmpty( entity.getOsP() ) )
{
validateOrgs( entity.getOsP(), OrgUnit.Type.PERM, entity.getContextId() );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleUtil.java b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleUtil.java
index 65df532..d73a301 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleUtil.java
@@ -31,13 +31,14 @@ import org.apache.directory.fortress.core.model.Graphable;
import org.apache.directory.fortress.core.model.Hier;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.model.UserAdminRole;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.jgrapht.graph.SimpleDirectedGraph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.ValidationException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import org.apache.directory.fortress.core.util.cache.Cache;
import org.apache.directory.fortress.core.util.cache.CacheMgr;
@@ -182,7 +183,7 @@ public final class AdminRoleUtil
// create Set with case insensitive comparator:
Set<String> iRoles = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
- if ( VUtil.isNotNullOrEmpty( uRoles ) )
+ if ( ObjUtil.isNotNullOrEmpty( uRoles ) )
{
for ( UserAdminRole uRole : uRoles )
{
@@ -190,7 +191,7 @@ public final class AdminRoleUtil
iRoles.add( rleName );
Set<String> parents = HierUtil.getAscendants( rleName, getGraph( contextId ) );
- if ( VUtil.isNotNullOrEmpty( parents ) )
+ if ( ObjUtil.isNotNullOrEmpty( parents ) )
{
iRoles.addAll( parents );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/DelAccessMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/DelAccessMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/DelAccessMgrImpl.java
index a3f9b89..046397c 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/DelAccessMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/DelAccessMgrImpl.java
@@ -28,8 +28,9 @@ import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.apache.directory.fortress.core.util.time.CUtil;
import java.util.List;
@@ -215,7 +216,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
List<UserAdminRole> uRoles = ue.getAdminRoles();
int indx;
// Is the admin role activation target valid for this user?
- if (!VUtil.isNotNullOrEmpty(uRoles) || ((indx = uRoles.indexOf(role)) == -1))
+ if (!ObjUtil.isNotNullOrEmpty(uRoles) || ((indx = uRoles.indexOf(role)) == -1))
{
String info = getFullMethodName(CLS_NM, methodName) + " Admin Role [" + role.getName() + "] User [" + session.getUserId() + "] adminRole not authorized for user.";
throw new SecurityException(GlobalErrIds.ARLE_ACTIVATE_FAILED, info);
@@ -323,7 +324,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
{
boolean result = false;
List<UserAdminRole> uaRoles = session.getAdminRoles();
- if(VUtil.isNotNullOrEmpty(uaRoles))
+ if(ObjUtil.isNotNullOrEmpty(uaRoles))
{
// validate user and retrieve user' ou:
User ue = userP.read(user, false);
@@ -335,7 +336,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
break;
}
Set<String> osUs = uaRole.getOsU();
- if(VUtil.isNotNullOrEmpty(osUs))
+ if(ObjUtil.isNotNullOrEmpty(osUs))
{
// create Set with case insensitive comparator:
Set<String> osUsFinal = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
@@ -359,7 +360,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
{
range.add(uaRole.getBeginRange());
}
- if(VUtil.isNotNullOrEmpty(range))
+ if(ObjUtil.isNotNullOrEmpty(range))
{
// Does admin role have authority over a role contained with the allowable role range?
if(range.contains(role.getName()))
@@ -395,7 +396,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
{
boolean result = false;
List<UserAdminRole> uaRoles = session.getAdminRoles();
- if(VUtil.isNotNullOrEmpty(uaRoles))
+ if(ObjUtil.isNotNullOrEmpty(uaRoles))
{
// validate perm and retrieve perm's ou:
PermObj inObj = new PermObj(perm.getObjName());
@@ -409,7 +410,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
break;
}
Set<String> osPs = uaRole.getOsP();
- if(VUtil.isNotNullOrEmpty(osPs))
+ if(ObjUtil.isNotNullOrEmpty(osPs))
{
// create Set with case insensitive comparator:
Set<String> osPsFinal = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
@@ -432,7 +433,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr
{
range.add(uaRole.getBeginRange());
}
- if(VUtil.isNotNullOrEmpty(range))
+ if( ObjUtil.isNotNullOrEmpty( range ))
{
// Does admin role have authority over a role contained with the allowable role range?
if(range.contains(role.getName()))
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/DelAdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/DelAdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/DelAdminMgrImpl.java
index aa041d6..ebf4ac7 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/DelAdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/DelAdminMgrImpl.java
@@ -32,9 +32,10 @@ import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.apache.directory.fortress.core.util.attr.AttrHelper;
import org.apache.directory.fortress.core.util.time.CUtil;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import java.util.List;
import java.util.Set;
@@ -199,7 +200,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
AdminRole re = admRP.update(role);
// search for all users assigned this role and update:
List<User> users = userP.getAssignedUsers(role);
- if(VUtil.isNotNullOrEmpty(users))
+ if(ObjUtil.isNotNullOrEmpty(users))
{
final AdminMgr aMgr = AdminMgrFactory.createInstance(this.contextId);
for (User ue : users)
@@ -417,7 +418,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
{
// Ensure the org unit is not assigned to any users, but set the sizeLimit to "true" to limit result set size.
List<User> assignedUsers = userP.search(entity, true);
- if (VUtil.isNotNullOrEmpty(assignedUsers))
+ if (ObjUtil.isNotNullOrEmpty(assignedUsers))
{
String error = methodName + " orgunit [" + entity.getName() + "] must unassign [" + assignedUsers.size() + "] users before deletion";
throw new SecurityException(GlobalErrIds.ORG_DEL_FAILED_USER, error, null);
@@ -428,7 +429,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
// Ensure the org unit is not assigned to any permission objects but set the sizeLimit to "true" to limit result set size..
// pass a "false" which places no restrictions on how many records server returns.
List<PermObj> assignedPerms = permP.search(entity, false);
- if (VUtil.isNotNullOrEmpty(assignedPerms))
+ if (ObjUtil.isNotNullOrEmpty(assignedPerms))
{
String error = methodName + " orgunit [" + entity.getName() + "] must unassign [" + assignedPerms.size() + "] perm objs before deletion";
throw new SecurityException(GlobalErrIds.ORG_DEL_FAILED_PERM, error, null);
@@ -701,7 +702,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
cOrg.delParent(parent.getName());
setAdminData(CLS_NM, methodName, cOrg);
// are there any parents left?
- if(!VUtil.isNotNullOrEmpty(cOrg.getParents()))
+ if(!ObjUtil.isNotNullOrEmpty(cOrg.getParents()))
{
// The updates only update non-empty multi-occurring attributes
// so if last parent assigned, so must remove the attribute completely:
@@ -893,7 +894,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
cRole2.setContextId(this.contextId);
setAdminData(CLS_NM, methodName, cRole2);
// are there any parents left?
- if(!VUtil.isNotNullOrEmpty(cRole2.getParents()))
+ if(!ObjUtil.isNotNullOrEmpty( cRole2.getParents() ))
{
// The updates only update non-empty multi-occurring attributes
// so if last parent assigned, so must remove the attribute completely:
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/DelReviewMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/DelReviewMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/rbac/DelReviewMgrImpl.java
index 12c82e3..d3c6279 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/DelReviewMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/DelReviewMgrImpl.java
@@ -26,7 +26,7 @@ import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/HierUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/HierUtil.java b/src/main/java/org/apache/directory/fortress/core/rbac/HierUtil.java
index 8b8e9bd..a6621ba 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/HierUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/HierUtil.java
@@ -32,13 +32,14 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.directory.fortress.core.model.Graphable;
import org.apache.directory.fortress.core.model.Hier;
import org.apache.directory.fortress.core.model.Relationship;
+import org.apache.directory.fortress.core.util.ObjUtil;
import org.jgrapht.graph.SimpleDirectedGraph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.ValidationException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
/**
@@ -693,13 +694,13 @@ final class HierUtil
static Hier loadHier( String contextId, List<Graphable> descendants )
{
Hier hier = new Hier();
- if ( VUtil.isNotNullOrEmpty( descendants ) )
+ if ( ObjUtil.isNotNullOrEmpty( descendants ) )
{
hier.setContextId( contextId );
for ( Graphable descendant : descendants )
{
Set<String> parents = descendant.getParents();
- if ( VUtil.isNotNullOrEmpty( parents ) )
+ if ( ObjUtil.isNotNullOrEmpty( parents ) )
{
for ( String parent : parents )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/Manageable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/Manageable.java b/src/main/java/org/apache/directory/fortress/core/rbac/Manageable.java
index 5fc263d..626f4d5 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/Manageable.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/Manageable.java
@@ -24,7 +24,7 @@ import org.apache.directory.fortress.core.ValidationException;
import org.apache.directory.fortress.core.model.FortEntity;
import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
/**
* Abstract class allows outside clients to manage security and multi-tenant concerns within the Fortress runtime.
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/0e307ed6/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnitP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnitP.java b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnitP.java
index b8a8ea3..50f38d7 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnitP.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnitP.java
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.directory.fortress.core.model.VUtil;
import org.apache.directory.fortress.core.util.cache.Cache;
import org.apache.directory.fortress.core.util.cache.CacheMgr;