Codota Logo
SecurityContextLoginModule
Code IndexAdd Codota to your IDE (free)

How to use
SecurityContextLoginModule
in
org.springframework.security.authentication.jaas

Best Java code snippets using org.springframework.security.authentication.jaas.SecurityContextLoginModule (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-security

@Test
public void testNullAuthenticationInSecurityContextIgnored() throws Exception {
  this.module = new SecurityContextLoginModule();
  Map<String, String> options = new HashMap<>();
  options.put("ignoreMissingAuthentication", "true");
  this.module.initialize(this.subject, null, null, options);
  SecurityContextHolder.getContext().setAuthentication(null);
  assertThat(this.module.login()).as("Should return false and ask to be ignored")
      .isFalse();
}
origin: spring-projects/spring-security

@Test
public void testAbort() throws Exception {
  assertThat(this.module.abort()).as("Should return false, no auth is set")
      .isFalse();
  SecurityContextHolder.getContext().setAuthentication(this.auth);
  this.module.login();
  this.module.commit();
  assertThat(this.module.abort()).isTrue();
}
origin: spring-projects/spring-security

  @Test
  public void testNullLogout() throws Exception {
    assertThat(this.module.logout()).isFalse();
  }
}
origin: spring-projects/spring-security

@Before
public void setUp() throws Exception {
  this.module = new SecurityContextLoginModule();
  this.module.initialize(this.subject, null, null, null);
  SecurityContextHolder.clearContext();
}
origin: spring-projects/spring-security

@Test
public void testLogout() throws Exception {
  SecurityContextHolder.getContext().setAuthentication(this.auth);
  this.module.login();
  assertThat(this.module.logout()).as("Should return true as it succeeds").isTrue();
  assertThat(this.module.getAuthentication()).as("Authentication should be null")
      .isNull();
  assertThat(this.subject.getPrincipals().contains(this.auth))
      .withFailMessage(
          "Principals should not contain the authentication after logout")
      .isFalse();
}
origin: spring-projects/spring-security

@Test
public void testLoginSuccess() throws Exception {
  SecurityContextHolder.getContext().setAuthentication(this.auth);
  assertThat(this.module.login())
      .as("Login should succeed, there is an authentication set").isTrue();
  assertThat(this.module.commit())
      .withFailMessage(
          "The authentication is not null, this should return true")
      .isTrue();
  assertThat(this.subject.getPrincipals().contains(this.auth))
      .withFailMessage("Principals should contain the authentication").isTrue();
}
origin: spring-projects/spring-security

@Test
public void testNullAuthenticationInSecurityContext() throws Exception {
  try {
    SecurityContextHolder.getContext().setAuthentication(null);
    this.module.login();
    fail("LoginException expected, the authentication is null in the SecurityContext");
  }
  catch (Exception e) {
  }
}
origin: spring-projects/spring-security

@Test
public void testLoginException() throws Exception {
  try {
    this.module.login();
    fail("LoginException expected, there is no Authentication in the SecurityContext");
  }
  catch (LoginException e) {
  }
}
org.springframework.security.authentication.jaasSecurityContextLoginModule

Javadoc

An implementation of LoginModule that uses a Spring Security org.springframework.security.core.context.SecurityContext to provide authentication.

This LoginModule provides opposite functionality to the JaasAuthenticationProvider API, and should not really be used in conjunction with it.

The JaasAuthenticationProvider allows Spring Security to authenticate against Jaas.

The SecurityContextLoginModule allows a Jaas based application to authenticate against Spring Security. If there is no Authentication in the SecurityContextHolder the login() method will throw a LoginException by default. This functionality can be changed with the ignoreMissingAuthentication option by setting it to "true". Setting ignoreMissingAuthentication=true will tell the SecurityContextLoginModule to simply return false and be ignored if the authentication is null.

Most used methods

  • <init>
  • abort
    Abort the authentication process by forgetting the Spring SecurityAuthentication .
  • commit
    Authenticate the Subject (phase two) by adding the Spring SecurityAuthentication to the Subject's p
  • getAuthentication
  • initialize
    Initialize this LoginModule. Ignores the callback handler, since the code establishing the LoginCont
  • login
    Authenticate the Subject (phase one) by extracting the Spring Security Authentication from the curre
  • logout
    Log out the Subject.

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • setContentView (Activity)
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • ImageIO (javax.imageio)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now