Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.tribuo.backend.configuration; import org.apache.commons.lang3.StringUtils; import org.pac4j.core.authorization.authorizer.ProfileAuthorizer; import org.pac4j.core.context.WebContext; import org.pac4j.core.exception.HttpAction; import org.pac4j.core.profile.CommonProfile; import java.util.List; /** * * @author Camilo */ public class CustomAuthorizer extends ProfileAuthorizer<CommonProfile> { @Override public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction { return isAnyAuthorized(context, profiles); } @Override public boolean isProfileAuthorized(final WebContext context, final CommonProfile profile) { if (profile == null) { return false; } return StringUtils.startsWith(profile.getUsername(), "jle"); } }