congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JaasAuthenticationProvider.getLoginContextName
Code IndexAdd Tabnine to your IDE (free)

How to use
getLoginContextName
method
in
org.springframework.security.authentication.jaas.JaasAuthenticationProvider

Best Java code snippets using org.springframework.security.authentication.jaas.JaasAuthenticationProvider.getLoginContextName (Showing top 12 results out of 315)

origin: spring-projects/spring-security

@Override
protected LoginContext createLoginContext(CallbackHandler handler)
    throws LoginException {
  return new LoginContext(getLoginContextName(), handler);
}
origin: org.springframework.security/spring-security-core

@Override
protected LoginContext createLoginContext(CallbackHandler handler)
    throws LoginException {
  return new LoginContext(getLoginContextName(), handler);
}
origin: spring-projects/spring-security

@Override
public void afterPropertiesSet() throws Exception {
  // the superclass is not called because it does additional checks that are
  // non-passive
  Assert.hasLength(getLoginContextName(),
      () -> "loginContextName must be set on " + getClass());
  Assert.notNull(this.loginConfig,
      () -> "loginConfig must be set on " + getClass());
  configureJaas(this.loginConfig);
  Assert.notNull(Configuration.getConfiguration(),
      "As per http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html "
          + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is "
          + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to "
          + "Configuration.getConfiguration().");
}
origin: org.springframework.security/spring-security-core

@Override
public void afterPropertiesSet() throws Exception {
  // the superclass is not called because it does additional checks that are
  // non-passive
  Assert.hasLength(getLoginContextName(),
      () -> "loginContextName must be set on " + getClass());
  Assert.notNull(this.loginConfig,
      () -> "loginConfig must be set on " + getClass());
  configureJaas(this.loginConfig);
  Assert.notNull(Configuration.getConfiguration(),
      "As per http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html "
          + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is "
          + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to "
          + "Configuration.getConfiguration().");
}
origin: spring-projects/spring-security

@Test
public void testLogout() throws Exception {
  MockLoginContext loginContext = new MockLoginContext(
      jaasProvider.getLoginContextName());
  JaasAuthenticationToken token = new JaasAuthenticationToken(null, null,
      loginContext);
  SecurityContext context = SecurityContextHolder.createEmptyContext();
  context.setAuthentication(token);
  SessionDestroyedEvent event = mock(SessionDestroyedEvent.class);
  when(event.getSecurityContexts()).thenReturn(Arrays.asList(context));
  jaasProvider.handleLogout(event);
  assertThat(loginContext.loggedOut).isTrue();
}
origin: spring-projects/spring-security

@Test
public void spacesInLoginConfigPathAreAccepted() throws Exception {
  File configFile;
  // Create temp directory with a space in the name
  File configDir = new File(System.getProperty("java.io.tmpdir") + File.separator
      + "jaas test");
  configDir.deleteOnExit();
  if (configDir.exists()) {
    configDir.delete();
  }
  configDir.mkdir();
  configFile = File.createTempFile("login", "conf", configDir);
  configFile.deleteOnExit();
  FileOutputStream fos = new FileOutputStream(configFile);
  PrintWriter pw = new PrintWriter(fos);
  pw.append("JAASTestBlah {"
      + "org.springframework.security.authentication.jaas.TestLoginModule required;"
      + "};");
  pw.flush();
  pw.close();
  JaasAuthenticationProvider myJaasProvider = new JaasAuthenticationProvider();
  myJaasProvider.setApplicationEventPublisher(context);
  myJaasProvider.setLoginConfig(new FileSystemResource(configFile));
  myJaasProvider.setAuthorityGranters(jaasProvider.getAuthorityGranters());
  myJaasProvider.setCallbackHandlers(jaasProvider.getCallbackHandlers());
  myJaasProvider.setLoginContextName(jaasProvider.getLoginContextName());
  myJaasProvider.afterPropertiesSet();
}
origin: spring-projects/spring-security

