directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-fortress-core] branch master updated: o Removed unused imports o Using static method in a static way o Closed a InputStream o Removed a useless private constructor o Added generics
Date Mon, 06 Jul 2020 09:55:59 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 1147b22  o Removed unused imports o Using static method in a static way o Closed
a InputStream o Removed a useless private constructor o Added generics
1147b22 is described below

commit 1147b229f141ff6d74738899ed66285e7b2624ed
Author: emmanuel lecharny <emmanuel.lecharny@busit.com>
AuthorDate: Mon Jul 6 11:55:28 2020 +0200

    o Removed unused imports
    o Using static method in a static way
    o Closed a InputStream
    o Removed a useless private constructor
    o Added generics
---
 .../fortress/core/impl/AccessMgrImpl.java          | 17 ++++++-------
 .../fortress/core/impl/PropertyMgrImpl.java        |  1 -
 .../directory/fortress/core/impl/RoleUtil.java     | 10 ++------
 .../fortress/core/ldap/LdapDataProvider.java       |  2 +-
 .../directory/fortress/core/model/Address.java     |  1 -
 .../directory/fortress/core/model/UserRole.java    |  2 +-
 .../directory/fortress/core/util/ResourceUtil.java | 29 ++++++++++++++--------
 .../apache/directory/fortress/core/util/VUtil.java |  3 ++-
 .../fortress/core/util/time/Discriminant.java      |  3 +--
 9 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
index 0d79785..4c618e7 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
@@ -89,8 +89,8 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
         throws SecurityException
     {
         String methodName = "authenticate";
-        VUtil.getInstance().assertNotNullOrEmpty( userId, GlobalErrIds.USER_ID_NULL, getFullMethodName(
CLS_NM, methodName ) );
-        VUtil.getInstance().assertNotNullOrEmpty( password, GlobalErrIds.USER_PW_NULL, getFullMethodName(
CLS_NM, methodName ) );
+        VUtil.assertNotNullOrEmpty( userId, GlobalErrIds.USER_ID_NULL, getFullMethodName(
CLS_NM, methodName ) );
+        VUtil.assertNotNullOrEmpty( password, GlobalErrIds.USER_PW_NULL, getFullMethodName(
CLS_NM, methodName ) );
         User inUser = new User( userId );
         inUser.setContextId( contextId );
 
@@ -153,9 +153,9 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
         assertContext( CLS_NM, methodName, perm, GlobalErrIds.PERM_NULL );
         assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
         
-        VUtil.getInstance().assertNotNullOrEmpty( perm.getOpName(), GlobalErrIds.PERM_OPERATION_NULL,
+        VUtil.assertNotNullOrEmpty( perm.getOpName(), GlobalErrIds.PERM_OPERATION_NULL,
             getFullMethodName( CLS_NM, methodName ) );
-        VUtil.getInstance().assertNotNullOrEmpty( perm.getObjName(), GlobalErrIds.PERM_OBJECT_NULL,
+        VUtil.assertNotNullOrEmpty( perm.getObjName(), GlobalErrIds.PERM_OBJECT_NULL,
             getFullMethodName( CLS_NM, methodName ) );
         VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false
);
         VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false
);
@@ -185,7 +185,7 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
     {
         String methodName = "isUserInRole";
         assertContext( CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL );
-        VUtil.getInstance().assertNotNullOrEmpty( role.getName(), GlobalErrIds.ROLE_NM_NULL,
+        VUtil.assertNotNullOrEmpty( role.getName(), GlobalErrIds.ROLE_NM_NULL,
             getFullMethodName( CLS_NM, methodName ) );
         boolean result = false;
         Session session = createSession( user, isTrusted );
@@ -246,11 +246,11 @@ public class AccessMgrImpl extends Manageable implements AccessMgr,
Serializable
         assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
         if (session.isGroupSession())
         {
-            VUtil.getInstance().assertNotNull(session.getGroup(), GlobalErrIds.GROUP_NULL,
CLS_NM + ".authorizedRoles");
+            VUtil.assertNotNull(session.getGroup(), GlobalErrIds.GROUP_NULL, CLS_NM + ".authorizedRoles");
         }
         else
         {
-            VUtil.getInstance().assertNotNull(session.getUser(), GlobalErrIds.USER_NULL,
CLS_NM + ".authorizedRoles");
+            VUtil.assertNotNull(session.getUser(), GlobalErrIds.USER_NULL, CLS_NM + ".authorizedRoles");
         }
         VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false
);
         VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false
);
@@ -346,8 +346,7 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
         }
         role.setUserId(entityId);
         List<UserRole> activatedRoles = session.getRoles();
-        VUtil.getInstance()
-            .assertNotNull( activatedRoles, GlobalErrIds.URLE_DEACTIVE_FAILED, CLS_NM + getFullMethodName(
CLS_NM, methodName ) );
+        VUtil.assertNotNull( activatedRoles, GlobalErrIds.URLE_DEACTIVE_FAILED, CLS_NM +
getFullMethodName( CLS_NM, methodName ) );
         int indx = activatedRoles.indexOf( role );
         if ( indx != -1 )
         {
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PropertyMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/PropertyMgrImpl.java
index 9e096ea..21d0a15 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/PropertyMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PropertyMgrImpl.java
@@ -24,7 +24,6 @@ import java.util.Properties;
 
 import org.apache.directory.fortress.core.GlobalErrIds;
 import org.apache.directory.fortress.core.PropertyMgr;
-import org.apache.directory.fortress.core.ReviewMgr;
 import org.apache.directory.fortress.core.SecurityException;
 import org.apache.directory.fortress.core.model.AdminRole;
 import org.apache.directory.fortress.core.model.FortEntity;
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java b/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
index 7711f0d..1c3cdc8 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
@@ -86,7 +86,8 @@ final class RoleUtil implements ParentUtil
         return sINSTANCE;
     }
     
-    private RoleUtil(){
+    private RoleUtil()
+    {
         init();
     }
     
@@ -102,13 +103,6 @@ final class RoleUtil implements ParentUtil
         roleCache = cacheMgr.getCache( "fortress.roles" );
     }
 
-    /**
-     * Private constructor
-     *
-     */
-    private void RoleUtil()
-    {
-    }
 
     /**
      * Used to determine if one {@link org.apache.directory.fortress.core.model.Role} is
the parent of another.  This method
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index 270a37a..1c0cf42 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -1334,7 +1334,7 @@ public abstract class LdapDataProvider
      * Closes all the ldap connection pools.
      */
     public static void closeAllConnectionPools(){
-        LdapConnectionProvider.getInstance().closeAllConnectionPools();
+        LdapConnectionProvider.closeAllConnectionPools();
     }
 
 }
\ No newline at end of file
diff --git a/src/main/java/org/apache/directory/fortress/core/model/Address.java b/src/main/java/org/apache/directory/fortress/core/model/Address.java
index 8d43257..20676b3 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/Address.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/Address.java
@@ -26,7 +26,6 @@ import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
index 248f210..d9e2156 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
@@ -698,7 +698,7 @@ public class UserRole extends FortEntity implements Serializable, Constraint
     {
         if(roleConstraints == null)
         {
-            roleConstraints = new ArrayList();
+            roleConstraints = new ArrayList<>();
         }
         return roleConstraints;
     }
diff --git a/src/main/java/org/apache/directory/fortress/core/util/ResourceUtil.java b/src/main/java/org/apache/directory/fortress/core/util/ResourceUtil.java
index d8f1e33..076d9d5 100644
--- a/src/main/java/org/apache/directory/fortress/core/util/ResourceUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/ResourceUtil.java
@@ -98,20 +98,27 @@ public final class ResourceUtil {
             } else if (url.getProtocol().equals("jar")){
                 result = ResourceUtil.class.getClassLoader().getResourceAsStream(_reference);
                 if (null != result) {
-                    PushbackInputStream pushbackInputStream = new PushbackInputStream(result);
-                    int b = -1;
-                    try {
-                        b = pushbackInputStream.read();
-                    } catch (IOException e) {
-                        // Don't care
-                    }
-                    if (b != -1) {
-                        result = pushbackInputStream;
+                    try ( PushbackInputStream pushbackInputStream = new PushbackInputStream(result)
)
+                    {
+                        int b = -1;
                         try {
-                            pushbackInputStream.unread(b);
+                            b = pushbackInputStream.read();
                         } catch (IOException e) {
-                            result = null;
+                            // Don't care
                         }
+                        if (b != -1) {
+                            result = pushbackInputStream;
+                            try {
+                                pushbackInputStream.unread(b);
+                            } catch (IOException e) {
+                                result = null;
+                            }
+                        }
+                    }
+                    catch ( IOException ioe )
+                    {
+                        // Problem while closing the input stream... Nothing we can do
+                        ioe.printStackTrace();
                     }
                 }
             }
diff --git a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
index 47f2fd7..f550bda 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
@@ -38,6 +38,7 @@ import org.apache.directory.fortress.core.ValidationException;
 import org.apache.directory.fortress.core.model.Constraint;
 import org.apache.directory.fortress.core.model.Group;
 import org.apache.directory.fortress.core.model.ObjectFactory;
+import org.apache.directory.fortress.core.model.RoleConstraint;
 import org.apache.directory.fortress.core.model.Session;
 import org.apache.directory.fortress.core.model.UserRole;
 import org.apache.directory.fortress.core.model.Warning;
@@ -803,7 +804,7 @@ public final class VUtil implements ConstraintValidator
         }
 
         @Override
-        public List getConstraints()
+        public List<RoleConstraint> getConstraints()
         {
             throw new java.lang.UnsupportedOperationException();
         }
diff --git a/src/main/java/org/apache/directory/fortress/core/util/time/Discriminant.java
b/src/main/java/org/apache/directory/fortress/core/util/time/Discriminant.java
index 638c008..cb6e0f6 100644
--- a/src/main/java/org/apache/directory/fortress/core/util/time/Discriminant.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/time/Discriminant.java
@@ -29,7 +29,6 @@ import org.apache.directory.fortress.core.util.VUtil;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.TreeSet;
 
 /**
  * Do not use, is deprecated for {@link org.apache.directory.fortress.core.util.time.UserRoleConstraint}.
@@ -87,7 +86,7 @@ public class Discriminant
         return rc;
     }
 
-    public Set getValues( String members )
+    public Set<String> getValues( String members )
     {
         Set<String> values = new HashSet<>(  );
         if ( members != null )


Mime
View raw message