directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-commander git commit: FC-79 - add common utils to web component
Date Thu, 12 Mar 2015 17:03:15 GMT
Repository: directory-fortress-commander
Updated Branches:
  refs/heads/master 5902e7942 -> 7e1657c31


FC-79 - add common utils to web component


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/commit/7e1657c3
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/tree/7e1657c3
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/diff/7e1657c3

Branch: refs/heads/master
Commit: 7e1657c3155e65779b7e23de82aba734736dcd69
Parents: 5902e79
Author: Shawn McKinney <smckinney@apache.org>
Authored: Thu Mar 12 12:02:39 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Thu Mar 12 12:02:39 2015 -0500

----------------------------------------------------------------------
 .../fortress/web/FtBookmarkablePageLink.java    | 52 +++++++++++++++++++-
 .../apache/directory/fortress/web/SecUtils.java | 13 +++++
 2 files changed, 63 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/7e1657c3/src/main/java/org/apache/directory/fortress/web/FtBookmarkablePageLink.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/web/FtBookmarkablePageLink.java b/src/main/java/org/apache/directory/fortress/web/FtBookmarkablePageLink.java
index 6bb77f7..4f8a98d 100644
--- a/src/main/java/org/apache/directory/fortress/web/FtBookmarkablePageLink.java
+++ b/src/main/java/org/apache/directory/fortress/web/FtBookmarkablePageLink.java
@@ -1,8 +1,56 @@
+/*
+ *   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.web;
 
+
+import org.apache.directory.fortress.core.rbac.Permission;
+import org.apache.log4j.Logger;
+import org.apache.wicket.Page;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+
+
 /**
- * Created by smckinn on 3/12/15.
+ * This link requires the id format be: objname.operationname
+ * where name maps to ft perm obj name and op maps to ft perm op name.
+ * If match not found link will quietly not display the link on page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
  */
-public class FtBookmarkablePageLink
+public class FtBookmarkablePageLink extends BookmarkablePageLink
 {
+    private static final Logger LOG = Logger.getLogger( FtBookmarkablePageLink.class.getName()
);
+    Permission perm;
+
+    public <C extends Page> FtBookmarkablePageLink( String id, Class<C> pageClass
)
+    {
+        super( id, pageClass );
+        perm = SecUtils.getPermFromId( id );
+        if ( perm != null && SecUtils.isFound( perm, this ) )
+        {
+            LOG.debug( "FtBookmarkablePageLink id: " + id + ", status found" );
+        }
+        else
+        {
+            LOG.debug( "FtBookmarkablePageLink id: " + id + ", status NOT found" );
+            setVisible( false );
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/7e1657c3/src/main/java/org/apache/directory/fortress/web/SecUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/web/SecUtils.java b/src/main/java/org/apache/directory/fortress/web/SecUtils.java
index 10b3161..ff70914 100644
--- a/src/main/java/org/apache/directory/fortress/web/SecUtils.java
+++ b/src/main/java/org/apache/directory/fortress/web/SecUtils.java
@@ -371,4 +371,17 @@ public class SecUtils
         return isLoggedIn;
     }
 
+    public static Permission getPermFromId( String id )
+    {
+        Permission perm = null;
+        String[] parts = id.split( "\\." );
+        if(parts != null && parts.length > 1)
+        {
+            String objName = parts[0];
+            String opName = parts[1];
+            perm = new Permission( objName, opName );
+        }
+        return perm;
+    }
+
 }


Mime
View raw message