io.undertow.predicate.AuthenticationRequiredPredicate Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
The newest version!
package io.undertow.predicate;
import io.undertow.security.api.SecurityContext;
import io.undertow.server.HttpServerExchange;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Predicate that returns true if authentication is required.
*
* @author Stuart Douglas
*/
public class AuthenticationRequiredPredicate implements Predicate {
public static final AuthenticationRequiredPredicate INSTANCE = new AuthenticationRequiredPredicate();
@Override
public boolean resolve(HttpServerExchange value) {
SecurityContext sc = value.getSecurityContext();
if(sc == null) {
return false;
}
return sc.isAuthenticationRequired();
}
@Override
public String toString() {
return "auth-required()";
}
public static class Builder implements PredicateBuilder {
@Override
public String name() {
return "auth-required";
}
@Override
public Map> parameters() {
final Map> params = new HashMap<>();
return params;
}
@Override
public Set requiredParameters() {
final Set params = new HashSet<>();
return params;
}
@Override
public String defaultParameter() {
return null;
}
@Override
public Predicate build(final Map config) {
return INSTANCE;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy