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

io.quarkus.security.runtime.AnonymousIdentityProvider Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.security.runtime;

import java.security.Permission;
import java.security.Principal;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

import io.quarkus.security.credential.Credential;
import io.quarkus.security.identity.AuthenticationRequestContext;
import io.quarkus.security.identity.IdentityProvider;
import io.quarkus.security.identity.SecurityIdentity;
import io.quarkus.security.identity.request.AnonymousAuthenticationRequest;
import io.smallrye.mutiny.Uni;

public class AnonymousIdentityProvider implements IdentityProvider {

    private static final Principal principal = new Principal() {
        @Override
        public String getName() {
            return "";
        }
    };

    private static final SecurityIdentity instance = new SecurityIdentity() {
        @Override
        public Principal getPrincipal() {
            return principal;
        }

        @Override
        public boolean isAnonymous() {
            return true;
        }

        @Override
        public Set getRoles() {
            return Collections.emptySet();
        }

        @Override
        public boolean hasRole(String role) {
            return false;
        }

        @Override
        public  T getCredential(Class credentialType) {
            return null;
        }

        @Override
        public Set getCredentials() {
            return Collections.emptySet();
        }

        @Override
        public  T getAttribute(String name) {
            return null;
        }

        @Override
        public Map getAttributes() {
            return Collections.emptyMap();
        }

        @Override
        public Uni checkPermission(Permission permission) {
            return Uni.createFrom().item(false);
        }
    };

    @Override
    public Class getRequestType() {
        return AnonymousAuthenticationRequest.class;
    }

    @Override
    public Uni authenticate(AnonymousAuthenticationRequest request,
            AuthenticationRequestContext context) {
        return Uni.createFrom().item(instance);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy