Tabnine Logo
Credentials.getUsername
Code IndexAdd Tabnine to your IDE (free)

How to use
getUsername
method
in
de.otto.edison.authentication.Credentials

Best Java code snippets using de.otto.edison.authentication.Credentials.getUsername (Showing top 5 results out of 315)

origin: otto-de/edison-microservice

String userDnFrom(final Credentials credentials, String baseDN) {
  return format("%s=%s,%s", ldapProperties.getRdnIdentifier(), credentials.getUsername(), baseDN);
}
origin: otto-de/edison-microservice

@Bean
@ConditionalOnMissingBean(UserProvider.class)
public UserProvider userProvider() {
  return () -> {
    final HttpServletRequest request = HttpServletRequestHolder.get();
    final Optional<Credentials> credentials = Credentials.readFrom(request);
    final boolean isAdmin = true; // "admin".equals(username);
    return new SimpleFeatureUser((credentials.isPresent() ? credentials.get().getUsername() : null), isAdmin);
  };
}
origin: otto-de/edison-microservice

private Optional<HttpServletRequest> tryToGetAuthenticatedRequest(final HttpServletRequest request, final Credentials credentials) {
  try (final LDAPConnection ldap = ldapConnectionFactory.buildLdapConnection()) {
    for (String baseDN : ldapProperties.getBaseDn()) {
      final String userDN = userDnFrom(credentials, baseDN);
      try {
        if (authenticate(ldap, userDN, credentials.getPassword())) {
          return ldapProperties.getRoleBaseDn() != null
              ? Optional.of(new LdapRoleCheckingRequest(request, ldap, userDN, ldapProperties))
              : Optional.of(request);
        }
      } catch (LDAPBindException e) {
        LOG.debug("LDAPBindException for userDN: {}", userDN);
      }
    }
    LOG.warn("Could not bind to LDAP: {}", credentials.getUsername());
  } catch (LDAPException | GeneralSecurityException e) {
    LOG.warn("Authentication error: ", e);
  }
  return Optional.empty();
}
origin: otto-de/edison-microservice

  @Test
  public void shouldReturnCorrectCredentialsIfPasswordContainsColons() {
    // given
    mockHttpServletRequestWithAuthentication("user:pass:word");

    // when
    final Optional<Credentials> credentials = Credentials.readFrom(httpServletRequest);

    // then
    assertThat(credentials.isPresent(), is(true));
    assertThat(credentials.get().getUsername(), is("user"));
    assertThat(credentials.get().getPassword(), is("pass:word"));
  }
}
origin: otto-de/edison-microservice

@Test
public void shouldBeAbleToReadCredentialsFromRequest() {
  // given
  mockHttpServletRequestWithAuthentication("someUsername:somePassword");
  // when
  final Optional<Credentials> credentials = Credentials.readFrom(httpServletRequest);
  // then
  assertThat(credentials.isPresent(), is(true));
  assertThat(credentials.get().getUsername(), is("someUsername"));
  assertThat(credentials.get().getPassword(), is("somePassword"));
}
de.otto.edison.authenticationCredentialsgetUsername

Popular methods of Credentials

  • readFrom
    Read username and password from the request's Authorization header and create a Credentialsobject. R
  • <init>
  • getPassword

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • JTable (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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