directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [60/75] [abbrv] directory-fortress-core git commit: FC-109 - separate AttrUtil into Prop and Audit utils
Date Tue, 09 Jun 2015 03:16:06 GMT
FC-109 - separate AttrUtil into Prop and Audit utils


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/1344104a
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/1344104a
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/1344104a

Branch: refs/heads/master
Commit: 1344104a0b207953312134c3111182561c2757ba
Parents: 2ba96f0
Author: Shawn McKinney <smckinney@apache.org>
Authored: Wed Jun 3 10:55:32 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Wed Jun 3 10:55:32 2015 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/ant/UserAnt.java    |   4 +-
 .../directory/fortress/core/impl/AuditDAO.java  |   4 +-
 .../directory/fortress/core/impl/ConfigDAO.java |   4 +-
 .../fortress/core/impl/DelAdminMgrImpl.java     |   3 +-
 .../directory/fortress/core/impl/GroupDAO.java  |   4 +-
 .../directory/fortress/core/impl/PermDAO.java   |   6 +-
 .../directory/fortress/core/impl/UserDAO.java   |   4 +-
 .../directory/fortress/core/impl/UserP.java     |  22 +-
 .../directory/fortress/core/model/Group.java    |   4 +-
 .../directory/fortress/core/util/AuditUtil.java |  70 ++++++
 .../directory/fortress/core/util/PropUtil.java  | 128 ++++++++++
 .../fortress/core/util/attr/AttrHelper.java     | 231 -------------------
 .../fortress/core/util/attr/package.html        |  33 ---
 .../fortress/core/AuditMgrConsole.java          |  50 +++-
 14 files changed, 279 insertions(+), 288 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/ant/UserAnt.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ant/UserAnt.java b/src/main/java/org/apache/directory/fortress/core/ant/UserAnt.java
index cdc6978..0f36d49 100755
--- a/src/main/java/org/apache/directory/fortress/core/ant/UserAnt.java
+++ b/src/main/java/org/apache/directory/fortress/core/ant/UserAnt.java
@@ -23,10 +23,10 @@ package org.apache.directory.fortress.core.ant;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.fortress.core.util.ObjUtil;
+import org.apache.directory.fortress.core.util.PropUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.directory.fortress.core.model.User;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
 
 import java.io.File;
 import java.io.IOException;
