shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r1331036 - in /shiro/trunk: core/src/main/java/org/apache/shiro/mgt/ core/src/test/groovy/org/apache/shiro/mgt/ support/ support/faces/ support/faces/src/ support/faces/src/main/ support/faces/src/main/java/ support/faces/src/main/java/org/...
Date Thu, 26 Apr 2012 19:15:15 GMT
Author: lhazlewood
Date: Thu Apr 26 19:15:13 2012
New Revision: 1331036

URL: http://svn.apache.org/viewvc?rev=1331036&view=rev
Log:
SHIRO-206: Added initial implementation based on patch

Added:
    shiro/trunk/support/faces/   (with props)
    shiro/trunk/support/faces/pom.xml
    shiro/trunk/support/faces/src/
    shiro/trunk/support/faces/src/main/
    shiro/trunk/support/faces/src/main/java/
    shiro/trunk/support/faces/src/main/java/org/
    shiro/trunk/support/faces/src/main/java/org/apache/
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java   (with props)
    shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java   (with props)
    shiro/trunk/support/faces/src/main/resources/
    shiro/trunk/support/faces/src/main/resources/META-INF/
    shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml   (with props)
    shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml   (with props)
Modified:
    shiro/trunk/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java
    shiro/trunk/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy
    shiro/trunk/support/pom.xml

Modified: shiro/trunk/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java
URL: http://svn.apache.org/viewvc/shiro/trunk/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java?rev=1331036&r1=1331035&r2=1331036&view=diff
==============================================================================
--- shiro/trunk/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java (original)
+++ shiro/trunk/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java Thu Apr 26 19:15:13 2012
@@ -182,7 +182,7 @@ public class DefaultSubjectDAO implement
                 session = subject.getSession();
                 session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY, currentPrincipals);
             }
-            //otherwise no session and no principals - nothing to save
+            // otherwise no session and no principals - nothing to save
         } else {
             PrincipalCollection existingPrincipals =
                     (PrincipalCollection) session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
@@ -191,12 +191,23 @@ public class DefaultSubjectDAO implement
                 if (!CollectionUtils.isEmpty(existingPrincipals)) {
                     session.removeAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
                 }
-                //otherwise both are null or empty - no need to update the session
+                // otherwise both are null or empty - no need to update the session
             } else {
                 if (!currentPrincipals.equals(existingPrincipals)) {
                     session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY, currentPrincipals);
                 }
-                //otherwise they're the same - no need to update the session
+                /*
+                PrincipalCollection previousPrincipals = null;
+                if (subject.isRunAs()) {
+                    previousPrincipals = subject.getPreviousPrincipals();
+                }
+
+                currentPrincipals = CollectionUtils.isEmpty(previousPrincipals) ? currentPrincipals : previousPrincipals;
+                if (currentPrincipals != null && !currentPrincipals.equals(existingPrincipals)) {
+                    session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY, currentPrincipals);
+                }
+                 */
+                // otherwise they're the same - no need to update the session
             }
         }
     }

Modified: shiro/trunk/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy
URL: http://svn.apache.org/viewvc/shiro/trunk/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy?rev=1331036&r1=1331035&r2=1331036&view=diff
==============================================================================
--- shiro/trunk/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy (original)
+++ shiro/trunk/core/src/test/groovy/org/apache/shiro/mgt/DefaultSubjectDAOTest.groovy Thu Apr 26 19:15:13 2012
@@ -22,6 +22,7 @@ import org.apache.shiro.session.Session
 import org.apache.shiro.subject.PrincipalCollection
 import org.apache.shiro.subject.Subject
 import org.apache.shiro.subject.support.DefaultSubjectContext
+
 import static org.easymock.EasyMock.*
 
 /**
@@ -217,9 +218,25 @@ class DefaultSubjectDAOTest extends Groo
      * yet reflect those principals.  In this case, the session will be accessed and the session will be set with the
      * Subject's principals.
      */
