All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.undertow.predicate.AuthenticationRequiredPredicate Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS 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).

There is a newer version: 34.0.0.Final
Show 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 - 2024 Weber Informatics LLC | Privacy Policy