@@ -113,7 +113,7 @@ public class UserAnt extends User
     public void setUserProps( String userProps )
     {
         this.userProps = userProps;
-        addProperties( AttrHelper.getProperties( userProps ) );
+        addProperties( PropUtil.getProperties( userProps ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
index e6233c7..c76e11b 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
@@ -35,7 +35,7 @@ import org.apache.directory.fortress.core.model.AuthZ;
 import org.apache.directory.fortress.core.model.Bind;
 import org.apache.directory.fortress.core.model.Mod;
 import org.apache.directory.fortress.core.model.UserAudit;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
+import org.apache.directory.fortress.core.util.AuditUtil;
 import org.apache.directory.fortress.core.util.time.TUtil;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.fortress.core.FinderException;
@@ -279,7 +279,7 @@ final class AuditDAO extends ApacheDsDataProvider
                 AuthZ authZ = getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++
);
                 // todo: fix this workaround. This search will return failed role assign
searches as well.  
                 // Work around is to remove the ou=People failed searches from user failed
searches on authN.
-                if ( !AttrHelper.getAuthZId( authZ.getReqDN() ).equalsIgnoreCase( "People"
) )
+                if ( !AuditUtil.getAuthZId( authZ.getReqDN() ).equalsIgnoreCase( "People"
) )
                 {
                     auditList.add( authZ );
                 }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
index 45807e8..72ce674 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
@@ -34,6 +34,7 @@ import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
 import org.apache.directory.fortress.core.CreateException;
 import org.apache.directory.fortress.core.util.Config;
 import org.apache.directory.fortress.core.util.ObjUtil;
+import org.apache.directory.fortress.core.util.PropUtil;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.fortress.core.ldap.ApacheDsDataProvider;
 import org.slf4j.Logger;
@@ -43,7 +44,6 @@ 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.UpdateException;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
 
 
 /**
@@ -270,7 +270,7 @@ final class ConfigDAO extends ApacheDsDataProvider
         {
             ld = getAdminConnection();
             Entry findEntry = read( ld, dn, CONFIG_ATRS );
-            props = AttrHelper.getProperties( getAttributes( findEntry, GlobalIds.PROPS )
);
+            props = PropUtil.getProperties( getAttributes( findEntry, GlobalIds.PROPS ) );
         }
         catch ( LdapNoSuchObjectException e )
         {

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
index 82a7c68..8fb9add 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
@@ -33,7 +33,6 @@ 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.VUtil;
 
@@ -282,7 +281,7 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr
         CUtil.validateOrCopy(validRole, uAdminRole);
 
         // copy the ARBAC AdminRole attributes to UserAdminRole:
-        AttrHelper.copyAdminAttrs( validRole, uAdminRole );
+        userP.copyAdminAttrs( validRole, uAdminRole );
         String dn = userP.assign(uAdminRole);
         // copy the admin session info to AdminRole:
         setAdminData(CLS_NM, methodName, validRole);

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
index 11cfed5..e2ee369 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
@@ -35,6 +35,7 @@ import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueEx
 import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.fortress.core.model.Group;
+import org.apache.directory.fortress.core.util.PropUtil;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.fortress.core.FinderException;
 import org.apache.directory.fortress.core.model.ObjectFactory;
@@ -42,7 +43,6 @@ import org.apache.directory.fortress.core.UpdateException;
 import org.apache.directory.fortress.core.util.Config;
 import org.apache.directory.fortress.core.ldap.ApacheDsDataProvider;
 import org.apache.directory.fortress.core.model.User;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.directory.fortress.core.CreateException;
@@ -494,7 +494,7 @@ final class GroupDAO extends ApacheDsDataProvider
         entity.setProtocol( getAttribute( le, GROUP_PROTOCOL_ATTR_IMPL ) );
         entity.setMembers( getAttributes( le, SchemaConstants.MEMBER_AT ) );
         entity.setMemberDn( true );
-        entity.setProperties( AttrHelper.getProperties( getAttributes( le, GROUP_PROPERTY_ATTR_IMPL
), '=' ) );
+        entity.setProperties( PropUtil.getProperties( getAttributes( le, GROUP_PROPERTY_ATTR_IMPL
), '=' ) );
         entity.setSequenceId( sequence );
 
         return entity;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index 7465481..85d09dd 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -49,7 +49,7 @@ 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.util.ObjUtil;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
+import org.apache.directory.fortress.core.util.PropUtil;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.fortress.core.CreateException;
 import org.apache.directory.fortress.core.FinderException;
@@ -1026,7 +1026,7 @@ final class PermDAO extends ApacheDsDataProvider
         entity.setUsers( getAttributeSet( le, USERS ) );
         entity.setType( getAttribute( le, TYPE ) );
         entity.setDescription( getAttribute( le, SchemaConstants.DESCRIPTION_AT ) );
-        entity.addProperties( AttrHelper.getProperties( getAttributes( le, GlobalIds.PROPS
) ) );
+        entity.addProperties( PropUtil.getProperties( getAttributes( le, GlobalIds.PROPS
) ) );
         entity.setAdmin( isAdmin );
 
         // TODO: find out the correct way to do this:
@@ -1056,7 +1056,7 @@ final class PermDAO extends ApacheDsDataProvider
         entity.setInternalId( getAttribute( le, GlobalIds.FT_IID ) );
         entity.setType( getAttribute( le, TYPE ) );
         entity.setDescription( getAttribute( le, SchemaConstants.DESCRIPTION_AT ) );
-        entity.addProperties( AttrHelper.getProperties( getAttributes( le, GlobalIds.PROPS
) ) );
+        entity.addProperties( PropUtil.getProperties( getAttributes( le, GlobalIds.PROPS
) ) );
         entity.setAdmin( isAdmin );
         return entity;
     }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index b17d7d4..21ed464 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -58,7 +58,7 @@ import org.apache.directory.fortress.core.model.UserAdminRole;
 import org.apache.directory.fortress.core.model.UserRole;
 import org.apache.directory.fortress.core.model.Warning;
 import org.apache.directory.fortress.core.util.ObjUtil;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
+import org.apache.directory.fortress.core.util.PropUtil;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -2078,7 +2078,7 @@ final class UserDAO extends ApacheDsDataProvider
                 entity.setGecos( getAttribute( entry, GECOS ) );
         */
 
-        entity.addProperties( AttrHelper.getProperties( getAttributes( entry, GlobalIds.PROPS
) ) );
+        entity.addProperties( PropUtil.getProperties( getAttributes( entry, GlobalIds.PROPS
) ) );
 
         if ( GlobalIds.IS_OPENLDAP )
         {

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
index efee0b9..f67ec09 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
@@ -26,6 +26,7 @@ import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.fortress.core.model.AdminRole;
+import org.apache.directory.fortress.core.model.Administrator;
 import org.apache.directory.fortress.core.model.OrgUnit;
 import org.apache.directory.fortress.core.model.PwPolicy;
 import org.apache.directory.fortress.core.model.Role;
@@ -34,7 +35,6 @@ import org.apache.directory.fortress.core.model.User;
 import org.apache.directory.fortress.core.model.UserAdminRole;
 import org.apache.directory.fortress.core.model.UserRole;
 import org.apache.directory.fortress.core.util.ObjUtil;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -862,8 +862,26 @@ final class UserP
                 CUtil.validateOrCopy( outRole, uare );
 
                 // copy the ARBAC AdminRole attributes to UserAdminRole:
-                AttrHelper.copyAdminAttrs( outRole, uare );
+                copyAdminAttrs( outRole, uare );
             }
         }
     }
