Class SearchFirstActiveDirectoryRealm

java.lang.Object
org.apache.shiro.realm.CachingRealm
org.apache.shiro.realm.AuthenticatingRealm
org.apache.shiro.realm.AuthorizingRealm
org.apache.shiro.realm.ldap.AbstractLdapRealm
org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
com.linecorp.centraldogma.server.auth.shiro.realm.SearchFirstActiveDirectoryRealm
All Implemented Interfaces:
org.apache.shiro.authc.LogoutAware, org.apache.shiro.authz.Authorizer, org.apache.shiro.authz.permission.PermissionResolverAware, org.apache.shiro.authz.permission.RolePermissionResolverAware, org.apache.shiro.cache.CacheManagerAware, org.apache.shiro.realm.Realm, org.apache.shiro.util.Initializable, org.apache.shiro.util.Nameable

public class SearchFirstActiveDirectoryRealm extends org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
A variant of ActiveDirectoryRealm that binds first with the privileged credential to search for the DN of a user from a username before the actual authentication. This Realm is useful when there is no simple rule to convert a username into a DN.

The INI configuration might be specified as follows:


 [main]
 adRealm = com.linecorp.centraldogma.server.support.shiro.SearchFirstActiveDirectoryRealm
 adRealm.url = ldap://hostname:port
 adRealm.systemUsername = admin
 adRealm.systemPassword = admin
 adRealm.searchBase = ...
 adRealm.searchFilter = cn={0}
 adRealm.searchTimeoutMillis = 10000
 
  • Field Summary

    Fields inherited from class org.apache.shiro.realm.ldap.AbstractLdapRealm

    principalSuffix, searchBase, systemPassword, systemUsername, url
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    findUserDn(org.apache.shiro.realm.ldap.LdapContextFactory ldapContextFactory, String username)
    Finds a distinguished name(DN) of a user by querying the active directory LDAP context for the specified username.
    protected String
    Returns a search filter string.
    int
    Returns a timeout(ms) for LDAP search.
    protected org.apache.shiro.authc.AuthenticationInfo
    queryForAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.realm.ldap.LdapContextFactory ldapContextFactory)
    Builds an AuthenticationInfo object by querying the active directory LDAP context for the specified username.
    protected void
    setSearchFilter(String searchFilter)
    Sets a search filter string.
    protected void
    setSearchTimeoutMillis(int searchTimeoutMillis)
    Sets a timeout(ms) for LDAP search.

    Methods inherited from class org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm

    buildAuthenticationInfo, buildAuthorizationInfo, getRoleNamesForGroups, queryForAuthorizationInfo, setGroupRolesMap

    Methods inherited from class org.apache.shiro.realm.ldap.AbstractLdapRealm

    doGetAuthenticationInfo, doGetAuthorizationInfo, onInit, setLdapContextFactory, setPrincipalSuffix, setSearchBase, setSystemPassword, setSystemUsername, setUrl

    Methods inherited from class org.apache.shiro.realm.AuthorizingRealm

    afterCacheManagerSet, checkPermission, checkPermission, checkPermission, checkPermissions, checkPermissions, checkPermissions, checkRole, checkRole, checkRoles, checkRoles, checkRoles, clearCachedAuthorizationInfo, doClearCache, getAuthorizationCache, getAuthorizationCacheKey, getAuthorizationCacheName, getAuthorizationInfo, getPermissionResolver, getPermissions, getRolePermissionResolver, hasAllRoles, hasRole, hasRole, hasRoles, hasRoles, isAuthorizationCachingEnabled, isPermitted, isPermitted, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll, isPermittedAll, setAuthorizationCache, setAuthorizationCacheName, setAuthorizationCachingEnabled, setName, setPermissionResolver, setRolePermissionResolver

    Methods inherited from class org.apache.shiro.realm.AuthenticatingRealm

    assertCredentialsMatch, clearCachedAuthenticationInfo, getAuthenticationCache, getAuthenticationCacheKey, getAuthenticationCacheKey, getAuthenticationCacheName, getAuthenticationInfo, getAuthenticationTokenClass, getCredentialsMatcher, init, isAuthenticationCachingEnabled, isAuthenticationCachingEnabled, setAuthenticationCache, setAuthenticationCacheName, setAuthenticationCachingEnabled, setAuthenticationTokenClass, setCredentialsMatcher, supports

    Methods inherited from class org.apache.shiro.realm.CachingRealm

    clearCache, getAvailablePrincipal, getCacheManager, getName, isCachingEnabled, onLogout, setCacheManager, setCachingEnabled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.shiro.util.Initializable

    init
  • Constructor Details

    • SearchFirstActiveDirectoryRealm

      public SearchFirstActiveDirectoryRealm()
  • Method Details

    • getSearchFilter

      @Nullable protected String getSearchFilter()
      Returns a search filter string.
    • setSearchFilter

      protected void setSearchFilter(String searchFilter)
      Sets a search filter string.
    • getSearchTimeoutMillis

      public int getSearchTimeoutMillis()
      Returns a timeout(ms) for LDAP search.
    • setSearchTimeoutMillis

      protected void setSearchTimeoutMillis(int searchTimeoutMillis)
      Sets a timeout(ms) for LDAP search.
    • queryForAuthenticationInfo

      @Nullable protected org.apache.shiro.authc.AuthenticationInfo queryForAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.realm.ldap.LdapContextFactory ldapContextFactory) throws NamingException
      Builds an AuthenticationInfo object by querying the active directory LDAP context for the specified username.
      Overrides:
      queryForAuthenticationInfo in class org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
      Throws:
      NamingException
    • findUserDn

      @Nullable protected String findUserDn(org.apache.shiro.realm.ldap.LdapContextFactory ldapContextFactory, String username) throws NamingException
      Finds a distinguished name(DN) of a user by querying the active directory LDAP context for the specified username.
      Returns:
      the DN of the user, or null if there's no such user
      Throws:
      NamingException