-    void testMergePrincipalsWithSubjectPrincipalsButWithoutSessionPrincipals() {
-        testMergePrincipalsWithSubjectPrincipalsButWithSessionPrincipals(null)
-    }
+    /*void testMergePrincipalsWithSubjectPrincipalsButWithoutSessionPrincipals() {
+        def dao = new DefaultSubjectDAO()
+        def subject = createStrictMock(Subject)
+        def session = createStrictMock(Session)
+        def subjectPrincipals = createStrictMock(PrincipalCollection)
+
+        expect(subject.principals).andReturn subjectPrincipals
+        expect(subject.getSession(false)).andReturn session
+        expect(subjectPrincipals.isEmpty()).andReturn false
+
+        expect(session.getAttribute(eq(DefaultSubjectContext.PRINCIPALS_SESSION_KEY))).andReturn null
+        session.setAttribute(eq(DefaultSubjectContext.PRINCIPALS_SESSION_KEY), same(subjectPrincipals))
+
+        replay subject, session, subjectPrincipals
+
+        dao.mergePrincipals(subject)
+
+        verify subject, session, subjectPrincipals
+    }*/
 
     /**
      * Tests the case when the Subject has a Session and the Subject has associated principals, but the session reflects

Propchange: shiro/trunk/support/faces/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Apr 26 19:15:13 2012
@@ -0,0 +1 @@
+*.iml

Added: shiro/trunk/support/faces/pom.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/pom.xml?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/pom.xml (added)
+++ shiro/trunk/support/faces/pom.xml Thu Apr 26 19:15:13 2012
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-root</artifactId>
+        <version>1.3.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>shiro-faces</artifactId>
+    <name>Apache Shiro :: Support :: JSF</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.faces</groupId>
+            <artifactId>jsf-api</artifactId>
+            <version>2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- <dependency>
+            <groupId>com.sun.faces</groupId>
+            <artifactId>jsf-api</artifactId>
+            <version>2.0.3</version>
+            <scope>provided</scope>
+        </dependency> -->
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>org.apache.shiro.guice</Bundle-SymbolicName>
+                        <Export-Package>org.apache.shiro.guice*;version=${project.version}</Export-Package>
+                        <Import-Package>
+                            org.apache.shiro*;version="${shiro.osgi.importRange}",
+                            javax.faces*;version="[2.0, 3.0)",
+                            javax.el*;version="[1.0, 2.0)",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,50 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body only if the current user has executed a <b>successful</b> authentication attempt
+ * <em>during their current session</em>.
+ * <p/>
+ * This is more restrictive than the {@link UserTag}, which only
+ * ensures the current user is known to the system, either via a current login or from Remember Me services,
+ * which only makes the assumption that the current user is who they say they are, and does not guarantee it like
+ * this tag does.
+ * <p/>
+ * The logically opposite tag of this one is the {@link NotAuthenticatedTag}
+ *
+ * @since 1.3
+ */
+public class AuthenticatedTag extends SecureTagHandler {
+
+    public AuthenticatedTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody() {
+        return isAuthenticated();
+    }
+
+    protected boolean isAuthenticated() {
+        return getSubject() != null && getSubject().isAuthenticated();
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag handler which shows or hides body content based on the current Subject's authorization state.  'Authorization
+ * state' means whether or not they have or do not have a role or whether they are permitted to do something or not.
+ *
+ * @since 1.3
+ */
+public abstract class AuthorizationTagHandler extends SecureTagHandler {
+
+    private final TagAttribute name;
+
+    public AuthorizationTagHandler(TagConfig config) {
+        super(config);
+        this.name = this.getRequiredAttribute("name");
+    }
+
+    private String getAttrValue(FaceletContext ctx, TagAttribute attr) {
+        String value;
+        if (attr.isLiteral()) {
+            value = attr.getValue(ctx);
+        } else {
+            ValueExpression expression = attr.getValueExpression(ctx, String.class);
+            value = (String) expression.getValue(ctx);
+        }
+        return value;
+    }
+
+    @Override 
+    protected boolean showTagBody(FaceletContext ctx, UIComponent parent) {
+        String value = getAttrValue(ctx, name);
+        return showTagBody(value);
+    }
+    
+    protected boolean showTagBody(String nameAttributeValue) {
+        return false;
+    }
+}

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body if the current user <em>is not</em> known to the system, either because they
+ * haven't logged in yet, or because they have no 'RememberMe' identity.
+ *
+ * <p>The logically opposite tag of this one is the {@link UserTag}.  Please read that class's JavaDoc as it explains
+ * more about the differences between Authenticated/Unauthenticated and User/Guest semantic differences.
+ *
+ * @since 1.3
+ */
+public class GuestTag extends UserTag {
+
+    public GuestTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody() {
+        return !isUser();
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.StringUtils;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body only if the current user has <em>at least one</em> of the comma-delimited
+ * string permissions specified in <tt>name</tt> attribute.
+ *
+ * @since 1.3
+ */
+public class HasAnyPermissionsTag extends AuthorizationTagHandler {
+
+    public HasAnyPermissionsTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody(String commaDelimitedPermissions) {
+        boolean hasAnyPermission = false;
+
+        Subject subject = getSubject();
+
+        if (subject != null) {
+            // Iterate through permissions and check to see if the user has one of the permission
+            String[] permissions = StringUtils.split(commaDelimitedPermissions);
+            for (String permission : permissions) {
+                if (subject.isPermitted(permission)) {
+                    hasAnyPermission = true;
+                    break;
+                }
+            }
+        }
+
+        return hasAnyPermission;
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.StringUtils;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Displays body content if the current user has any of the roles specified.
+ *
+ * @since 1.3
+ */
+public class HasAnyRolesTag extends AuthorizationTagHandler {
+
+    public HasAnyRolesTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody(String commaDelimitedRoleNames) {
+        boolean hasAnyRole = false;
+
+        Subject subject = getSubject();
+
+        if (subject != null) {
+            // Iterate through roles and check to see if the user has one of the roles
+            String[] roleNames = StringUtils.split(commaDelimitedRoleNames);
+            for (String roleName : roleNames) {
+                if (subject.hasRole(roleName)) {
+                    hasAnyRole = true;
+                    break;
+                }
+            }
+        }
+
+        return hasAnyRole;
+    }
+
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,43 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body only if the current user has the string permissions
+ * specified in <tt>name</tt> attribute.
+ *
+ * @since 1.3
+ */
+public class HasPermissionTag extends AuthorizationTagHandler {
+
+    public HasPermissionTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody(String p) {
+        return isPermitted(p);
+    }
+    
+    protected boolean isPermitted(String p) {
+        return getSubject() != null && getSubject().isPermitted(p);
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * @since 1.3
+ */
+public class HasRoleTag extends AuthorizationTagHandler {
+
+    public HasRoleTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override 
+    protected boolean showTagBody(String value) {
+        return hasRole(value);
+    }
+    
+    protected boolean hasRole(String roleName) {
+        return getSubject() != null && getSubject().hasRole(roleName);
+    }
+}
\ No newline at end of file

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * @since 1.3
+ */
+public class LacksPermissionTag extends HasPermissionTag {
+
+    public LacksPermissionTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody(String p) {
+        return !isPermitted(p);
+    }
+
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,36 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * @since 1.3
+ */
+public class LacksRoleTag extends HasRoleTag {
+
+    public LacksRoleTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody(String value) {
+        return !hasRole(value);
+    }
+}
\ No newline at end of file

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,41 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body only if the current user has <em>not</em> executed a successful authentication
+ * attempt <em>during their current session</em>.
+ *
+ * <p>The logically opposite tag of this one is the {@link AuthenticatedTag}.
+ *
+ * @since 1.3
+ */
+public class NotAuthenticatedTag extends AuthenticatedTag {
+
+    public NotAuthenticatedTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody() {
+        return !isAuthenticated();
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,220 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import org.apache.shiro.subject.PrincipalCollection;
+
+import javax.faces.context.FacesContext;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+
+/**
+ * Tag used to print out the String value of a user's default principal,
+ * or a specific principal as specified by the tag's attributes.
+ * <p/>
+ * If no attributes are specified, the tag prints out the {@code toString()} value of the user's default principal.
+ * If the {@code type} attribute is specified, the tag looks for a principal with the given type.  If the
+ * {@code property} attribute is specified, the tag prints the string value of the specified property of the principal.
+ * If no principal is found or the user is not authenticated, the tag displays nothing unless a
+ * {@code defaultValue} is specified.
+ *
+ * @since 1.3
+ */
+public class PrincipalTag extends SecureComponent {
+
+    /**
+     * The type of principal to be retrieved, or null if the default principal should be used.
+     */
+    private String type;
+
+    /**
+     * The property name to retrieve of the principal, or null if the <tt>toString()</tt> value should be used.
+     */
+    private String property;
+
+    /**
+     * The default value that should be displayed if the user is not authenticated, or no principal is found.
+     */
+    private String defaultValue;
+
+    /*--------------------------------------------
+    |  A C C E S S O R S / M O D I F I E R S    |
+    ============================================*/
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getProperty() {
+        return property;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    /*--------------------------------------------
+    |               M E T H O D S               |
+    ============================================*/
+    @SuppressWarnings({"unchecked"})
+    @Override
+    protected void doEncodeAll(FacesContext ctx) throws IOException {
+        String strValue = null;
+
+        try {
+            if (getSubject() != null) {
+                // Get the principal to print out
+                Object principal;
+
+                if (type == null) {
+                    principal = getSubject().getPrincipal();
+                } else {
+                    principal = getPrincipalFromClassName();
+                }
+
+                // Get the string value of the principal
+                if (principal != null) {
+                    if (property == null) {
+                        strValue = principal.toString();
+                    } else {
+                        strValue = getPrincipalProperty(principal, property);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("Error getting principal type [" + type + "], property [" + property + "]: " + e.getMessage(), e);
+        }
+
+        if (strValue == null) {
+            strValue = defaultValue;
+        }
+
+        // Print out the principal value if not null
+        if (strValue != null) {
+            try {
+                ctx.getResponseWriter().write(strValue);
+            } catch (IOException e) {
+                throw new IOException("Error writing [" + strValue + "] to output.");
+            }
+        }
+    }
+
+    @SuppressWarnings({"unchecked"})
+    private Object getPrincipalFromClassName() {
+        Object principal = null;
+
+        try {
+            Class cls = Class.forName(type);
+            PrincipalCollection principals = getSubject().getPrincipals();
+            if (principals != null) {
+                principal = principals.oneByType(cls);
+            }
+        } catch (ClassNotFoundException e) {
+            if (log.isErrorEnabled()) {
+                log.error("Unable to find class for name [" + type + "]");
+            }
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Unknown error while getting principal for type [" + type + "]: " + e.getMessage(), e);
+            }
+        }
+        return principal;
+    }
+
+    private String getPrincipalProperty(Object principal, String property) throws IOException {
+        String strValue = null;
+
+        try {
+            BeanInfo bi = Introspector.getBeanInfo(principal.getClass());
+
+            // Loop through the properties to get the string value of the specified property
+            boolean foundProperty = false;
+            for (PropertyDescriptor pd : bi.getPropertyDescriptors()) {
+                if (pd.getName().equals(property) && (Modifier.isPublic(pd.getReadMethod().getModifiers()))) {
+                    Object value = null;
+                    try {
+                        pd.getReadMethod().setAccessible(true);
+                        value = pd.getReadMethod().invoke(principal, (Object[]) null);
+                    } finally {
+                        pd.getReadMethod().setAccessible(false);
+                    }
+                    strValue = String.valueOf(value);
+                    foundProperty = true;
+                    break;
+                }
+            }
+
+            if (!foundProperty) {
+                final String message = "Property [" + property + "] not found in principal of type [" + principal.getClass().getName() + "]";
+                if (log.isErrorEnabled()) {
+                    log.error(message);
+                }
+                throw new IOException(message);
+            }
+
+        } catch (Exception e) {
+            final String message = "Error reading property [" + property + "] from principal of type [" + principal.getClass().getName() + "]";
+            if (log.isErrorEnabled()) {
+                log.error(message, e);
+            }
+            throw new IOException(message);
+        }
+
+        return strValue;
+    }
+
+    // ----------------------------------------------------- StateHolder Methods
+    private Object[] values;
+
+    @Override
+    public Object saveState(FacesContext context) {
+        if (values == null) {
+            values = new Object[4];
+        }
+        values[0] = super.saveState(context);
+        values[1] = type;
+        values[2] = property;
+        values[3] = defaultValue;
+
+        return values;
+    }
+
+    @Override
+    public void restoreState(FacesContext context, Object state) {
+        values = (Object[]) state;
+        super.restoreState(context, values[0]);
+        type = (String) values[1];
+        property = (String) values[2];
+        defaultValue = (String) values[3];
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body only if the current user's identity (aka principals) is remembered from a
+ * successful authentication during a previous session and the user has <b>not</b> executed a successful authentication
+ * attempt during their current session.
+ * <p/>
+ * <b>Note:</b> This is <em>less</em> restrictive than the <code>AuthenticatedTag</code> since it only assumes
+ * the user is who they say they are <em>via Remember Me services</em>, which
+ * makes no guarantee the user is who they say they are.  The <code>AuthenticatedTag</code> however
+ * guarantees that the current user has logged in <em>during their current session</em>, proving they really are
+ * who they say they are.
+ *
+ * @since 1.3
+ */
+public class RememberedTag extends SecureTagHandler {
+
+    public RememberedTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody() {
+        return getSubject() != null && getSubject().isRemembered();
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+/**
+ * Base class for JSF components.
+ *
+ * <p>OBS: Your subclass is responsible for saving the state of the component. See {@link org.apache.shiro.web.faces.tags.PrincipalTag}'s
+ * StateHolder Methods for an exemple.
+ * 
+ * @since 1.3
+ */
+public abstract class SecureComponent extends UIOutput {
+
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    protected Subject getSubject() {
+        return SecurityUtils.getSubject();
+    }
+
+    @Override
+    public void encodeAll(FacesContext ctx) throws IOException {
+        verifyAttributes();
+        doEncodeAll(ctx);
+    }
+
+    protected void verifyAttributes() throws IOException {
+    }
+
+    protected abstract void doEncodeAll(FacesContext ctx) throws IOException;
+    
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,61 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+import java.io.IOException;
+
+/**
+ * Base class for all Shiro TagHandlers
+ * 
+ * @since 1.3
+ */
+public abstract class SecureTagHandler extends TagHandler {
+
+    public SecureTagHandler(TagConfig config) {
+        super(config);
+    }
+
+    protected Subject getSubject() {
+        return SecurityUtils.getSubject();
+    }
+
+    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException {
+        if (showTagBody(ctx, parent)) {
+            this.nextHandler.apply(ctx, parent);
+        }
+    }
+
+    protected boolean showTagBody(FaceletContext ctx, UIComponent parent) {
+        return showTagBody();
+    }
+
+    protected boolean showTagBody() {
+        return false;
+    }
+
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,51 @@
+/*
+ * 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.shiro.web.faces.tags;
+
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ * Tag that renders the tag body if the current user known to the system, either from a successful login attempt
+ * (not necessarily during the current session) or from 'RememberMe' services.
+ * <p/>
+ * <b>Note:</b> This is <em>less</em> restrictive than the <code>AuthenticatedTag</code> since it only assumes
+ * the user is who they say they are, either via a current session login <em>or</em> via Remember Me services, which
+ * makes no guarantee the user is who they say they are.  The <code>AuthenticatedTag</code> however
+ * guarantees that the current user has logged in <em>during their current session</em>, proving they really are
+ * who they say they are.
+ * <p/>
+ * The logically opposite tag of this one is the {@link GuestTag}.
+ *
+ * @since 1.3
+ */
+public class UserTag extends SecureTagHandler {
+
+    public UserTag(TagConfig config) {
+        super(config);
+    }
+
+    @Override
+    protected boolean showTagBody() {
+        return isUser();
+    }
+
+    protected boolean isUser() {
+        return getSubject() != null && getSubject().getPrincipal() != null;
+    }
+}

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java (added)
+++ shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java Thu Apr 26 19:15:13 2012
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides the Shiro JSF Tag Library implementations.
+ *
+ * <p>Shiro JSF Tags can be used to evalute or not evaluate (show or not show) parts of a JSF page
+ * based on the current user's authentication status and/or authorization (access control) abilities.</p>
+ *
+ * @since 1.3
+ */
+package org.apache.shiro.web.faces.tags;
+
+

Propchange: shiro/trunk/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml (added)
+++ shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml Thu Apr 26 19:15:13 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+              version="2.0"
+              metadata-complete="false">
+
+    <component>
+        <component-type>org.apache.shiro.web.faces.tags.PrincipalTag</component-type>
+        <component-class>org.apache.shiro.web.faces.tags.PrincipalTag</component-class>
+    </component>
+
+</faces-config>
\ No newline at end of file

Propchange: shiro/trunk/support/faces/src/main/resources/META-INF/faces-config.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml?rev=1331036&view=auto
==============================================================================
--- shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml (added)
+++ shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml Thu Apr 26 19:15:13 2012
@@ -0,0 +1,135 @@
+<?xml version="1.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.
+  -->
+<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibary_2_0.xsd"
+        version="2.0">
+
+    <namespace>http://shiro.apache.org/tags</namespace>
+
+    <tag>
+        <tag-name>user</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.UserTag</handler-class>
+    </tag>
+
+    <tag>
+        <tag-name>authenticated</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.AuthenticatedTag</handler-class>
+    </tag>
+
+    <tag>
+        <tag-name>guest</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.GuestTag</handler-class>
+    </tag>
+
+    <tag>
+        <tag-name>hasAnyPermissions</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.HasAnyPermissionsTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>hasAnyRoles</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.HasAnyRolesTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>hasPermission</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.HasPermissionTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>hasRole</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.HasRoleTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>lacksPermission</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.LacksPermissionTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>lacksRole</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.LacksRoleTag</handler-class>
+        <attribute>
+            <name>name</name>
+            <description></description>
+            <required>true</required>
+        </attribute>
+    </tag>
+
+    <tag>
+        <tag-name>notAuthenticated</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.NotAuthenticatedTag</handler-class>
+    </tag>
+
+    <tag>
+        <tag-name>remembered</tag-name>
+        <handler-class>org.apache.shiro.web.faces.tags.RememberedTag</handler-class>
+    </tag>
+
+    <tag>
+        <tag-name>principal</tag-name>
+        <component>
+            <component-type>org.apache.shiro.web.faces.tags.PrincipalTag</component-type>
+        </component>
+        <attribute>
+            <name>type</name>
+            <description></description>
+            <required>false</required>
+        </attribute>
+        <attribute>
+            <name>property</name>
+            <description></description>
+            <required>false</required>
+        </attribute>
+        <attribute>
+            <name>defaultValue</name>
+            <description></description>
+            <required>false</required>
+        </attribute>
+    </tag>
+
+</facelet-taglib>
+

Propchange: shiro/trunk/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: shiro/trunk/support/pom.xml
URL: http://svn.apache.org/viewvc/shiro/trunk/support/pom.xml?rev=1331036&r1=1331035&r2=1331036&view=diff
==============================================================================
--- shiro/trunk/support/pom.xml (original)
+++ shiro/trunk/support/pom.xml Thu Apr 26 19:15:13 2012
@@ -34,6 +34,7 @@
     <modules>
         <module>aspectj</module>
         <module>ehcache</module>
+        <module>faces</module>
         <module>quartz</module>
         <module>spring</module>
         <module>guice</module>



Mime
View raw message