directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [1/5] directory-fortress-core git commit: o Fixed many Sonar warnings o Renamed the Organizat*ii*onalUnitDAO class
Date Wed, 20 May 2015 07:35:41 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master d48b33c5b -> 195bcc1ee


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/33477ff6/src/main/java/org/apache/directory/fortress/core/rbac/UserP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/UserP.java b/src/main/java/org/apache/directory/fortress/core/rbac/UserP.java
index cb7b4fa..dac9d39 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/UserP.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/UserP.java
@@ -81,13 +81,13 @@ public final class UserP
      * @return List of type User containing fully populated matching User entities.  If no
records found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<User> search( User user ) throws SecurityException
+    List<User> search( User user ) throws SecurityException
     {
         return uDao.findUsers( user );
     }
 
 
-    final List<User> search( OrgUnit ou, boolean limitSize ) throws SecurityException
+    List<User> search( OrgUnit ou, boolean limitSize ) throws SecurityException
     {
         return uDao.findUsers( ou, limitSize );
     }
@@ -102,7 +102,7 @@ public final class UserP
      * @return List of type String containing userId of all matching User entities. If no
records found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<String> search( User user, int limit ) throws SecurityException
+    List<String> search( User user, int limit ) throws SecurityException
     {
         return uDao.findUsers( user, limit );
     }
@@ -115,7 +115,7 @@ public final class UserP
      * @return List of type User containing fully populated matching User entities. If no
records found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<User> getAuthorizedUsers( Role role ) throws SecurityException
+    List<User> getAuthorizedUsers( Role role ) throws SecurityException
     {
         return uDao.getAuthorizedUsers( role );
     }
@@ -129,7 +129,7 @@ public final class UserP
      * @return Set of type String containing the userId's for matching User entities. If
no records found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final Set<String> getAssignedUsers( Set<String> roles, String contextId )
throws SecurityException
+    Set<String> getAssignedUsers( Set<String> roles, String contextId ) throws
SecurityException
     {
         return uDao.getAssignedUsers( roles, contextId );
     }
@@ -145,7 +145,7 @@ public final class UserP
      * @return list of type String of userIds. If no records found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<String> getAuthorizedUsers( Role role, int limit ) throws SecurityException
+    List<String> getAuthorizedUsers( Role role, int limit ) throws SecurityException
     {
         return uDao.getAuthorizedUsers( role, limit );
     }
@@ -159,7 +159,7 @@ public final class UserP
      * @return List of fully populated User entities matching target search. If no records
found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<User> getAssignedUsers( Role role ) throws SecurityException
+    List<User> getAssignedUsers( Role role ) throws SecurityException
     {
         return uDao.getAssignedUsers( role );
     }
@@ -173,7 +173,7 @@ public final class UserP
      * @return List of fully populated User entities matching target search.  If no records
found this will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<User> getAssignedUsers( AdminRole role ) throws SecurityException
+    List<User> getAssignedUsers( AdminRole role ) throws SecurityException
     {
         return uDao.getAssignedUsers( role );
     }
@@ -186,7 +186,7 @@ public final class UserP
      * @return List of type String containing RBAC role names.  If no records found this
will be empty.
      * @throws SecurityException in the event of DAO search error.
      */
-    final List<String> getAssignedRoles( User user ) throws SecurityException
+    List<String> getAssignedRoles( User user ) throws SecurityException
     {
         return uDao.getRoles( user );
     }
@@ -201,7 +201,7 @@ public final class UserP
      * @return User entity containing all attributes associated with User in directory.
      * @throws SecurityException in the event of User not found or DAO search error.
      */
-    final User read( User user, boolean isRoles ) throws SecurityException
+    User read( User user, boolean isRoles ) throws SecurityException
     {
         return uDao.getUser( user, isRoles );
     }
@@ -216,7 +216,7 @@ public final class UserP
      * @return User entity copy of input + additional attributes (internalId) that were added
by op.
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final User add( User entity ) throws SecurityException
+    User add( User entity ) throws SecurityException
     {
         return add( entity, true );
     }
