feature/jakrtaee10 #2
@ -24,7 +24,7 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>shared-configuration</name>
|
||||
|
||||
@ -25,7 +25,7 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>shared-db</name>
|
||||
|
||||
@ -20,7 +20,7 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
@ -55,11 +55,6 @@ limitations under the License.
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shared.jeeutil.jwt;
|
||||
|
||||
import io.fusionauth.jwt.Verifier;
|
||||
import io.fusionauth.jwt.domain.JWT;
|
||||
import io.fusionauth.jwt.hmac.HMACVerifier;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class JWTDecoder {
|
||||
|
||||
private boolean parsedSuccessfully;
|
||||
private JWT jwt = null;
|
||||
|
||||
public JWTDecoder(String password, String issuer, String jwtString) throws JWTException {
|
||||
if ((password == null) || (issuer == null) || (jwtString == null)) {
|
||||
throw new JWTException("password, issuer and jwt must not be null");
|
||||
}
|
||||
Verifier verifier = HMACVerifier.newVerifier(password);
|
||||
jwt = JWT.getDecoder().decode(jwtString, verifier);
|
||||
parsedSuccessfully = jwt != null && jwt.issuer.equals(issuer);
|
||||
}
|
||||
|
||||
public String getIssuer() {
|
||||
if (jwt == null) {
|
||||
return null;
|
||||
} else {
|
||||
return jwt.issuer;
|
||||
}
|
||||
}
|
||||
|
||||
public ZonedDateTime getIssuedAt() {
|
||||
if (jwt == null) {
|
||||
return null;
|
||||
} else {
|
||||
return jwt.issuedAt;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
if (jwt == null) {
|
||||
return null;
|
||||
} else {
|
||||
return jwt.subject;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUniqueId() {
|
||||
if (jwt == null) {
|
||||
return null;
|
||||
} else {
|
||||
return jwt.uniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
public ZonedDateTime getExpiration() {
|
||||
if (jwt == null) {
|
||||
return null;
|
||||
} else {
|
||||
return jwt.expiration;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
if ((jwt == null) || (jwt.isExpired())) {
|
||||
return false;
|
||||
} else {
|
||||
return this.parsedSuccessfully;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shared.jeeutil.jwt;
|
||||
|
||||
import io.fusionauth.jwt.Signer;
|
||||
import io.fusionauth.jwt.domain.JWT;
|
||||
import io.fusionauth.jwt.hmac.HMACSigner;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class JWTEncoder {
|
||||
|
||||
public static String encode(String password, String issuer, ZonedDateTime issuedAt, String subject, String uniqueId, short expirationInMinutes ) throws JWTException {
|
||||
if ((password == null) || (issuer == null)) {
|
||||
throw new JWTException("password and issuer must not be null");
|
||||
}
|
||||
Signer signer = HMACSigner.newSHA256Signer(password);
|
||||
// Signer signer = RSASigner.newSHA256Signer(new String(Files.readAllBytes(Paths.get("private_key.pem"))));
|
||||
|
||||
|
||||
JWT jwt = new JWT().setIssuer(issuer) // FIXME - make configurable
|
||||
.setIssuedAt(issuedAt)
|
||||
.setSubject(subject)
|
||||
.setUniqueId(uniqueId)
|
||||
.setExpiration(issuedAt.plusMinutes(expirationInMinutes));
|
||||
return JWT.getEncoder().encode(jwt, signer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shared.jeeutil.jwt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class JWTException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 423992803027530544L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>JWTException</code> without detail message.
|
||||
*/
|
||||
public JWTException() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>JWTException</code> with the specified detail message.
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
public JWTException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>JWTException</code> with the specified detail message and root cause.
|
||||
* @param msg the detail message.
|
||||
* @param th the root cause
|
||||
*/
|
||||
public JWTException(String msg, Throwable th) {
|
||||
super(msg,th);
|
||||
}
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shared.jeeutil.jwt;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.shiro.web.filter.authc.AuthenticationFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class JWTGuard extends AuthenticationFilter {
|
||||
|
||||
@Override
|
||||
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -80,5 +80,5 @@ limitations under the License.
|
||||
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
||||
@ -47,9 +47,9 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
||||
19
pom.xml
19
pom.xml
@ -19,7 +19,7 @@ limitations under the License.
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>shared</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@ -28,7 +28,6 @@ limitations under the License.
|
||||
<module>network</module>
|
||||
<module>util</module>
|
||||
<module>jeeutil</module>
|
||||
<module>shiro-faces</module>
|
||||
<module>poi-util</module>
|
||||
<module>db</module>
|
||||
</modules>
|
||||
@ -82,7 +81,6 @@ limitations under the License.
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<slf4j.version>2.0.6</slf4j.version>
|
||||
<jackson.version>2.14.2</jackson.version>
|
||||
<shiro.version>1.11.0</shiro.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
<junit.version>5.9.2</junit.version>
|
||||
<primefaces.version>12.0.0</primefaces.version>
|
||||
@ -104,11 +102,6 @@ limitations under the License.
|
||||
<type>ejb</type>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-shiro-faces</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
@ -187,16 +180,6 @@ limitations under the License.
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<groupId>javax</groupId>
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-shiro-faces</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>shared-shiro-faces</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter;
|
||||
|
||||
/**
|
||||
* found at http://balusc.omnifaces.org/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html#MakeShiroJSFAjaxAware)
|
||||
* source by BalusC, adjusted to PassThruAuthenticationFilter by Joern Muehlencord
|
||||
* @author BalusC
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class FacesAjaxAwarePassThruAuthenticationFilter extends PassThruAuthenticationFilter {
|
||||
|
||||
private static final String FACES_REDIRECT_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<partial-response><redirect url=\"%s\"></redirect></partial-response>";
|
||||
|
||||
|
||||
@Override
|
||||
protected void redirectToLogin(ServletRequest req, ServletResponse res) throws IOException {
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
|
||||
if ("partial/ajax".equals(request.getHeader("Faces-Request"))) {
|
||||
res.setContentType("text/xml");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
res.getWriter().printf(FACES_REDIRECT_XML, request.getContextPath() + getLoginUrl());
|
||||
}
|
||||
else {
|
||||
super.redirectToLogin(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagAttribute;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractAccessControlTag extends AbstractTag {
|
||||
|
||||
protected TagAttribute attribute;
|
||||
|
||||
protected AbstractAccessControlTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
protected String getAttributeValue(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;
|
||||
}
|
||||
|
||||
protected boolean isPermitted(String permission) {
|
||||
return getSubject() != null && getSubject().isPermitted(permission);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractAuthenticationTag extends AbstractTag {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractAuthenticationTag.class);
|
||||
|
||||
protected AbstractAuthenticationTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
protected abstract boolean isAuthenticated();
|
||||
|
||||
protected boolean applyTagHandler() {
|
||||
if (isAuthenticated()) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Authentication verified, tag will be evaluated");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Authentifaction verification failed, tag will not be evaluated");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(FaceletContext fc, UIComponent uic) throws IOException {
|
||||
if (applyTagHandler()) {
|
||||
this.nextHandler.apply(fc, uic);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractPermissionTag extends AbstractAccessControlTag {
|
||||
|
||||
protected AbstractPermissionTag(TagConfig config) {
|
||||
super(config);
|
||||
this.attribute = this.getRequiredAttribute("name");
|
||||
}
|
||||
|
||||
protected abstract boolean hasPermission(String permission);
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isPermitted(String permission) {
|
||||
return getSubject() != null && getSubject().isPermitted(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(FaceletContext fc, UIComponent uic) throws IOException {
|
||||
String permissionName = getAttributeValue(fc, attribute);
|
||||
if (hasPermission(permissionName)) {
|
||||
this.nextHandler.apply(fc, uic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractRoleTag extends AbstractAccessControlTag {
|
||||
|
||||
protected AbstractRoleTag(TagConfig config) {
|
||||
super(config);
|
||||
this.attribute = this.getRequiredAttribute("name");
|
||||
}
|
||||
|
||||
protected abstract boolean hasRole(String role);
|
||||
|
||||
public void apply(FaceletContext fc, UIComponent uic) throws IOException {
|
||||
String roleName = getAttributeValue(fc, attribute);
|
||||
if (hasRole(roleName)) {
|
||||
this.nextHandler.apply(fc, uic);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import javax.faces.view.facelets.TagHandler;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractTag extends TagHandler {
|
||||
|
||||
protected AbstractTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
protected Subject getSubject() {
|
||||
return SecurityUtils.getSubject();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class AuthenticatedTag extends AbstractAuthenticationTag {
|
||||
|
||||
public AuthenticatedTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthenticated() {
|
||||
return getSubject() != null && getSubject().isAuthenticated();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class GuestTag extends AbstractAuthenticationTag {
|
||||
|
||||
public GuestTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthenticated() {
|
||||
return getSubject() == null || getSubject().getPrincipal() == null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class HasAnyPermissionTag extends AbstractPermissionTag {
|
||||
|
||||
private final static String PERMISSIONS_DELIMETER = ",";
|
||||
|
||||
public HasAnyPermissionTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasPermission(String permissions) {
|
||||
Subject subject = getSubject();
|
||||
|
||||
if (subject != null) {
|
||||
List<String> permissionsList = Arrays.asList(permissions.split(PERMISSIONS_DELIMETER));
|
||||
return permissionsList.stream().anyMatch(permission -> subject.isPermitted(permission));
|
||||
} else return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class HasAnyRolesTag extends AbstractRoleTag {
|
||||
|
||||
private final static String ROLE_NAMES_DELIMETER = ",";
|
||||
|
||||
public HasAnyRolesTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasRole(String roleNames) {
|
||||
Subject subject = getSubject();
|
||||
|
||||
if (subject != null) {
|
||||
List<String> roleList = Arrays.asList(roleNames.split(ROLE_NAMES_DELIMETER));
|
||||
return roleList.stream().anyMatch(role -> subject.hasRole(role.trim()));
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class HasPermissionTag extends AbstractPermissionTag {
|
||||
|
||||
public HasPermissionTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasPermission(String permission) {
|
||||
return isPermitted(permission);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class HasRoleTag extends AbstractRoleTag {
|
||||
|
||||
public HasRoleTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasRole(String role) {
|
||||
return getSubject() != null && getSubject().hasRole(role);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class LacksPermissionTag extends AbstractPermissionTag {
|
||||
|
||||
public LacksPermissionTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasPermission(String permission) {
|
||||
return !isPermitted(permission);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class LacksRoleTag extends AbstractRoleTag {
|
||||
|
||||
public LacksRoleTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasRole(String role) {
|
||||
return getSubject() != null && getSubject().hasRole(role);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class NotAuthenticatedTag extends AbstractAuthenticationTag {
|
||||
|
||||
public NotAuthenticatedTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthenticated() {
|
||||
return getSubject() == null || !getSubject().isAuthenticated();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags;
|
||||
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class UserTag extends AbstractAuthenticationTag {
|
||||
|
||||
public UserTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAuthenticated() {
|
||||
return getSubject() != null && getSubject().getPrincipal() != null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* 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 de.muehlencord.shirofaces.tags.unsupported;
|
||||
|
||||
import de.muehlencord.shirofaces.tags.AbstractTag;
|
||||
import java.io.IOException;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
|
||||
/**
|
||||
* <div>
|
||||
* 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.
|
||||
* </div>
|
||||
*
|
||||
* <div>
|
||||
* If no attributes are specified, the tag prints out the <b>toString()</b>
|
||||
* value of the user's default principal. If the <b>type</b> attribute is
|
||||
* specified, the tag looks for a principal with the given type. If the
|
||||
* <b>property</b> 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 <b>defaultValue</b>
|
||||
* is specified.
|
||||
* </div>
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class PrincipalTag extends AbstractTag {
|
||||
|
||||
/**
|
||||
* creates a new principal tag
|
||||
*
|
||||
* @param config the configuration to use
|
||||
*/
|
||||
public PrincipalTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(FaceletContext fc, UIComponent uic) throws IOException {
|
||||
throw new UnsupportedOperationException("PrincipalTag Not supported yet.");
|
||||
}
|
||||
}
|
||||
@ -1,134 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<facelet-taglib version="2.2"
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
|
||||
|
||||
<namespace>http://shiro.apache.org/tags</namespace>
|
||||
|
||||
<tags>
|
||||
|
||||
<tag>
|
||||
<tag-name>authenticated</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.AuthenticatedTag</handler-class>
|
||||
<description>Displays body content only if the current user has successfully authenticated
|
||||
_during their current session_. It is more restrictive than the 'user' tag.
|
||||
It is logically opposite to the 'notAuthenticated' tag.
|
||||
</description>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>guest</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.GuestTag</handler-class>
|
||||
<description>Displays body content only if the current Subject IS NOT known to the system, either
|
||||
because they have not logged in or they have no corresponding 'RememberMe' identity. It is logically
|
||||
opposite to the 'user' tag.
|
||||
</description>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>hasAnyPermission</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.HasAnyPermissionTag</handler-class>
|
||||
<description>Displays body content only if the current user has one of the specified permissions from a comma-separated list of permissions.</description>
|
||||
<attribute>
|
||||
<description>comma-separated list of permissions to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>hasAnyRoles</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.HasAnyRolesTag</handler-class>
|
||||
<description>Displays body content only if the current user has one of the specified roles from a comma-separated list of role names.</description>
|
||||
<attribute>
|
||||
<description>comma-separated list of roles to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>hasPermission</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.HasPermissionTag</handler-class>
|
||||
<description>Displays body content only if the current user the given permission.</description>
|
||||
<attribute>
|
||||
<description>the permission to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>hasRole</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.HasRoleTag</handler-class>
|
||||
<description>Displays body content only if the current user has the given role.</description>
|
||||
<attribute>
|
||||
<description>the role to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>lacksPermission</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.LacksPermissionTag</handler-class>
|
||||
<description>Displays body content only if the current user has NOT the given permission.</description>
|
||||
<attribute>
|
||||
<description>the permission to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>lacksRole</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.LacksRoleTag</handler-class>
|
||||
<description>Displays body content only if the current user has NOT the given role.</description>
|
||||
<attribute>
|
||||
<description>the role to check for</description>
|
||||
<name>name</name>
|
||||
<required>true</required>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>notAuthenticated</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.NotAuthenticatedTag</handler-class>
|
||||
<description>Displays body content only if the current user has NOT succesfully authenticated
|
||||
_during their current session_. It is logically opposite to the 'authenticated' tag.
|
||||
</description>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>user</tag-name>
|
||||
<handler-class>de.muehlencord.shirofaces.tags.UserTag</handler-class>
|
||||
<description>Displays body content only if the current Subject has a known identity, either
|
||||
from a previous login or from 'RememberMe' services. Note that this is semantically different
|
||||
from the 'authenticated' tag, which is more restrictive. It is logically
|
||||
opposite to the 'guest' tag.
|
||||
</description>
|
||||
</tag>
|
||||
|
||||
|
||||
</tags>
|
||||
|
||||
|
||||
|
||||
</facelet-taglib>
|
||||
@ -26,7 +26,7 @@ limitations under the License.
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user