You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2021/04/22 19:47:29 UTC
[tomee] 04/04: Add a workaround in case there is only one mechanism
available
This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 9c7bc47a37144313bb5b455a1dd92a6d03c2cf58
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Thu Apr 22 21:46:52 2021 +0200
Add a workaround in case there is only one mechanism available
---
.../cdi/TomEESecurityServletAuthenticationMechanismMapper.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java b/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java
index c74e76f..7ac4772 100644
--- a/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java
+++ b/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java
@@ -74,10 +74,11 @@ public class TomEESecurityServletAuthenticationMechanismMapper {
final Set<HttpAuthenticationMechanism> availableBeans = authenticationMechanisms.stream().collect(Collectors.toSet());
availableBeans.removeAll(servletAuthenticationMapper.values());
- availableBeans.remove(defaultAuthenticationMechanism);
+ availableBeans.remove(defaultAuthenticationMechanism); // this our wrapper
if (availableBeans.size() == 1) {
defaultAuthenticationMechanism.setDelegate(availableBeans.iterator().next());
+
} else if (availableBeans.size() > 1) {
throw new IllegalStateException(
"Multiple HttpAuthenticationMechanism found " +
@@ -86,6 +87,11 @@ public class TomEESecurityServletAuthenticationMechanismMapper {
.collect(toList()) + " " +
"without a @WebServlet association. " +
"Deploy a single one for the application, or associate it with a @WebServlet.");
+
+ } else if (servletAuthenticationMapper.size() == 1) {
+ // don't think it's covered by the spec but sotera seems to support such a case
+ defaultAuthenticationMechanism.setDelegate(servletAuthenticationMapper.values().iterator().next());
+
}
}