diff --git a/configuration/pom.xml b/configuration/pom.xml index 94a61b6..9468dc4 100644 --- a/configuration/pom.xml +++ b/configuration/pom.xml @@ -24,7 +24,7 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT shared-configuration diff --git a/db/pom.xml b/db/pom.xml index ad011d5..dfc0f2b 100644 --- a/db/pom.xml +++ b/db/pom.xml @@ -25,7 +25,7 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT shared-db diff --git a/jeeutil/pom.xml b/jeeutil/pom.xml index 9e2c0c5..573f024 100644 --- a/jeeutil/pom.xml +++ b/jeeutil/pom.xml @@ -20,7 +20,7 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT de.muehlencord.shared @@ -55,11 +55,6 @@ limitations under the License. jar provided - - org.apache.shiro - shiro-web - provided - diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java deleted file mode 100644 index 52d8c72..0000000 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java +++ /dev/null @@ -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; - } - } -} diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java deleted file mode 100644 index 7cdaef7..0000000 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java +++ /dev/null @@ -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); - - } - -} diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTException.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTException.java deleted file mode 100644 index 16ca909..0000000 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTException.java +++ /dev/null @@ -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 JWTException without detail message. - */ - public JWTException() { - } - - - /** - * Constructs an instance of JWTException with the specified detail message. - * @param msg the detail message. - */ - public JWTException(String msg) { - super(msg); - } - - /** - * Constructs an instance of JWTException 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); - } -} diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTGuard.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTGuard.java deleted file mode 100644 index ffd40fb..0000000 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTGuard.java +++ /dev/null @@ -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; - } -} diff --git a/network/pom.xml b/network/pom.xml index 5aedb88..3b6d0be 100644 --- a/network/pom.xml +++ b/network/pom.xml @@ -72,7 +72,7 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT UTF-8 @@ -80,5 +80,5 @@ limitations under the License. http://maven.apache.org - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT diff --git a/poi-util/pom.xml b/poi-util/pom.xml index 83898bc..24a4b92 100644 --- a/poi-util/pom.xml +++ b/poi-util/pom.xml @@ -47,9 +47,9 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 402ded5..156abd1 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ limitations under the License. 4.0.0 shared - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT shared pom @@ -28,7 +28,6 @@ limitations under the License. network util jeeutil - shiro-faces poi-util db @@ -82,7 +81,6 @@ limitations under the License. UTF-8 2.0.6 2.14.2 - 1.11.0 1.18.26 5.9.2 12.0.0 @@ -104,11 +102,6 @@ limitations under the License. ejb ${project.version} - - shared-shiro-faces - de.muehlencord.shared - ${project.version} - shared-util de.muehlencord.shared @@ -187,16 +180,6 @@ limitations under the License. com.fasterxml.jackson.datatype ${jackson.version} - - shiro-core - org.apache.shiro - ${shiro.version} - - - shiro-web - org.apache.shiro - ${shiro.version} - javaee-api javax diff --git a/shiro-faces/pom.xml b/shiro-faces/pom.xml deleted file mode 100644 index 8caf544..0000000 --- a/shiro-faces/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - 4.0.0 - de.muehlencord.shared - shared-shiro-faces - jar - - - de.muehlencord - shared - 1.3.2-SNAPSHOT - - - shared-shiro-faces - - - - org.apache.shiro - shiro-web - provided - - - javax - javaee-api - provided - - - - \ No newline at end of file diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/filter/FacesAjaxAwarePassThruAuthenticationFilter.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/filter/FacesAjaxAwarePassThruAuthenticationFilter.java deleted file mode 100644 index 1183ba8..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/filter/FacesAjaxAwarePassThruAuthenticationFilter.java +++ /dev/null @@ -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 = "" - + ""; - - - @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); - } - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAccessControlTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAccessControlTag.java deleted file mode 100644 index 3a2230d..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAccessControlTag.java +++ /dev/null @@ -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); - } - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAuthenticationTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAuthenticationTag.java deleted file mode 100644 index a7665ad..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractAuthenticationTag.java +++ /dev/null @@ -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); - } - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractPermissionTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractPermissionTag.java deleted file mode 100644 index a008031..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractPermissionTag.java +++ /dev/null @@ -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); - } - - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractRoleTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractRoleTag.java deleted file mode 100644 index 068c6a5..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractRoleTag.java +++ /dev/null @@ -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); - } - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractTag.java deleted file mode 100644 index 355da1c..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AbstractTag.java +++ /dev/null @@ -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(); - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AuthenticatedTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AuthenticatedTag.java deleted file mode 100644 index ddd1b30..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/AuthenticatedTag.java +++ /dev/null @@ -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(); - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/GuestTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/GuestTag.java deleted file mode 100644 index e6bbc8c..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/GuestTag.java +++ /dev/null @@ -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; - } - - - - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyPermissionTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyPermissionTag.java deleted file mode 100644 index 0707e51..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyPermissionTag.java +++ /dev/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 permissionsList = Arrays.asList(permissions.split(PERMISSIONS_DELIMETER)); - return permissionsList.stream().anyMatch(permission -> subject.isPermitted(permission)); - } else return false; - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyRolesTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyRolesTag.java deleted file mode 100644 index c7bf9c1..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasAnyRolesTag.java +++ /dev/null @@ -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 roleList = Arrays.asList(roleNames.split(ROLE_NAMES_DELIMETER)); - return roleList.stream().anyMatch(role -> subject.hasRole(role.trim())); - } - return false; - - } -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasPermissionTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasPermissionTag.java deleted file mode 100644 index 001cb22..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasPermissionTag.java +++ /dev/null @@ -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); - } - - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasRoleTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasRoleTag.java deleted file mode 100644 index bdd06c2..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/HasRoleTag.java +++ /dev/null @@ -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); - } - - - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksPermissionTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksPermissionTag.java deleted file mode 100644 index 974ce02..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksPermissionTag.java +++ /dev/null @@ -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); - } - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksRoleTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksRoleTag.java deleted file mode 100644 index 6781e22..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/LacksRoleTag.java +++ /dev/null @@ -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); - } - - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/NotAuthenticatedTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/NotAuthenticatedTag.java deleted file mode 100644 index 6ef004d..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/NotAuthenticatedTag.java +++ /dev/null @@ -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(); - } - - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/UserTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/UserTag.java deleted file mode 100644 index 49adda9..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/UserTag.java +++ /dev/null @@ -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; - } - -} diff --git a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/unsupported/PrincipalTag.java b/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/unsupported/PrincipalTag.java deleted file mode 100644 index 0136d87..0000000 --- a/shiro-faces/src/main/java/de/muehlencord/shirofaces/tags/unsupported/PrincipalTag.java +++ /dev/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; - -/** - *
- * 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. - *
- * - *
- * If no attributes are specified, the tag prints out the toString() - * value of the user's default principal. If the type attribute is - * specified, the tag looks for a principal with the given type. If the - * 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 defaultValue - * is specified. - *
- * - * @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."); - } -} diff --git a/shiro-faces/src/main/resources/META-INF/shiro-faces.taglib.xml b/shiro-faces/src/main/resources/META-INF/shiro-faces.taglib.xml deleted file mode 100644 index f6721b7..0000000 --- a/shiro-faces/src/main/resources/META-INF/shiro-faces.taglib.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - http://shiro.apache.org/tags - - - - - authenticated - de.muehlencord.shirofaces.tags.AuthenticatedTag - 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. - - - - - guest - de.muehlencord.shirofaces.tags.GuestTag - 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. - - - - - hasAnyPermission - de.muehlencord.shirofaces.tags.HasAnyPermissionTag - Displays body content only if the current user has one of the specified permissions from a comma-separated list of permissions. - - comma-separated list of permissions to check for - name - true - - - - - hasAnyRoles - de.muehlencord.shirofaces.tags.HasAnyRolesTag - Displays body content only if the current user has one of the specified roles from a comma-separated list of role names. - - comma-separated list of roles to check for - name - true - - - - - hasPermission - de.muehlencord.shirofaces.tags.HasPermissionTag - Displays body content only if the current user the given permission. - - the permission to check for - name - true - - - - - hasRole - de.muehlencord.shirofaces.tags.HasRoleTag - Displays body content only if the current user has the given role. - - the role to check for - name - true - - - - - lacksPermission - de.muehlencord.shirofaces.tags.LacksPermissionTag - Displays body content only if the current user has NOT the given permission. - - the permission to check for - name - true - - - - - lacksRole - de.muehlencord.shirofaces.tags.LacksRoleTag - Displays body content only if the current user has NOT the given role. - - the role to check for - name - true - - - - - notAuthenticated - de.muehlencord.shirofaces.tags.NotAuthenticatedTag - Displays body content only if the current user has NOT succesfully authenticated - _during their current session_. It is logically opposite to the 'authenticated' tag. - - - - - user - de.muehlencord.shirofaces.tags.UserTag - 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. - - - - - - - - - \ No newline at end of file diff --git a/util/pom.xml b/util/pom.xml index 47f62f0..b4b4f75 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -26,7 +26,7 @@ limitations under the License. shared de.muehlencord - 1.3.2-SNAPSHOT + 2.0.0-SNAPSHOT