SHIRO-206 - Removing shiro-faces from master (for now)
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/3fccc75a Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/3fccc75a Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/3fccc75a Branch: refs/heads/master Commit: 3fccc75a644adb4ac7b390c3635573e5fe243bc4 Parents: 53f1f6d Author: Brian Demers <[email protected]> Authored: Mon Nov 7 15:15:11 2016 -0500 Committer: Brian Demers <[email protected]> Committed: Mon Nov 7 15:15:48 2016 -0500 ---------------------------------------------------------------------- all/pom.xml | 4 - support/faces/pom.xml | 80 ------- .../shiro/web/faces/tags/AuthenticatedTag.java | 50 ----- .../web/faces/tags/AuthorizationTagHandler.java | 62 ------ .../apache/shiro/web/faces/tags/GuestTag.java | 42 ---- .../web/faces/tags/HasAnyPermissionsTag.java | 57 ----- .../shiro/web/faces/tags/HasAnyRolesTag.java | 57 ----- .../shiro/web/faces/tags/HasPermissionTag.java | 43 ---- .../apache/shiro/web/faces/tags/HasRoleTag.java | 40 ---- .../web/faces/tags/LacksPermissionTag.java | 37 ---- .../shiro/web/faces/tags/LacksRoleTag.java | 36 --- .../web/faces/tags/NotAuthenticatedTag.java | 41 ---- .../shiro/web/faces/tags/PrincipalTag.java | 220 ------------------- .../shiro/web/faces/tags/RememberedTag.java | 46 ---- .../shiro/web/faces/tags/SecureComponent.java | 57 ----- .../shiro/web/faces/tags/SecureTagHandler.java | 61 ----- .../apache/shiro/web/faces/tags/UserTag.java | 51 ----- .../shiro/web/faces/tags/package-info.java | 30 --- .../main/resources/META-INF/faces-config.xml | 31 --- .../resources/META-INF/shiro-faces.taglib.xml | 135 ------------ support/pom.xml | 1 - 21 files changed, 1181 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/all/pom.xml ---------------------------------------------------------------------- diff --git a/all/pom.xml b/all/pom.xml index 7fa265a..ce3d1c3 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -79,10 +79,6 @@ </dependency> <dependency> <groupId>org.apache.shiro</groupId> - <artifactId>shiro-faces</artifactId> - </dependency> - <dependency> - <groupId>org.apache.shiro</groupId> <artifactId>shiro-guice</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/pom.xml ---------------------------------------------------------------------- diff --git a/support/faces/pom.xml b/support/faces/pom.xml deleted file mode 100644 index f4c1159..0000000 --- a/support/faces/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?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>2.alpha.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>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.web.faces</Bundle-SymbolicName> - <Export-Package>org.apache.shiro.web.faces*;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 http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java deleted file mode 100755 index 03f980d..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthenticatedTag.java +++ /dev/null @@ -1,50 +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.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 2.0 - */ -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(); - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java deleted file mode 100644 index b2bca1c..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/AuthorizationTagHandler.java +++ /dev/null @@ -1,62 +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.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 2.0 - */ -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; - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java deleted file mode 100755 index 3506ac3..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/GuestTag.java +++ /dev/null @@ -1,42 +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.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 2.0 - */ -public class GuestTag extends UserTag { - - public GuestTag(TagConfig config) { - super(config); - } - - @Override - protected boolean showTagBody() { - return !isUser(); - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java deleted file mode 100755 index daa197e..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyPermissionsTag.java +++ /dev/null @@ -1,57 +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.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 2.0 - */ -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; - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java deleted file mode 100755 index 045dc7e..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasAnyRolesTag.java +++ /dev/null @@ -1,57 +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.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 2.0 - */ -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; - } - -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java deleted file mode 100755 index 9a35b55..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasPermissionTag.java +++ /dev/null @@ -1,43 +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.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 2.0 - */ -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); - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java deleted file mode 100755 index 196c40a..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/HasRoleTag.java +++ /dev/null @@ -1,40 +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.shiro.web.faces.tags; - -import javax.faces.view.facelets.TagConfig; - -/** - * @since 2.0 - */ -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 http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java deleted file mode 100755 index 7088ad4..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksPermissionTag.java +++ /dev/null @@ -1,37 +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.shiro.web.faces.tags; - -import javax.faces.view.facelets.TagConfig; - -/** - * @since 2.0 - */ -public class LacksPermissionTag extends HasPermissionTag { - - public LacksPermissionTag(TagConfig config) { - super(config); - } - - @Override - protected boolean showTagBody(String p) { - return !isPermitted(p); - } - -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java deleted file mode 100755 index 1bda8f3..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/LacksRoleTag.java +++ /dev/null @@ -1,36 +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.shiro.web.faces.tags; - -import javax.faces.view.facelets.TagConfig; - -/** - * @since 2.0 - */ -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 http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java deleted file mode 100755 index a7ba548..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/NotAuthenticatedTag.java +++ /dev/null @@ -1,41 +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.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 2.0 - */ -public class NotAuthenticatedTag extends AuthenticatedTag { - - public NotAuthenticatedTag(TagConfig config) { - super(config); - } - - @Override - protected boolean showTagBody() { - return !isAuthenticated(); - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java deleted file mode 100755 index a746bab..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/PrincipalTag.java +++ /dev/null @@ -1,220 +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.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 2.0 - */ -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]; - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java deleted file mode 100755 index 502c7f4..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/RememberedTag.java +++ /dev/null @@ -1,46 +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.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 2.0 - */ -public class RememberedTag extends SecureTagHandler { - - public RememberedTag(TagConfig config) { - super(config); - } - - @Override - protected boolean showTagBody() { - return getSubject() != null && getSubject().isRemembered(); - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java deleted file mode 100755 index ddfe9e0..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureComponent.java +++ /dev/null @@ -1,57 +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.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 2.0 - */ -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; - -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java deleted file mode 100755 index 0bf1538..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/SecureTagHandler.java +++ /dev/null @@ -1,61 +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.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 2.0 - */ -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; - } - -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java deleted file mode 100755 index b7b75a5..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/UserTag.java +++ /dev/null @@ -1,51 +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.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 2.0 - */ -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; - } -} http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java ---------------------------------------------------------------------- diff --git a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java b/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java deleted file mode 100755 index a6e310f..0000000 --- a/support/faces/src/main/java/org/apache/shiro/web/faces/tags/package-info.java +++ /dev/null @@ -1,30 +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. - */ - -/** - * 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 2.0 - */ -package org.apache.shiro.web.faces.tags; - - http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/resources/META-INF/faces-config.xml ---------------------------------------------------------------------- diff --git a/support/faces/src/main/resources/META-INF/faces-config.xml b/support/faces/src/main/resources/META-INF/faces-config.xml deleted file mode 100755 index 7ff30a1..0000000 --- a/support/faces/src/main/resources/META-INF/faces-config.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?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 http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml ---------------------------------------------------------------------- diff --git a/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml b/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml deleted file mode 100755 index ef6dd83..0000000 --- a/support/faces/src/main/resources/META-INF/shiro-faces.taglib.xml +++ /dev/null @@ -1,135 +0,0 @@ -<?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> - http://git-wip-us.apache.org/repos/asf/shiro/blob/3fccc75a/support/pom.xml ---------------------------------------------------------------------- diff --git a/support/pom.xml b/support/pom.xml index 001f8a6..e753d60 100644 --- a/support/pom.xml +++ b/support/pom.xml @@ -35,7 +35,6 @@ <module>aspectj</module> <module>ehcache</module> <module>hazelcast</module> - <module>faces</module> <module>quartz</module> <module>spring</module> <module>guice</module>
