Author: chathura
Date: Wed Dec 19 21:39:44 2007
New Revision: 11606

Log:


More authorization related improvements.



Modified:
   
branches/registry/0_1/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
   
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
   
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
   branches/registry/0_1/modules/webapps/src/main/webapp/admin/header.jsp
   branches/registry/0_1/modules/webapps/src/main/webapp/admin/permisions.jsp
   
branches/registry/0_1/modules/webapps/src/main/webapp/admin/registry-resources.jsp

Modified: 
branches/registry/0_1/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
--- 
branches/registry/0_1/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
       (original)
+++ 
branches/registry/0_1/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
       Wed Dec 19 21:39:44 2007
@@ -30,6 +30,8 @@
 import org.wso2.usermanager.acl.realm.AuthorizingRealmConfig;
 
 import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Registry implementation to perform authentication and authorization. Each 
user should use a
@@ -333,7 +335,27 @@
                               Date to,
                               boolean recentFirst)
             throws RegistryException {
+        
         User.setCurrentUser(userID);
-        return registry.getLogs(resourcePath, action, userName, from, to, 
recentFirst);
+
+        LogEntry[] allEntries =
+                registry.getLogs(resourcePath, action, userName, from, to, 
recentFirst);
+
+        // remove logs about resource for which the current user doesn't get 
read permission.
+        List authorizedEnListList = new ArrayList();
+        for (int i = 0; i < allEntries.length; i++) {
+
+            try {
+                if (authorizer.isUserAuthorized(userID, 
allEntries[i].getResourcePath(), ActionConstants.GET)) {
+                    authorizedEnListList.add(allEntries[i]);
+                }
+            } catch (UserManagerException e) {
+                continue;
+            }
+        }
+
+        LogEntry[] authorizedLogs = (LogEntry[]) authorizedEnListList.
+                toArray(new LogEntry[authorizedEnListList.size()]);
+        return authorizedLogs;
     }
 }

Modified: 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
==============================================================================
--- 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
    (original)
+++ 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
    Wed Dec 19 21:39:44 2007
