diff --git a/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityJsf12TagLibrary.java b/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityJsf12TagLibrary.java new file mode 100644 index 00000000..ceebc911 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityJsf12TagLibrary.java @@ -0,0 +1,53 @@ +/* + * Copyright 2004-2010 the original author or authors. + * + * Licensed 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.springframework.faces.security; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import com.sun.facelets.tag.AbstractTagLibrary; + +/** + * Registers a tag handler for the <authorize> tag and several EL functions that can be used on any component that + * accepts EL expressions in its attributes. For details on the EL functions see {@link Jsf12FaceletsAuthorizeTagUtils}. + * + * @author Rossen Stoyanchev + * @since 2.2.0 + * @see Jsf12FaceletsAuthorizeTagHandler + * @see Jsf12FaceletsAuthorizeTagUtils + */ +public class SpringSecurityJsf12TagLibrary extends AbstractTagLibrary { + + public static final String NAMESPACE = "http://www.springframework.org/security/tags"; + + public SpringSecurityJsf12TagLibrary() { + super(NAMESPACE); + + this.addTagHandler("authorize", Jsf12FaceletsAuthorizeTagHandler.class); + + try { + Method[] methods = Jsf12FaceletsAuthorizeTagUtils.class.getMethods(); + for (int i = 0; i < methods.length; i++) { + if (Modifier.isStatic(methods[i].getModifiers())) { + this.addFunction(methods[i].getName(), methods[i]); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityTagLibrary.java b/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityTagLibrary.java index f875e538..b874b5db 100644 --- a/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityTagLibrary.java +++ b/spring-faces/src/main/java/org/springframework/faces/security/SpringSecurityTagLibrary.java @@ -18,14 +18,11 @@ package org.springframework.faces.security; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import org.springframework.faces.webflow.JsfRuntimeInformation; - import com.sun.faces.facelets.tag.AbstractTagLibrary; /** * Registers a tag handler for the <authorize> tag and several EL functions that can be used on any component that - * accepts EL expressions in its attributes. For details on the EL functions see {@link FaceletsAuthorizeTagUtils} or - * {@link Jsf12FaceletsAuthorizeTagUtils} depending on your environment. + * accepts EL expressions in its attributes. For details on the EL functions see {@link FaceletsAuthorizeTagUtils}. * * @author Rossen Stoyanchev * @since 2.2.0 @@ -39,15 +36,10 @@ public class SpringSecurityTagLibrary extends AbstractTagLibrary { public SpringSecurityTagLibrary() { super(NAMESPACE); - if (JsfRuntimeInformation.isAtLeastJsf20()) { - this.addTagHandler("authorize", FaceletsAuthorizeTagHandler.class); - } else { - this.addTagHandler("authorize", Jsf12FaceletsAuthorizeTagHandler.class); - } + this.addTagHandler("authorize", FaceletsAuthorizeTagHandler.class); try { - Method[] methods = (JsfRuntimeInformation.isAtLeastJsf20()) ? FaceletsAuthorizeTagUtils.class.getMethods() - : Jsf12FaceletsAuthorizeTagUtils.class.getMethods(); + Method[] methods = FaceletsAuthorizeTagUtils.class.getMethods(); for (int i = 0; i < methods.length; i++) { if (Modifier.isStatic(methods[i].getModifiers())) { this.addFunction(methods[i].getName(), methods[i]); diff --git a/spring-faces/src/main/resources/META-INF/springsecurity.taglib.xml b/spring-faces/src/main/resources/META-INF/springsecurity.taglib.xml deleted file mode 100644 index 5455cb2f..00000000 --- a/spring-faces/src/main/resources/META-INF/springsecurity.taglib.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - org.springframework.faces.security.SpringSecurityTagLibrary - \ No newline at end of file