+
+    /**
+     * Perform copy on ARBAC attributes.  This is used during assignment of {@link org.apache.directory.fortress.core.model.AdminRole}
to {@link org.apache.directory.fortress.core.model.User}.
+     * This method does not perform input validations.
+     *
+     * @param srcR contains source attributes to copy.
+     * @param trgR contains the target reference.
+     */
+    void copyAdminAttrs(Administrator srcR, Administrator trgR)
+    {
+        trgR.setBeginInclusive(srcR.isBeginInclusive());
+        trgR.setEndInclusive(srcR.isEndInclusive());
+        trgR.setBeginRange(srcR.getBeginRange());
+        trgR.setEndRange(srcR.getEndRange());
+        // copy the user and perm pools:
+        trgR.setOsP(srcR.getOsP());
+        trgR.setOsU(srcR.getOsU());
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/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
index a268054..f3ae25a 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/Group.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/Group.java
@@ -20,7 +20,7 @@
 package org.apache.directory.fortress.core.model;
 
 
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
+import org.apache.directory.fortress.core.util.PropUtil;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -287,7 +287,7 @@ public class Group extends FortEntity implements Serializable
      */
     public void setProperties( String properties )
     {
-        setProperties( AttrHelper.getProperties( properties, '=', "," ) );
+        setProperties( PropUtil.getProperties( properties, '=', "," ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/util/AuditUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/AuditUtil.java b/src/main/java/org/apache/directory/fortress/core/util/AuditUtil.java
new file mode 100755
index 0000000..00f43c4
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/util/AuditUtil.java
@@ -0,0 +1,70 @@
+/*
+ *   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.util;
+
+
+import java.util.StringTokenizer;
+
+/**
+ * Class contains static utilities for conversions of ldap data to/from audit format
+ * These are low-level data utilities and no validations are performed.  These apis should
not be called by outside programs.
+ * <p/>
+ * This class is thread safe.
+ * <p/>
+
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class AuditUtil
+{
+
+    /**
+     * Private constructor
+     *
+     */
+    private AuditUtil()
+    {
+    }
+
+    /**
+     * Parse a raw slapd access log format data string for userId.
+     *
+     * @param inputString raw slapd access log data.
+     * @return string containing userId.
+     */
+    public static String getAuthZId(String inputString)
+    {
+        //reqAuthzID               <uid=fttu3user4,ou=people,dc=jts,dc=com>
+        String userId = null;
+        if (inputString != null && inputString.length() > 0)
+        {
+            StringTokenizer maxTkn = new StringTokenizer(inputString, ",");
+            if (maxTkn.countTokens() > 0)
+            {
+                String val = maxTkn.nextToken();
+                int indx = val.indexOf('=');
+                if (indx >= 1)
+                {
+                    userId = val.substring(indx + 1);
+                }
+            }
+        }
+        return userId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/util/PropUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/PropUtil.java b/src/main/java/org/apache/directory/fortress/core/util/PropUtil.java
new file mode 100644
index 0000000..ff8ef99
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/util/PropUtil.java
@@ -0,0 +1,128 @@
+/*
+ *   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.util;
+
+import org.apache.directory.fortress.core.GlobalIds;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ *  Utilities to convert to/from property formats.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class PropUtil
+{
+    /**
+     * Convert from a {@link java.util.List} of properties stored as name:value pairs to
+     * a {@link java.util.Properties}.
+     *
+     * @param propList contains a list of name-value pairs separated by a ':'.
+     * @return reference to a Properties collection.
+     */
+    public static Properties getProperties(List<String> propList)
+    {
+        return getProperties(propList, GlobalIds.PROP_SEP );
+    }
+
+    /**
+     * Convert from a {@link java.util.List} of properties stored as name:value pairs to
+     * a {@link java.util.Properties}.
+     *
+     * @param propList contains a list of name-value pairs separated by a ':'.
+     * @param separator contains char to be used to separate key and value.
+     * @return reference to a Properties collection.
+     */
+    public static Properties getProperties( List<String> propList, char separator )
+    {
+        Properties props = null;
+        if (propList != null && propList.size() > 0)
+        {
+            props = new Properties();
+            propList.size();
+            for (String raw : propList)
+            {
+                int indx = raw.indexOf(separator);
+                if (indx >= 1)
+                {
+                    props.setProperty(raw.substring(0, indx), raw.substring(indx + 1));
+                }
+            }
+        }
+        return props;
+    }
+
+    /**
+     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
+     *
+     * @param inputString contains comma delimited list of properties.
+     * @return java collection class containing props.
+     */
+    public static Properties getProperties( String inputString )
+    {
+        return getProperties( inputString, GlobalIds.PROP_SEP );
+    }
+
+    /**
+     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
+     *
+     * @param inputString contains comma delimited list of properties.
+     * @param separator contains char to be used to separate key and value.
+     * @return java collection class containing props.
+     */
+    public static Properties getProperties( String inputString, char separator )
+    {
+        return getProperties( inputString, separator, GlobalIds.DELIMITER );
+    }
+
+    /**
+     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
+     *
+     * @param inputString contains comma delimited list of properties.
+     * @param separator contains char to be used to separate key and value.
+     * @param delimiter contains a single char specifying delimiter between properties.
+     * @return java collection class containing props.
+     */
+    public static Properties getProperties( String inputString, char separator, String delimiter
)
+    {
+        Properties props = new Properties();
+        if (inputString != null && inputString.length() > 0)
+        {
+            StringTokenizer maxTkn = new StringTokenizer(inputString, delimiter);
+            if (maxTkn.countTokens() > 0)
+            {
+                while (maxTkn.hasMoreTokens())
+                {
+                    String val = maxTkn.nextToken();
+                    int indx = val.indexOf(separator);
+                    if (indx >= 1)
+                    {
+                        String name = val.substring(0, indx).trim();
+                        String value = val.substring(indx + 1).trim();
+                        props.setProperty(name, value);
+                    }
+                }
+            }
+        }
+        return props;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/util/attr/AttrHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/attr/AttrHelper.java b/src/main/java/org/apache/directory/fortress/core/util/attr/AttrHelper.java
deleted file mode 100755
index 1fe6024..0000000
--- a/src/main/java/org/apache/directory/fortress/core/util/attr/AttrHelper.java
+++ /dev/null
@@ -1,231 +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.util.attr;
-
-import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
-import org.apache.directory.api.ldap.model.name.Dn;
-import org.apache.directory.api.ldap.model.name.Rdn;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.Administrator;
-import org.apache.directory.fortress.core.model.AuthZ;
-import org.apache.directory.fortress.core.model.Permission;
-import org.apache.directory.fortress.core.util.ObjUtil;
-
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Properties;
-
-/**
- * Class contains static utilities for various conversions of ldap data to application entity
and back.  These methods are called by the
- * Fortress DAO's, i.e. {@link org.apache.directory.fortress.core.impl.UserDAO}.
- * These are low-level data utilities and no validations are performed.  These apis should
not be called by outside programs.
- * <p/>
- * This class is thread safe.
- * <p/>
-
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public final class AttrHelper
-{
-
-    /**
-     * Private constructor
-     *
-     */
-    private AttrHelper()
-    {
-    }
-
-    /**
-     * Perform copy on ARBAC attributes.  This is used during assignment of {@link org.apache.directory.fortress.core.model.AdminRole}
to {@link org.apache.directory.fortress.core.model.User}.
-     * This method does not perform input validations.
-     *
-     * @param srcR contains source attributes to copy.
-     * @param trgR contains the target reference.
-     */
-    public static void copyAdminAttrs(Administrator srcR, Administrator trgR)
-    {
-        trgR.setBeginInclusive(srcR.isBeginInclusive());
-        trgR.setEndInclusive(srcR.isEndInclusive());
-        trgR.setBeginRange(srcR.getBeginRange());
-        trgR.setEndRange(srcR.getEndRange());
-        // copy the user and perm pools:
-        trgR.setOsP(srcR.getOsP());
-        trgR.setOsU(srcR.getOsU());
-    }
-
-    /**
-     * Convert from a {@link java.util.List} of properties stored as name:value pairs to
-     * a {@link java.util.Properties}.
-     *
-     * @param propList contains a list of name-value pairs separated by a ':'.
-     * @return reference to a Properties collection.
-     */
-    public static Properties getProperties(List<String> propList)
-    {
-        return getProperties(propList, GlobalIds.PROP_SEP );
-    }
-
-    /**
-     * Convert from a {@link java.util.List} of properties stored as name:value pairs to
-     * a {@link java.util.Properties}.
-     *
-     * @param propList contains a list of name-value pairs separated by a ':'.
-     * @param separator contains char to be used to separate key and value.
-     * @return reference to a Properties collection.
-     */
-    public static Properties getProperties( List<String> propList, char separator )
-    {
-        Properties props = null;
-        if (propList != null && propList.size() > 0)
-        {
-            props = new Properties();
-            propList.size();
-            for (String raw : propList)
-            {
-                int indx = raw.indexOf(separator);
-                if (indx >= 1)
-                {
-                    props.setProperty(raw.substring(0, indx), raw.substring(indx + 1));
-                }
-            }
-        }
-        return props;
-    }
-
-    /**
-     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
-     *
-     * @param inputString contains comma delimited list of properties.
-     * @return java collection class containing props.
-     */
-    public static Properties getProperties( String inputString )
-    {
-        return getProperties( inputString, GlobalIds.PROP_SEP );
-    }
-
-    /**
-     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
-     *
-     * @param inputString contains comma delimited list of properties.
-     * @param separator contains char to be used to separate key and value.
-     * @return java collection class containing props.
-     */
-    public static Properties getProperties( String inputString, char separator )
-    {
-        return getProperties( inputString, separator, GlobalIds.DELIMITER );
-    }
-
-    /**
-     * Convert from a comma delimited list of name-value pairs separated by a ':'.  Return
the pros as {@link java.util.Properties}.
-     *
-     * @param inputString contains comma delimited list of properties.
-     * @param separator contains char to be used to separate key and value.
-     * @param delimiter contains a single char specifying delimiter between properties.
-     * @return java collection class containing props.
-     */
-    public static Properties getProperties( String inputString, char separator, String delimiter
)
-    {
-        Properties props = new Properties();
-        if (inputString != null && inputString.length() > 0)
-        {
-            StringTokenizer maxTkn = new StringTokenizer(inputString, delimiter);
-            if (maxTkn.countTokens() > 0)
-            {
-                while (maxTkn.hasMoreTokens())
-                {
-                    String val = maxTkn.nextToken();
-                    int indx = val.indexOf(separator);
-                    if (indx >= 1)
-                    {
-                        String name = val.substring(0, indx).trim();
-                        String value = val.substring(indx + 1).trim();
-                        props.setProperty(name, value);
-                    }
-                }
-            }
-        }
-        return props;
-    }
-
-    /**
-     * Parse a raw slapd access log format data string for userId.
-     *
-     * @param inputString raw slapd access log data.
-     * @return string containing userId.
-     */
-    public static String getAuthZId(String inputString)
-    {
-        //reqAuthzID               <uid=fttu3user4,ou=people,dc=jts,dc=com>
-        String userId = null;
-        if (inputString != null && inputString.length() > 0)
-        {
-            StringTokenizer maxTkn = new StringTokenizer(inputString, ",");
-            if (maxTkn.countTokens() > 0)
-            {
-                String val = maxTkn.nextToken();
-                int indx = val.indexOf('=');
-                if (indx >= 1)
-                {
-                    userId = val.substring(indx + 1);
-                }
-            }
-        }
-        return userId;
-    }
-
-
-    /**
-     * Break the authZ eqDn attribute into 1. permission object name, 2. op name and 3. object
id (optional).
-     *
-     * @param authZ contains the raw dn format from openldap slapo access log data
-     * @return Permisison containing objName, opName and optionally the objId populated from
the raw data.
-     */
-    public static Permission getAuthZPerm(AuthZ authZ) throws LdapInvalidDnException
-    {
-        // This will be returned to the caller:
-        Permission pOp = new Permission();
-        // Break dn into rdns for leaf and parent.  Use the 'type' field in rdn.
-        // The objId value is optional.  If present it will be part of the parent's relative
distinguished name..
-        // Here the sample reqDN=ftOpNm=TOP2_2+ftObjId=002,ftObjNm=TOB2_1,ou=Permissions,ou=RBAC,dc=example,dc=com
-        // Will be mapped to objName=TOB2_1, opName=TOP2_2, objId=002, in the returned permission
object.
-        Dn dn = new Dn( authZ.getReqDN() );
-        if(dn != null && dn.getRdns() != null && ObjUtil.isNotNullOrEmpty(
dn.getRdns() ) )
-        {
-            for( Rdn rdn : dn.getRdns() )
-            {
-                // The rdn type attribute will be mapped to objName, opName and objId fields.
-                switch ( rdn.getType() )
-                {
-                    case GlobalIds.POP_NAME:
-                        pOp.setOpName( rdn.getType() );
-                        break;
-                    case GlobalIds.POBJ_NAME:
-                        pOp.setObjName( rdn.getType() );
-                        break;
-                    case GlobalIds.POBJ_ID:
-                        pOp.setObjId( rdn.getType() );
-                        break;
-                }
-            }
-        }
-        return pOp;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/main/java/org/apache/directory/fortress/core/util/attr/package.html
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/attr/package.html b/src/main/java/org/apache/directory/fortress/core/util/attr/package.html
deleted file mode 100755
index e2a7c8c..0000000
--- a/src/main/java/org/apache/directory/fortress/core/util/attr/package.html
+++ /dev/null
@@ -1,33 +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.
- *
--->
-<html>
-   <head>
-      <title>Package Documentation for org.apache.directory.fortress.core.util.attr</title>
-   </head>
-   <body>
-      <p>
-         This package contains utilities used for data validation and formatting by fortress
process modules.
-      </p>
-      <p>
-         The <b>org.apache.directory.fortress.core.util.attr</b> package contains
utilities to format and validate low level attributes both inbound and outbound to ldap server.
 The apis contained within this package are used by fortress process modules and are not intended
for external use.
-          See the corresponding javadoc contained with this package for more info.
-      </p>
-   </body>
-</html>

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1344104a/src/test/java/org/apache/directory/fortress/core/AuditMgrConsole.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/AuditMgrConsole.java b/src/test/java/org/apache/directory/fortress/core/AuditMgrConsole.java
index dad2473..5e8cb0b 100755
--- a/src/test/java/org/apache/directory/fortress/core/AuditMgrConsole.java
+++ b/src/test/java/org/apache/directory/fortress/core/AuditMgrConsole.java
@@ -21,13 +21,16 @@ package org.apache.directory.fortress.core;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
 import org.apache.directory.fortress.core.model.Bind;
 import org.apache.directory.fortress.core.model.AuthZ;
 import org.apache.directory.fortress.core.model.Mod;
 import org.apache.directory.fortress.core.impl.TestUtils;
 import org.apache.directory.fortress.core.model.UserAudit;
 import org.apache.directory.fortress.core.model.Permission;
-import org.apache.directory.fortress.core.util.attr.AttrHelper;
+import org.apache.directory.fortress.core.util.ObjUtil;
+import org.apache.directory.fortress.core.util.AuditUtil;
 import org.apache.directory.fortress.core.util.time.TUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -156,7 +159,7 @@ class AuditMgrConsole
                 */
                 System.out.println("AUTHENTICATION AUDIT RECORD " + ctr++);
                 System.out.println("***************************************");
-                System.out.println("    UserId        " + AttrHelper.getAuthZId(aBind.getReqDN()));
+                System.out.println("    UserId        " + AuditUtil.getAuthZId( aBind.getReqDN()
));
                 Date aDate = null;
                 try
                 {
@@ -450,10 +453,10 @@ class AuditMgrConsole
                     System.out.println("    Access Time     " + formattedDate);
                 }
 
-                System.out.println("    userId          " + AttrHelper.getAuthZId(authZ.getReqAuthzID()));
+                System.out.println("    userId          " + AuditUtil.getAuthZId( authZ.getReqAuthzID()
));
                 try
                 {
-                    Permission pOp = AttrHelper.getAuthZPerm(authZ);
+                    Permission pOp = getAuthZPerm(authZ);
                     System.out.println("    Resource Name   " + pOp.getObjName());
                     System.out.println("    Operation       " + pOp.getOpName());
                     int rCtr = 0;
@@ -484,6 +487,43 @@ class AuditMgrConsole
         }
     }
 
+    /**
+     * Break the authZ eqDn attribute into 1. permission object name, 2. op name and 3. object
id (optional).
+     *
+     * @param authZ contains the raw dn format from openldap slapo access log data
+     * @return Permisison containing objName, opName and optionally the objId populated from
the raw data.
+     */
+    public static Permission getAuthZPerm(AuthZ authZ) throws LdapInvalidDnException
+    {
+        // This will be returned to the caller:
+        Permission pOp = new Permission();
+        // Break dn into rdns for leaf and parent.  Use the 'type' field in rdn.
+        // The objId value is optional.  If present it will be part of the parent's relative
distinguished name..
+        // Here the sample reqDN=ftOpNm=TOP2_2+ftObjId=002,ftObjNm=TOB2_1,ou=Permissions,ou=RBAC,dc=example,dc=com
+        // Will be mapped to objName=TOB2_1, opName=TOP2_2, objId=002, in the returned permission
object.
+        Dn dn = new Dn( authZ.getReqDN() );
+        if(dn != null && dn.getRdns() != null && ObjUtil.isNotNullOrEmpty(
dn.getRdns() ) )
+        {
+            for( Rdn rdn : dn.getRdns() )
+            {
+                // The rdn type attribute will be mapped to objName, opName and objId fields.
+                switch ( rdn.getType() )
+                {
+                    case GlobalIds.POP_NAME:
+                        pOp.setOpName( rdn.getType() );
+                        break;
+                    case GlobalIds.POBJ_NAME:
+                        pOp.setObjName( rdn.getType() );
+                        break;
+                    case GlobalIds.POBJ_ID:
+                        pOp.setObjId( rdn.getType() );
+                        break;
+                }
+            }
+        }
+        return pOp;
+    }
+
     void printfailedAuthNReport(List<AuthZ> list)
     {
         ReaderUtil.clearScreen();
@@ -541,7 +581,7 @@ class AuditMgrConsole
                     String formattedDate = formatter.format(aDate);
                     System.out.println("    Access Time     " + formattedDate);
                 }
-                System.out.println("    userId          " + AttrHelper.getAuthZId(authZ.getReqDN()));
+                System.out.println("    userId          " + AuditUtil.getAuthZId( authZ.getReqDN()
));
                 System.out.println("    Success?        " + authZ.getReqEntries().equals("1"));
                 System.out.println("    reqDN           " + authZ.getReqDN());
                 System.out.println();


Mime
View raw message