@@ -62,6 +62,8 @@
         if (userRegistry != null) {
             request.getSession().setAttribute(UIConstants.USER_ATTR, 
userRegistry.getUserID());
 
+            request.getSession().setAttribute(UIConstants.IS_LOGGED_IN_ATTR, 
new Boolean(true));
+
             try {
                 boolean isAdmin = UserUtil.isAdmin(request, 
userRegistry.getUserID());
                 request.getSession().setAttribute(UIConstants.IS_ADMIN_ATTR, 
new Boolean(isAdmin));
@@ -73,6 +75,7 @@
 
         } else {
             request.getSession().setAttribute(UIConstants.USER_ATTR, 
RegistryConstants.ANONYMOUS_USER);
+            request.getSession().setAttribute(UIConstants.IS_LOGGED_IN_ATTR, 
new Boolean(false));
         }
 
         String uri = request.getRequestURI();

Modified: 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
==============================================================================
--- 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
  (original)
+++ 
branches/registry/0_1/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
  Wed Dec 19 21:39:44 2007
@@ -35,6 +35,7 @@
     public static final String PATH_ATTR = "path";
     public static final String USER_ATTR = "currentUser";
     public static final String IS_ADMIN_ATTR = "is.admin";
+    public static final String IS_LOGGED_IN_ATTR = "is.logged.in";
     public static final String QUERY_ATTR = "regQuery";
 
     public static final String ERROR_CODE = "error.code";

Modified: branches/registry/0_1/modules/webapps/src/main/webapp/admin/header.jsp
==============================================================================
--- branches/registry/0_1/modules/webapps/src/main/webapp/admin/header.jsp      
(original)
+++ branches/registry/0_1/modules/webapps/src/main/webapp/admin/header.jsp      
Wed Dec 19 21:39:44 2007
@@ -56,6 +56,12 @@
         if (isAdminObject != null) {
             isAdmin = isAdminObject.booleanValue();
         }
+
+        Boolean isLoggedObject = (Boolean) 
request.getSession().getAttribute(UIConstants.IS_LOGGED_IN_ATTR);
+        boolean isLogged = false;
+        if (isLoggedObject != null) {
+            isLogged = isLoggedObject.booleanValue();
+        }
     %>
                <table cellpadding="0" cellspacing="0" border="0" 
style="width:100%">
                        <tr>
@@ -99,12 +105,14 @@
                                                                <img 
src="/wso2registry/admin/images/icon-people-small.gif" border="0" align="top" 
/> People
                                                                </a>
                                                        </td>
-                                                       <td class="top-menu">
+                            <% if (isLogged) { %>
+                            <td class="top-menu">
                                                                <a 
href="/wso2registry/system/activity/new">
                                                                <img 
src="/wso2registry/admin/images/icon-recent-activity-small.gif" border="0" 
align="top"  /> Activity
                                                                </a>
                                                        </td>
-                            <% if (isAdmin) { %>
+                            <% } %>
+                            <% if (isLogged) { %>
                             <td class="top-menu">
                                                                <a 
href="/wso2registry/system/admin">
                                                                <img 
src="/wso2registry/admin/images/icon-admin.gif" border="0" align="top"  /> Admin

Modified: 
branches/registry/0_1/modules/webapps/src/main/webapp/admin/permisions.jsp
==============================================================================
--- branches/registry/0_1/modules/webapps/src/main/webapp/admin/permisions.jsp  
(original)
+++ branches/registry/0_1/modules/webapps/src/main/webapp/admin/permisions.jsp  
Wed Dec 19 21:39:44 2007
@@ -6,10 +6,10 @@
 <%
     ResourceDetailsAction resource = (ResourceDetailsAction) 
request.getSession().getAttribute(UIConstants.RESOURCE_BEAN);
 %>
-<h3>User Permisions</h3>
+<h3>User Permissions</h3>
 <div id="userPermisionsDiv" class="userPermisionsDiv leftSpace">
 
-<h4>Add New Permisions</h4>
+<h4>Add New Permissions</h4>
 <table width="100%" border="0" cellpadding="5" cellspacing="0">
     <tr>
         <form action="/wso2registry/system/authorize" theme="simple" 
method="post">
@@ -43,7 +43,7 @@
         </form>
     </tr>
 </table>
-<h4 style="margin-top:10px;">Defined User Permisions</h4>
+<h4 style="margin-top:10px;">Defined User Permissions</h4>
 <form name="permissions" action="/wso2registry/system/authorize/mass" 
theme="simple" method="post">
     <input type="hidden" id="pInput" name="permissionInput" value=""/>
     <input type="hidden" name="pathToAuthorize" value="%{path}"/>
@@ -86,7 +86,7 @@
 </form>
 </div>
 
-<h3 style="padding-top:20px;">Role Permisions</h3>
+<h3 style="padding-top:20px;">Role Permissions</h3>
 <div id="rolePermisionsDiv" class="rolePermisionsDiv leftSpace">
 <h4>New Role Permisions</h4>
 <table width="100%" border="0" cellpadding="5" cellspacing="0">
@@ -122,7 +122,7 @@
         </form>
     </tr>
 </table>
-<h4 style="margin-top:10px;">Defined Role Permisions</h4>
+<h4 style="margin-top:10px;">Defined Role Permissions</h4>
 <form name="rolePermissions" action="/wso2registry/system/authorizeRoles" 
theme="simple" method="post">
     <input type="hidden" id="pRoleInput" name="permissionInput" value=""/>
     <input type="hidden" name="pathToAuthorize" value="%{path}"/>

Modified: 
branches/registry/0_1/modules/webapps/src/main/webapp/admin/registry-resources.jsp
==============================================================================
--- 
branches/registry/0_1/modules/webapps/src/main/webapp/admin/registry-resources.jsp
  (original)
+++ 
branches/registry/0_1/modules/webapps/src/main/webapp/admin/registry-resources.jsp
  Wed Dec 19 21:39:44 2007
@@ -363,7 +363,7 @@
         <tr>
             <td valign="top" style="padding-top:0px;width:14px;"><img 
src="/wso2registry/admin/images/box1-lefttop.jpg" /></td>
             <td valign="top">
-                <h2>Permisions</h2>
+                <h2>Permissions</h2>
             </td>
             <td align="right" valign="top">
                 <a href="#" 
onclick="showHideCommon('perIconExpanded');showHideCommon('perIconMinimized');showHideCommon('perExpanded');showHideCommon('perMinimized');">

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to