@Test
public void testFull() throws Exception {
  UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
      "user", "password", AuthorityUtils.createAuthorityList("ROLE_ONE"));
  assertThat(jaasProvider.supports(UsernamePasswordAuthenticationToken.class)).isTrue();
  Authentication auth = jaasProvider.authenticate(token);
  assertThat(jaasProvider.getAuthorityGranters()).isNotNull();
  assertThat(jaasProvider.getCallbackHandlers()).isNotNull();
  assertThat(jaasProvider.getLoginConfig()).isNotNull();
  assertThat(jaasProvider.getLoginContextName()).isNotNull();
  Collection<? extends GrantedAuthority> list = auth.getAuthorities();
  Set<String> set = AuthorityUtils.authorityListToSet(list);
  assertThat(set.contains("ROLE_ONE")).withFailMessage("GrantedAuthorities should not contain ROLE_ONE").isFalse();
  assertThat(set.contains("ROLE_TEST1")).withFailMessage("GrantedAuthorities should contain ROLE_TEST1").isTrue();
  assertThat(set.contains("ROLE_TEST2")).withFailMessage("GrantedAuthorities should contain ROLE_TEST2").isTrue();
  boolean foundit = false;
  for (GrantedAuthority a : list) {
    if (a instanceof JaasGrantedAuthority) {
      JaasGrantedAuthority grant = (JaasGrantedAuthority) a;
      assertThat(grant.getPrincipal()).withFailMessage("Principal was null on JaasGrantedAuthority").isNotNull();
      foundit = true;
    }
  }
  assertThat(foundit).as("Could not find a JaasGrantedAuthority").isTrue();
  assertThat(eventCheck.successEvent).as("Success event should be fired").isNotNull();
  assertThat(eventCheck.successEvent.getAuthentication()).withFailMessage("Auth objects should be equal").isEqualTo(auth);
  assertThat(eventCheck.failedEvent).as("Failure event should not be fired").isNull();
}
origin: spring-projects/spring-security

@Test
public void detectsMissingLoginConfig() throws Exception {
  JaasAuthenticationProvider myJaasProvider = new JaasAuthenticationProvider();
  myJaasProvider.setApplicationEventPublisher(context);
  myJaasProvider.setAuthorityGranters(jaasProvider.getAuthorityGranters());
  myJaasProvider.setCallbackHandlers(jaasProvider.getCallbackHandlers());
  myJaasProvider.setLoginContextName(jaasProvider.getLoginContextName());
  try {
    myJaasProvider.afterPropertiesSet();
    fail("Should have thrown ApplicationContextException");
  }
  catch (IllegalArgumentException expected) {
    assertThat(expected.getMessage().startsWith("loginConfig must be set on")).isTrue();
  }
}
origin: apache/servicemix-bundles

@Override
protected LoginContext createLoginContext(CallbackHandler handler)
    throws LoginException {
  return new LoginContext(getLoginContextName(), handler);
}
origin: org.springframework.security/org.springframework.security.core

@Override
protected LoginContext createLoginContext(CallbackHandler handler) throws LoginException {
  return new LoginContext(getLoginContextName(), handler);
}
origin: org.springframework.security/org.springframework.security.core

public void afterPropertiesSet() throws Exception {
  // the superclass is not called because it does additional checks that are non-passive
  Assert.hasLength(getLoginContextName(), "loginContextName must be set on " + getClass());
  Assert.notNull(loginConfig, "loginConfig must be set on " + getClass());
  configureJaas(loginConfig);
  Assert.notNull(
      Configuration.getConfiguration(),
      "As per http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html "
          + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is "
          + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to "
          + "Configuration.getConfiguration().");
}
origin: apache/servicemix-bundles

@Override
public void afterPropertiesSet() throws Exception {
  // the superclass is not called because it does additional checks that are
  // non-passive
  Assert.hasLength(getLoginContextName(),
      () -> "loginContextName must be set on " + getClass());
  Assert.notNull(this.loginConfig,
      () -> "loginConfig must be set on " + getClass());
  configureJaas(this.loginConfig);
  Assert.notNull(Configuration.getConfiguration(),
      "As per http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html "
          + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is "
          + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to "
          + "Configuration.getConfiguration().");
}
org.springframework.security.authentication.jaasJaasAuthenticationProvidergetLoginContextName

Popular methods of JaasAuthenticationProvider

  • getApplicationEventPublisher
  • configureJaas
    Hook method for configuring Jaas.
  • configureJaasUsingLoop
    Loops through the login.config.url.1,login.config.url.2 properties looking for the login configurati
  • convertLoginConfigToUrl
  • <init>
  • afterPropertiesSet
  • setLoginConfig
    Set the JAAS login configuration file.
  • setLoginContextName
  • authenticate
  • getAuthorityGranters
  • getCallbackHandlers
  • getLoginConfig
  • getCallbackHandlers,
  • getLoginConfig,
  • getLoginExceptionResolver,
  • handleLogout,
  • setApplicationEventPublisher,
  • setAuthorityGranters,
  • setCallbackHandlers,
  • setLoginExceptionResolver,
  • setRefreshConfigurationOnStartup

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top plugins for Android Studio
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