Tabnine Logo
DefaultLdapRealm.getUserDn
Code IndexAdd Tabnine to your IDE (free)

How to use
getUserDn
method
in
org.apache.shiro.realm.ldap.DefaultLdapRealm

Best Java code snippets using org.apache.shiro.realm.ldap.DefaultLdapRealm.getUserDn (Showing top 6 results out of 315)

origin: apache/shiro

/**
 * Returns the User Distinguished Name (DN) template to use when creating User DNs at runtime - see the
 * {@link #setUserDnTemplate(String) setUserDnTemplate} JavaDoc for a full explanation.
 *
 * @return the User Distinguished Name (DN) template to use when creating User DNs at runtime.
 */
public String getUserDnTemplate() {
  return getUserDn(USERDN_SUBSTITUTION_TOKEN);
}
origin: apache/shiro

/**
 * Returns the principal to use when creating the LDAP connection for an authentication attempt.
 * <p/>
 * This implementation uses a heuristic: it checks to see if the specified token's
 * {@link AuthenticationToken#getPrincipal() principal} is a {@code String}, and if so,
 * {@link #getUserDn(String) converts it} from what is
 * assumed to be a raw uid or username {@code String} into a User DN {@code String}.  Almost all LDAP directories
 * expect the authentication connection to present a User DN and not an unqualified username or uid.
 * <p/>
 * If the token's {@code principal} is not a String, it is assumed to already be in the format supported by the
 * underlying {@link LdapContextFactory} implementation and the raw principal is returned directly.
 *
 * @param token the {@link AuthenticationToken} submitted during the authentication process
 * @return the User DN or raw principal to use to acquire the LdapContext.
 * @see LdapContextFactory#getLdapContext(Object, Object)
 */
protected Object getLdapPrincipal(AuthenticationToken token) {
  Object principal = token.getPrincipal();
  if (principal instanceof String) {
    String sPrincipal = (String) principal;
    return getUserDn(sPrincipal);
  }
  return principal;
}
origin: apache/shiro

@Test(expected=IllegalArgumentException.class)
public void testGetUserDnNullArgument() {
  realm.getUserDn(null);
}
origin: apache/shiro

  @Test
  public void testGetUserDnWithOutPrefixAndSuffix() {
    realm = new DefaultLdapRealm() {
      @Override
      protected String getUserDnPrefix() {
        return null;
      }

      @Override
      protected String getUserDnSuffix() {
        return null;
      }
    };
    String principal = "foo";
    String userDn = realm.getUserDn(principal);
    assertEquals(principal, userDn);
  }
}
origin: org.apache.shiro/shiro-core

/**
 * Returns the User Distinguished Name (DN) template to use when creating User DNs at runtime - see the
 * {@link #setUserDnTemplate(String) setUserDnTemplate} JavaDoc for a full explanation.
 *
 * @return the User Distinguished Name (DN) template to use when creating User DNs at runtime.
 */
public String getUserDnTemplate() {
  return getUserDn(USERDN_SUBSTITUTION_TOKEN);
}
origin: org.apache.shiro/shiro-core

/**
 * Returns the principal to use when creating the LDAP connection for an authentication attempt.
 * <p/>
 * This implementation uses a heuristic: it checks to see if the specified token's
 * {@link AuthenticationToken#getPrincipal() principal} is a {@code String}, and if so,
 * {@link #getUserDn(String) converts it} from what is
 * assumed to be a raw uid or username {@code String} into a User DN {@code String}.  Almost all LDAP directories
 * expect the authentication connection to present a User DN and not an unqualified username or uid.
 * <p/>
 * If the token's {@code principal} is not a String, it is assumed to already be in the format supported by the
 * underlying {@link LdapContextFactory} implementation and the raw principal is returned directly.
 *
 * @param token the {@link AuthenticationToken} submitted during the authentication process
 * @return the User DN or raw principal to use to acquire the LdapContext.
 * @see LdapContextFactory#getLdapContext(Object, Object)
 */
protected Object getLdapPrincipal(AuthenticationToken token) {
  Object principal = token.getPrincipal();
  if (principal instanceof String) {
    String sPrincipal = (String) principal;
    return getUserDn(sPrincipal);
  }
  return principal;
}
org.apache.shiro.realm.ldapDefaultLdapRealmgetUserDn

Javadoc

Returns the LDAP User Distinguished Name (DN) to use when acquiring an javax.naming.ldap.LdapContext from the LdapContextFactory.

If the the #getUserDnTemplate() property has been set, this implementation will construct the User DN by substituting the specified principal into the configured template. If the #getUserDnTemplate() has not been set, the method argument will be returned directly (indicating that the submitted authentication token principal is the User DN).

Popular methods of DefaultLdapRealm

  • getContextFactory
    Returns the LdapContextFactory instance used to acquire connections to the LDAP directory during aut
  • queryForAuthenticationInfo
    This implementation opens an LDAP connection using the token's #getLdapPrincipal(org.apache.shiro.au
  • <init>
    Default no-argument constructor that defaults the internal LdapContextFactory instance to a JndiLdap
  • createAuthenticationInfo
    Returns the AuthenticationInfo resulting from a Subject's successful LDAP authentication attempt. Th
  • doGetAuthenticationInfo
    Delegates to #queryForAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken,LdapContextFacto
  • doGetAuthorizationInfo
  • getAuthenticationInfo
  • getAuthenticationTokenClass
  • getCredentialsMatcher
  • getLdapPrincipal
    Returns the principal to use when creating the LDAP connection for an authentication attempt. This i
  • getName
  • getUserDnPrefix
    Returns the User DN prefix to use when building a runtime User DN value or null if no #getUserDnTemp
  • getName,
  • getUserDnPrefix,
  • getUserDnSuffix,
  • getUserDnTemplate,
  • queryForAuthorizationInfo,
  • setAuthenticationTokenClass,
  • setContextFactory,
  • setCredentialsMatcher,
  • setUserDnTemplate

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • getApplicationContext (Context)
  • findViewById (Activity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now