@@ -232,7 +232,7 @@ public final class UserP
      * @return User entity copy of input + additional attributes (internalId)
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final User add( User entity, boolean validate ) throws SecurityException
+    User add( User entity, boolean validate ) throws SecurityException
     {
         if ( validate )
         {
@@ -257,7 +257,7 @@ public final class UserP
      * @return User entity copy of input
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final User update( User entity ) throws SecurityException
+    User update( User entity ) throws SecurityException
     {
         return update( entity, true );
     }
@@ -287,7 +287,7 @@ public final class UserP
      * @return User entity copy of input
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final User update( User entity, boolean validate ) throws SecurityException
+    User update( User entity, boolean validate ) throws SecurityException
     {
         if ( validate )
         {
@@ -307,7 +307,7 @@ public final class UserP
      * @return String contains user DN
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final String softDelete( User user ) throws SecurityException
+    String softDelete( User user ) throws SecurityException
     {
         // Ensure this user isn't listed in Fortress config as a system user that can't be
removed via API.
         // Is there a match between this userId and a Fortress system user?
@@ -332,7 +332,7 @@ public final class UserP
      * @return String contains user DN
      * @throws SecurityException in the event of data validation or DAO system error.
      */
-    final String delete( User user ) throws SecurityException
+    String delete( User user ) throws SecurityException
     {
         // Ensure this user isn't listed in Fortress config as a system user that can't be
removed via API.
         // Is there a match between this userId and a Fortress system user?
@@ -354,7 +354,7 @@ public final class UserP
      * @param user contains the userId for target user.
      * @throws SecurityException in the event of DAO error.
      */
-    final void deletePwPolicy( User user ) throws SecurityException
+    void deletePwPolicy( User user ) throws SecurityException
     {
         uDao.deletePwPolicy( user );
     }
@@ -368,7 +368,7 @@ public final class UserP
      * @return Session object will be returned if authentication successful.  This will not
contain user's roles.
      * @throws SecurityException in the event of data validation failure, security policy
violation or DAO error.
      */
-    final Session authenticate( User user ) throws SecurityException
+    Session authenticate( User user ) throws SecurityException
     {
         Session session;
         session = uDao.checkPassword( user );
@@ -435,7 +435,7 @@ public final class UserP
      * @return Session object will contain authentication result code, RBAC and Admin role
activations, OpenLDAP pw policy output and more.
      * @throws SecurityException in the event of data validation failure, security policy
violation or DAO error.
      */
-    final Session createSession( User user, boolean trusted ) throws SecurityException
+    Session createSession( User user, boolean trusted ) throws SecurityException
     {
         Session session;
         if ( trusted )
@@ -535,7 +535,7 @@ public final class UserP
      * @param user Contains userId that represents rDn of node in ldap directory.
      * @throws SecurityException in the event of DAO error.
      */
-    final void lock( User user ) throws SecurityException
+    void lock( User user ) throws SecurityException
     {
         uDao.lock( user );
     }
@@ -547,7 +547,7 @@ public final class UserP
      * @param user Contains userId that represents rDn of node in ldap directory.
      * @throws SecurityException in the event of DAO  error.
      */
-    final void unlock( User user ) throws SecurityException
+    void unlock( User user ) throws SecurityException
     {
         uDao.unlock( user );
     }
@@ -560,7 +560,7 @@ public final class UserP
      * @param newPassword contains the new password which must pass the password policy constraints.
      * @throws SecurityException in the event of data validation failure, password policy
violation or DAO error.
      */
-    final void changePassword( User entity, char[] newPassword ) throws SecurityException
+    void changePassword( User entity, char[] newPassword ) throws SecurityException
     {
         String userId = entity.getUserId();
         boolean result = uDao.changePassword( entity, newPassword );
@@ -578,7 +578,7 @@ public final class UserP
      * @param user contains the userId and the new password.
      * @throws SecurityException in the event of DAO error.
      */
-    final void resetPassword( User user ) throws SecurityException
+    void resetPassword( User user ) throws SecurityException
     {
         uDao.resetUserPassword( user );
     }
@@ -618,7 +618,7 @@ public final class UserP
      * @return String containing the user's DN.  This value is used to update the "roleOccupant"
attribute on associated role entity.
      * @throws SecurityException in the event data error in user or role objects or system
error.
      */
-    final String assign( UserRole uRole ) throws SecurityException
+    String assign( UserRole uRole ) throws SecurityException
     {
         validate( uRole );
         // "assign" custom Fortress role data, i.e. temporal constraints, onto the user node:
@@ -640,7 +640,7 @@ public final class UserP
      * @return String containing the user's DN.  This value is used to remove the "roleOccupant"
attribute on associated RBAC Role entity.
      * @throws SecurityException - in the event data error in user or role objects or system
error.
      */
-    final String deassign( UserRole uRole ) throws SecurityException
+    String deassign( UserRole uRole ) throws SecurityException
     {
         validate( uRole );
         // "deassign" custom Fortress role data from the user's node:
@@ -672,7 +672,7 @@ public final class UserP
      * @return String containing the user's DN.  This value is used to update the "roleOccupant"
attribute on associated Admin Role entity.
      * @throws SecurityException in the event data error in user or role objects or system
error.
      */
-    final String assign( UserAdminRole uRole ) throws SecurityException
+    String assign( UserAdminRole uRole ) throws SecurityException
     {
         validate( uRole );
         // Assign custom Fortress role data, i.e. temporal constraints, onto the user node:
@@ -692,7 +692,7 @@ public final class UserP
      * @return String containing the user's DN.  This value is used to remove the "roleOccupant"
attribute on associated Admin Role entity.
      * @throws SecurityException - in the event data error in user or role objects or system
error.
      */
-    final String deassign( UserAdminRole uRole ) throws SecurityException
+    String deassign( UserAdminRole uRole ) throws SecurityException
     {
         validate( uRole );
         // Deassign custom Fortress role data from the user's node:

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/33477ff6/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
index d671b7b..3728bf1 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
@@ -63,13 +63,13 @@ public class RestUtils
 {
     private static final String CLS_NM = RestUtils.class.getName();
     private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
-    private final static String HTTP_UID = Config.getProperty( "http.user" );
-    private final static String HTTP_PW_PARAM = "http.pw";
-    private final static String HTTP_PW = ( ( EncryptUtil.isEnabled() ) ? EncryptUtil.decrypt(
Config
+    private static final String HTTP_UID = Config.getProperty( "http.user" );
+    private static final String HTTP_PW_PARAM = "http.pw";
+    private static final String HTTP_PW = ( ( EncryptUtil.isEnabled() ) ? EncryptUtil.decrypt(
Config
         .getProperty( HTTP_PW_PARAM ) ) : Config.getProperty( HTTP_PW_PARAM ) );
-    private final static String HTTP_HOST = Config.getProperty( "http.host" );
-    private final static String HTTP_PORT = Config.getProperty( "http.port" );
-    private final static String HTTP_PROTOCOL = Config.getProperty( "http.protocol", "http"
);
+    private static final String HTTP_HOST = Config.getProperty( "http.host" );
+    private static final String HTTP_PORT = Config.getProperty( "http.port" );
+    private static final String HTTP_PROTOCOL = Config.getProperty( "http.protocol", "http"
);
     private static final String VERSION = System.getProperty( "version" );
     private static final String SERVICE = "fortress-rest-" + VERSION;
     // TODO: add SSL capability here:
@@ -88,14 +88,14 @@ public class RestUtils
     private static final String TRUST_STORE_PW = Config.getProperty( "trust.store.password"
);
     private static final String SET_TRUST_STORE_PROP = "trust.store.set.prop";
     private static final boolean IS_SET_TRUST_STORE_PROP = (
-            Config.getProperty( SET_TRUST_STORE_PROP ) != null   &&
-            Config.getProperty( SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ));
+        Config.getProperty( SET_TRUST_STORE_PROP ) != null &&
+        Config.getProperty( SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
 
     static
     {
-        if(IS_SET_TRUST_STORE_PROP)
+        if ( IS_SET_TRUST_STORE_PROP )
         {
-            LOG.info( "Set JSSE truststore properties:");
+            LOG.info( "Set JSSE truststore properties:" );
             LOG.info( "javax.net.ssl.trustStore: {}", TRUST_STORE );
             System.setProperty( "javax.net.ssl.trustStore", TRUST_STORE );
             System.setProperty( "javax.net.ssl.trustStorePassword", TRUST_STORE_PW );
@@ -103,8 +103,6 @@ public class RestUtils
     }
 
 
-
-
     /**
      * Marshall the request into an XML String.
      *

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/33477ff6/src/main/java/org/apache/directory/fortress/core/util/attr/VUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/attr/VUtil.java b/src/main/java/org/apache/directory/fortress/core/util/attr/VUtil.java
index db0268a..ea5d67c 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/attr/VUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/attr/VUtil.java
@@ -42,7 +42,7 @@ public 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 final static String VALIDATE_LENGTH = "field.length";
+    private static final String VALIDATE_LENGTH = "field.length";
 
     static
     {
@@ -61,10 +61,10 @@ public class VUtil
         }
     }
 
-    private final static int MAXIMUM_FIELD_LEN = maximumFieldLen;
-    private final static int maxFieldLength = MAXIMUM_FIELD_LEN;
-    private final static char[] LDAP_META_CHARS = loadLdapEscapeChars();
-    private final static String[] LDAP_REPL_VALS = loadValidLdapVals();
+    private static final int MAXIMUM_FIELD_LEN = maximumFieldLen;
+    private static final int maxFieldLength = MAXIMUM_FIELD_LEN;
+    private static final char[] LDAP_META_CHARS = loadLdapEscapeChars();
+    private static final String[] LDAP_REPL_VALS = loadValidLdapVals();
     private static final int TIME_LEN = 4;
     private static final int DATE_LEN = 8;
     private static final int DAYMASK_LEN = 7;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/33477ff6/src/main/java/org/apache/directory/fortress/core/util/time/CUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/time/CUtil.java b/src/main/java/org/apache/directory/fortress/core/util/time/CUtil.java
index 77d9e86..96026a5 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/time/CUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/time/CUtil.java
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.fortress.core.util.time;
 
+
 import org.apache.directory.fortress.core.CfgException;
 import org.apache.directory.fortress.core.GlobalIds;
 import org.apache.directory.fortress.core.ObjectFactory;
@@ -38,6 +39,7 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.StringTokenizer;
 
+
 /**
  * This class contains utilities for temporal constraint processing that are used by Fortress
internal.  All of the methods are static and the class
  * is thread safe.
@@ -61,7 +63,8 @@ public class CUtil
     private static final String CLS_NM = CUtil.class.getName();
     private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
     private static List<Validator> validators;
-    private static final String DSDVALIDATOR = Config.getProperty(GlobalIds.DSD_VALIDATOR_PROP);
+    private static final String DSDVALIDATOR = Config.getProperty( GlobalIds.DSD_VALIDATOR_PROP
);
+
 
     /**
      * Used by DAO utilities to convert from a string with comma delimited values to fortress
internal format {@link Constraint}.
@@ -69,24 +72,24 @@ public class CUtil
      * @param inputString contains raw data format which is comma delimited containing temporal
data.
      * @param constraint  used by internal processing to perform validations.
      */
-    public static void setConstraint(String inputString, Constraint constraint)
+    public static void setConstraint( String inputString, Constraint constraint )
     {
-        if(VUtil.isNotNullOrEmpty(inputString))
+        if ( VUtil.isNotNullOrEmpty( inputString ) )
         {
-            StringTokenizer tkn = new StringTokenizer(inputString, GlobalIds.DELIMITER, true);
-            if (tkn.countTokens() > 0)
+            StringTokenizer tkn = new StringTokenizer( inputString, GlobalIds.DELIMITER,
true );
+            if ( tkn.countTokens() > 0 )
             {
                 int count = tkn.countTokens();
                 int index = 0;
                 boolean previousTokenWasDelimiter = false;
-                for (int i = 0; i < count; i++)
+                for ( int i = 0; i < count; i++ )
                 {
                     String szValue = tkn.nextToken();
-                    if(szValue.equals(GlobalIds.DELIMITER) && !previousTokenWasDelimiter)
+                    if ( szValue.equals( GlobalIds.DELIMITER ) && !previousTokenWasDelimiter
)
                     {
                         previousTokenWasDelimiter = true;
                     }
-                    else if(szValue.equals(GlobalIds.DELIMITER))
+                    else if ( szValue.equals( GlobalIds.DELIMITER ) )
                     {
                         previousTokenWasDelimiter = true;
                         index++;
@@ -94,36 +97,39 @@ public class CUtil
                     else
                     {
                         previousTokenWasDelimiter = false;
-                        switch (index++)
+                        switch ( index++ )
                         {
                             case 0:
                                 // only set the name attr if it isn't already set:
-                                if (constraint.getName() == null || constraint.getName().length()
== 0)
-                                    constraint.setName(szValue);
+                                if ( ( constraint.getName() == null ) || ( constraint.getName().length()
== 0 ) )
+                                {
+                                    constraint.setName( szValue );
+                                }
+
                                 break;
                             case 1:
-                                constraint.setTimeout(Integer.parseInt(szValue));
+                                constraint.setTimeout( Integer.parseInt( szValue ) );
                                 break;
                             case 2:
-                                constraint.setBeginTime(szValue);
+                                constraint.setBeginTime( szValue );
                                 break;
                             case 3:
-                                constraint.setEndTime(szValue);
+                                constraint.setEndTime( szValue );
                                 break;
                             case 4:
-                                constraint.setBeginDate(szValue);
+                                constraint.setBeginDate( szValue );
                                 break;
                             case 5:
-                                constraint.setEndDate(szValue);
+                                constraint.setEndDate( szValue );
                                 break;
                             case 6:
-                                constraint.setBeginLockDate(szValue);
+                                constraint.setBeginLockDate( szValue );
                                 break;
                             case 7:
-                                constraint.setEndLockDate(szValue);
+                                constraint.setEndLockDate( szValue );
                                 break;
                             case 8:
-                                constraint.setDayMask(szValue);
+                                constraint.setDayMask( szValue );
                                 break;
                         }
                     }
@@ -132,91 +138,126 @@ public class CUtil
         }
     }
 
+
     /**
      * Convert from fortress {@link Constraint} to comma delimited ldap format.
      *
      * @param constraint contains the temporal data.
      * @return string containing raw data bound for ldap.
      */
-    public static String setConstraint(Constraint constraint)
+    public static String setConstraint( Constraint constraint )
     {
         String szConstraint = null;
-        if (constraint != null)
+        if ( constraint != null )
         {
             StringBuilder sb = new StringBuilder();
-            sb.append(constraint.getName());
-            sb.append(GlobalIds.DELIMITER);
-            if(constraint.getTimeout() != null)
-                sb.append(constraint.getTimeout());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getBeginTime() != null)
-                sb.append(constraint.getBeginTime());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getEndTime() != null)
-                sb.append(constraint.getEndTime());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getBeginDate() != null)
-                sb.append(constraint.getBeginDate());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getEndDate() != null)
-                sb.append(constraint.getEndDate());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getBeginLockDate() != null)
-                sb.append(constraint.getBeginLockDate());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getEndLockDate() != null)
-                sb.append(constraint.getEndLockDate());
-            sb.append(GlobalIds.DELIMITER);
-            if (constraint.getDayMask() != null)
-                sb.append(constraint.getDayMask());
+            sb.append( constraint.getName() );
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getTimeout() != null )
+            {
+                sb.append( constraint.getTimeout() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getBeginTime() != null )
+            {
+                sb.append( constraint.getBeginTime() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getEndTime() != null )
+            {
+                sb.append( constraint.getEndTime() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getBeginDate() != null )
+            {
+                sb.append( constraint.getBeginDate() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getEndDate() != null )
+            {
+                sb.append( constraint.getEndDate() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getBeginLockDate() != null )
+            {
+                sb.append( constraint.getBeginLockDate() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getEndLockDate() != null )
+            {
+                sb.append( constraint.getEndLockDate() );
+            }
+
+            sb.append( GlobalIds.DELIMITER );
+
+            if ( constraint.getDayMask() != null )
+            {
+                sb.append( constraint.getDayMask() );
+            }
+
             szConstraint = sb.toString();
         }
         return szConstraint;
     }
 
+
     /**
      * Validate the non-null attributes on the constraint.
      *
      * @param c1 contains the temporal values associated with an entity.
      * @throws org.apache.directory.fortress.core.ValidationException on first invalid attribute
found.
      */
-    public static void validate(Constraint c1)
+    public static void validate( Constraint c1 )
         throws ValidationException
     {
-        if (VUtil.isNotNullOrEmpty(c1.getTimeout()))
+        if ( VUtil.isNotNullOrEmpty( c1.getTimeout() ) )
         {
-            VUtil.timeout(c1.getTimeout());
+            VUtil.timeout( c1.getTimeout() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getBeginTime()))
+        if ( VUtil.isNotNullOrEmpty( c1.getBeginTime() ) )
         {
-            VUtil.beginTime(c1.getBeginTime());
+            VUtil.beginTime( c1.getBeginTime() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getEndTime()))
+        if ( VUtil.isNotNullOrEmpty( c1.getEndTime() ) )
         {
-            VUtil.endTime(c1.getEndTime());
+            VUtil.endTime( c1.getEndTime() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getBeginDate()))
+        if ( VUtil.isNotNullOrEmpty( c1.getBeginDate() ) )
         {
-            VUtil.beginDate(c1.getBeginDate());
+            VUtil.beginDate( c1.getBeginDate() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getEndDate()))
+        if ( VUtil.isNotNullOrEmpty( c1.getEndDate() ) )
         {
-            VUtil.endDate(c1.getEndDate());
+            VUtil.endDate( c1.getEndDate() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getDayMask()))
+        if ( VUtil.isNotNullOrEmpty( c1.getDayMask() ) )
         {
-            VUtil.dayMask(c1.getDayMask());
+            VUtil.dayMask( c1.getDayMask() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getBeginLockDate()))
+        if ( VUtil.isNotNullOrEmpty( c1.getBeginLockDate() ) )
         {
-            VUtil.beginDate(c1.getBeginLockDate());
+            VUtil.beginDate( c1.getBeginLockDate() );
         }
-        if (VUtil.isNotNullOrEmpty(c1.getEndLockDate()))
+        if ( VUtil.isNotNullOrEmpty( c1.getEndLockDate() ) )
         {
-            VUtil.endDate(c1.getEndLockDate());
+            VUtil.endDate( c1.getEndLockDate() );
         }
     }
 
+
     /**
      * Utility is used during processing of constraint values.  The rule used here is if
the target constraint will
      * accept the source constraint attribute only when not set initially.  If target constraint's
attribute is set,
@@ -226,73 +267,73 @@ public class CUtil
      * @param trgC instantiated object may contain zero or more attributes set.  Copy will
not be performed on set attrs.
      * @throws org.apache.directory.fortress.core.ValidationException on first invalid attribute
found.
      */
-    public static void validateOrCopy(Constraint srcC, Constraint trgC)
+    public static void validateOrCopy( Constraint srcC, Constraint trgC )
         throws ValidationException
     {
         //VUtil.timeout(trgC.getTimeout());
-        if (VUtil.isNotNullOrEmpty(trgC.getTimeout()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getTimeout() ) )
         {
-            srcC.setTimeout(trgC.getTimeout());
+            srcC.setTimeout( trgC.getTimeout() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getTimeout()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getTimeout() ) )
         {
-            trgC.setTimeout(srcC.getTimeout());
+            trgC.setTimeout( srcC.getTimeout() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getBeginTime()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getBeginTime() ) )
         {
-            VUtil.beginTime(trgC.getBeginTime());
+            VUtil.beginTime( trgC.getBeginTime() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getBeginTime()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getBeginTime() ) )
         {
-            trgC.setBeginTime(srcC.getBeginTime());
+            trgC.setBeginTime( srcC.getBeginTime() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getEndTime()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getEndTime() ) )
         {
-            VUtil.endTime(trgC.getEndTime());
+            VUtil.endTime( trgC.getEndTime() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getEndTime()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getEndTime() ) )
         {
-            trgC.setEndTime(srcC.getEndTime());
+            trgC.setEndTime( srcC.getEndTime() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getBeginDate()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getBeginDate() ) )
         {
-            VUtil.beginDate(trgC.getBeginDate());
+            VUtil.beginDate( trgC.getBeginDate() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getBeginDate()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getBeginDate() ) )
         {
-            trgC.setBeginDate(srcC.getBeginDate());
+            trgC.setBeginDate( srcC.getBeginDate() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getEndDate()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getEndDate() ) )
         {
-            VUtil.endDate(trgC.getEndDate());
+            VUtil.endDate( trgC.getEndDate() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getEndDate()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getEndDate() ) )
         {
-            trgC.setEndDate(srcC.getEndDate());
+            trgC.setEndDate( srcC.getEndDate() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getDayMask()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getDayMask() ) )
         {
-            VUtil.dayMask(trgC.getDayMask());
+            VUtil.dayMask( trgC.getDayMask() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getDayMask()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getDayMask() ) )
         {
-            trgC.setDayMask(srcC.getDayMask());
+            trgC.setDayMask( srcC.getDayMask() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getBeginLockDate()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getBeginLockDate() ) )
         {
-            VUtil.beginDate(trgC.getBeginLockDate());
+            VUtil.beginDate( trgC.getBeginLockDate() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getBeginLockDate()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getBeginLockDate() ) )
         {
-            trgC.setBeginLockDate(srcC.getBeginLockDate());
+            trgC.setBeginLockDate( srcC.getBeginLockDate() );
         }
-        if (VUtil.isNotNullOrEmpty(trgC.getEndLockDate()))
+        if ( VUtil.isNotNullOrEmpty( trgC.getEndLockDate() ) )
         {
-            VUtil.endDate(trgC.getEndLockDate());
+            VUtil.endDate( trgC.getEndLockDate() );
         }
-        else if (VUtil.isNotNullOrEmpty(srcC.getEndLockDate()))
+        else if ( VUtil.isNotNullOrEmpty( srcC.getEndLockDate() ) )
         {
-            trgC.setEndLockDate(srcC.getEndLockDate());
+            trgC.setEndLockDate( srcC.getEndLockDate() );
         }
     }
 
@@ -320,54 +361,55 @@ public class CUtil
         {
             validators = getValidators();
         }
-        catch ( SecurityException ex)
+        catch ( SecurityException ex )
         {
-            LOG.error("static initialzier caught SecurityException=" + ex.getMessage(), ex);
+            LOG.error( "static initialzier caught SecurityException=" + ex.getMessage(),
ex );
         }
     }
 
+
     /**
      * Copy source constraint to target. Both must be created before calling this utility.
      *
      * @param srcC contains constraint source.
      * @param trgC contains target constraint.
      */
-    public static void copy(Constraint srcC, Constraint trgC)
+    public static void copy( Constraint srcC, Constraint trgC )
     {
         // Both variables must be instantiated before being passed in to this method.
-        trgC.setTimeout(srcC.getTimeout());
+        trgC.setTimeout( srcC.getTimeout() );
 
-        if (VUtil.isNotNullOrEmpty(srcC.getName()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getName() ) )
         {
-            trgC.setName(srcC.getName());
+            trgC.setName( srcC.getName() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getBeginTime()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getBeginTime() ) )
         {
-            trgC.setBeginTime(srcC.getBeginTime());
+            trgC.setBeginTime( srcC.getBeginTime() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getEndTime()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getEndTime() ) )
         {
-            trgC.setEndTime(srcC.getEndTime());
+            trgC.setEndTime( srcC.getEndTime() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getDayMask()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getDayMask() ) )
         {
-            trgC.setDayMask(srcC.getDayMask());
+            trgC.setDayMask( srcC.getDayMask() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getBeginDate()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getBeginDate() ) )
         {
-            trgC.setBeginDate(srcC.getBeginDate());
+            trgC.setBeginDate( srcC.getBeginDate() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getEndDate()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getEndDate() ) )
         {
-            trgC.setEndDate(srcC.getEndDate());
+            trgC.setEndDate( srcC.getEndDate() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getBeginLockDate()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getBeginLockDate() ) )
         {
-            trgC.setBeginLockDate(srcC.getBeginLockDate());
+            trgC.setBeginLockDate( srcC.getBeginLockDate() );
         }
-        if (VUtil.isNotNullOrEmpty(srcC.getEndLockDate()))
+        if ( VUtil.isNotNullOrEmpty( srcC.getEndLockDate() ) )
         {
-            trgC.setEndLockDate(srcC.getEndLockDate());
+            trgC.setEndLockDate( srcC.getEndLockDate() );
         }
     }
 
@@ -381,79 +423,83 @@ public class CUtil
      * @param checkDsd will check DSD constraints if true
      * @throws org.apache.directory.fortress.core.SecurityException in the event validation
fails for User or system error occurs.
      */
-    public static void validateConstraints(Session session, ConstraintType type, boolean
checkDsd)
+    public static void validateConstraints( Session session, ConstraintType type, boolean
checkDsd )
         throws SecurityException
     {
         String location = "validateConstraints";
         int rc;
-        if (validators == null)
+        if ( validators == null )
         {
-            if(LOG.isDebugEnabled())
+            if ( LOG.isDebugEnabled() )
             {
                 LOG.debug( "{} userId [{}]  no constraints enabled", location, session.getUserId()
);
             }
             return;
         }
         // no need to continue if the role list is empty and we're trying to check role constraints:
-        else if (type == ConstraintType.ROLE && !VUtil.isNotNullOrEmpty(session.getRoles())
&& !VUtil.isNotNullOrEmpty(session.getAdminRoles()))
+        else if ( type == ConstraintType.ROLE && !VUtil.isNotNullOrEmpty( session.getRoles()
)
+            && !VUtil.isNotNullOrEmpty( session.getAdminRoles() ) )
         {
-            if(LOG.isDebugEnabled())
+            if ( LOG.isDebugEnabled() )
             {
                 LOG.debug( "{} userId [{}]  has no roles assigned", location, session.getUserId()
);
             }
             return;
         }
-        for (Validator val : validators)
+        for ( Validator val : validators )
         {
             Time currTime = TUtil.getCurrentTime();
             // first check the constraint on the user:
-            if (type == ConstraintType.USER)
+            if ( type == ConstraintType.USER )
             {
-                rc = val.validate(session, session.getUser(), currTime);
-                if (rc > 0)
+                rc = val.validate( session, session.getUser(), currTime );
+                if ( rc > 0 )
                 {
-                    String info = location + " user [" + session.getUserId() + "] was deactivated
reason code [" + rc + "]";
-                    throw new ValidationException(rc, info);
+                    String info = location + " user [" + session.getUserId() + "] was deactivated
reason code [" + rc
+                        + "]";
+                    throw new ValidationException( rc, info );
                 }
             }
             // Check the constraints for each role assignment:
             else
             {
-                if (VUtil.isNotNullOrEmpty(session.getRoles()))
+                if ( VUtil.isNotNullOrEmpty( session.getRoles() ) )
                 {
                     // now check the constraint on every rbac role activation candidate contained
within session object:
                     ListIterator<UserRole> roleItems = session.getRoles().listIterator();
-                    
-                    while (roleItems.hasNext())
+
+                    while ( roleItems.hasNext() )
                     {
-                        Constraint constraint = (Constraint) roleItems.next();
-                        rc = val.validate(session, constraint, currTime);
-                        
-                        if (rc > 0)
+                        Constraint constraint = ( Constraint ) roleItems.next();
+                        rc = val.validate( session, constraint, currTime );
+
+                        if ( rc > 0 )
                         {
                             String msg = location + " role [" + constraint.getName() + "]
for user ["
                                 + session.getUserId() + "] was deactivated reason code ["
+ rc + "]";
-                            LOG.info(msg);
+                            LOG.info( msg );
                             roleItems.remove();
-                            session.setWarning( new ObjectFactory().createWarning( rc, msg,
Warning.Type.ROLE, constraint.getName() ) );
+                            session.setWarning( new ObjectFactory().createWarning( rc, msg,
Warning.Type.ROLE,
+                                constraint.getName() ) );
                         }
                     }
                 }
-                if (VUtil.isNotNullOrEmpty(session.getAdminRoles()))
+                if ( VUtil.isNotNullOrEmpty( session.getAdminRoles() ) )
                 {
                     // now check the constraint on every arbac role activation candidate
contained within session object:
                     ListIterator roleItems = session.getAdminRoles().listIterator();
-                    while (roleItems.hasNext())
+                    while ( roleItems.hasNext() )
                     {
-                        Constraint constraint = (Constraint) roleItems.next();
-                        rc = val.validate(session, constraint, currTime);
-                        if (rc > 0)
+                        Constraint constraint = ( Constraint ) roleItems.next();
+                        rc = val.validate( session, constraint, currTime );
+                        if ( rc > 0 )
                         {
                             String msg = location + " admin role [" + constraint.getName()
+ "] for user ["
                                 + session.getUserId() + "] was deactivated reason code ["
+ rc + "]";
-                            LOG.info(msg);
+                            LOG.info( msg );
                             roleItems.remove();
-                            session.setWarning( new ObjectFactory().createWarning( rc, msg,
Warning.Type.ROLE, constraint.getName() ) );
+                            session.setWarning( new ObjectFactory().createWarning( rc, msg,
Warning.Type.ROLE,
+                                constraint.getName() ) );
                         }
                     }
                 }
@@ -461,15 +507,17 @@ public class CUtil
         }
 
         // now perform DSD validation on session's rbac roles:
-        if (checkDsd && DSDVALIDATOR != null && DSDVALIDATOR.length() >
0 && type == ConstraintType.ROLE && VUtil.isNotNullOrEmpty( session.getRoles()
))
+        if ( checkDsd && DSDVALIDATOR != null && DSDVALIDATOR.length() >
0 && type == ConstraintType.ROLE
+            && VUtil.isNotNullOrEmpty( session.getRoles() ) )
         {
-            Validator dsdVal = (Validator) ClassUtil.createInstance(DSDVALIDATOR);
-            dsdVal.validate(session, session.getUser(), null);
+            Validator dsdVal = ( Validator ) ClassUtil.createInstance( DSDVALIDATOR );
+            dsdVal.validate( session, session.getUser(), null );
         }
         // reset the user's last access timestamp:
         session.setLastAccess();
     }
 
+
     /**
      * Utility is used internally by this class to retrieve a list of all Validator class
names, instantiate and return.
      *
@@ -480,16 +528,16 @@ public class CUtil
         throws CfgException
     {
         List<Validator> validators = new ArrayList<>();
-        for (int i = 0; ; i++)
+        for ( int i = 0;; i++ )
         {
             String prop = GlobalIds.VALIDATOR_PROPS + i;
-            String className = Config.getProperty(prop);
-            if (className == null)
+            String className = Config.getProperty( prop );
+            if ( className == null )
             {
                 break;
             }
 
-            validators.add((Validator) ClassUtil.createInstance(className));
+            validators.add( ( Validator ) ClassUtil.createInstance( className ) );
         }
         return validators;
     }


Mime
View raw message