Class AbstractLdapRealm

All Implemented Interfaces:
LogoutAware, Authorizer, PermissionResolverAware, RolePermissionResolverAware, org.apache.shiro.cache.CacheManagerAware, org.apache.shiro.lang.util.Initializable, org.apache.shiro.lang.util.Nameable, Realm
Direct Known Subclasses:
ActiveDirectoryRealm

public abstract class AbstractLdapRealm extends AuthorizingRealm

A Realm that authenticates with an LDAP server to build the Subject for a user. This implementation only returns roles for a particular user, and not permissions - but it can be subclassed to build a permission list as well.

Implementations would need to implement the queryForAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken, LdapContextFactory) and queryForAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection, LdapContextFactory) abstract methods.

By default, this implementation will create an instance of JndiLdapContextFactory to use for creating LDAP connections using the principalSuffix, searchBase, url, systemUsername, and systemPassword properties specified on the realm. The remaining settings use the defaults of JndiLdapContextFactory, which are usually sufficient. If more customized connections are needed, you should inject a custom LdapContextFactory, which will cause these properties specified on the realm to be ignored.

Since:
0.1
See Also:
  • Field Details

    • principalSuffix

      Defines the Suffix added to the User Principal Name when looking up groups (e.g. "memberOf") AD Example: User's Principal Name be "John.Doe" User's E-Mail Address be "John.Doe@example.com" For the example below, set: realm.principalSuffix = @example.com Only then, "John.Doe" and also "John.Doe@example.com" can authorize against groups
    • searchBase

      protected String searchBase
    • url

      protected String url
    • systemUsername

    • systemPassword

    • searchFilter

      protected String searchFilter
      SHIRO-115 - prevent potential code injection.
  • Constructor Details

  • Method Details