Tabnine Logo
RunAsManagerImpl.setKey
Code IndexAdd Tabnine to your IDE (free)

How to use
setKey
method
in
org.springframework.security.access.intercept.RunAsManagerImpl

Best Java code snippets using org.springframework.security.access.intercept.RunAsManagerImpl.setKey (Showing top 5 results out of 315)

origin: spring-projects/spring-security

  @Override
  protected RunAsManager runAsManager() {
    RunAsManagerImpl runAsManager = new RunAsManagerImpl();
    runAsManager.setKey("some key");
    return runAsManager;
  }
}
origin: spring-projects/spring-security

@Test
public void testStartupSuccessfulWithKey() throws Exception {
  RunAsManagerImpl runAs = new RunAsManagerImpl();
  runAs.setKey("hello_world");
  runAs.afterPropertiesSet();
  assertThat(runAs.getKey()).isEqualTo("hello_world");
}
origin: spring-projects/spring-security

@Test
public void testRespectsRolePrefix() throws Exception {
  UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken(
      "Test", "Password", AuthorityUtils.createAuthorityList("ONE", "TWO"));
  RunAsManagerImpl runAs = new RunAsManagerImpl();
  runAs.setKey("my_password");
  runAs.setRolePrefix("FOOBAR_");
  Authentication result = runAs.buildRunAs(inputToken, new Object(),
      SecurityConfig.createList("RUN_AS_SOMETHING"));
  assertThat(result instanceof RunAsUserToken).withFailMessage(
      "Should have returned a RunAsUserToken").isTrue();
  assertThat(result.getPrincipal()).isEqualTo(inputToken.getPrincipal());
  assertThat(result.getCredentials()).isEqualTo(inputToken.getCredentials());
  Set<String> authorities = AuthorityUtils.authorityListToSet(
      result.getAuthorities());
  assertThat(authorities.contains("FOOBAR_RUN_AS_SOMETHING")).isTrue();
  assertThat(authorities.contains("ONE")).isTrue();
  assertThat(authorities.contains("TWO")).isTrue();
  RunAsUserToken resultCast = (RunAsUserToken) result;
  assertThat(resultCast.getKeyHash()).isEqualTo("my_password".hashCode());
}
origin: spring-projects/spring-security

@Test
public void testReturnsAdditionalGrantedAuthorities() throws Exception {
  UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken(
      "Test", "Password",
      AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
  RunAsManagerImpl runAs = new RunAsManagerImpl();
  runAs.setKey("my_password");
  Authentication result = runAs.buildRunAs(inputToken, new Object(),
      SecurityConfig.createList("RUN_AS_SOMETHING"));
  if (!(result instanceof RunAsUserToken)) {
    fail("Should have returned a RunAsUserToken");
  }
  assertThat(result.getPrincipal()).isEqualTo(inputToken.getPrincipal());
  assertThat(result.getCredentials()).isEqualTo(inputToken.getCredentials());
  Set<String> authorities = AuthorityUtils.authorityListToSet(
      result.getAuthorities());
  assertThat(authorities.contains("ROLE_RUN_AS_SOMETHING")).isTrue();
  assertThat(authorities.contains("ROLE_ONE")).isTrue();
  assertThat(authorities.contains("ROLE_TWO")).isTrue();
  RunAsUserToken resultCast = (RunAsUserToken) result;
  assertThat(resultCast.getKeyHash()).isEqualTo("my_password".hashCode());
}
origin: spring-projects/spring-security

@Test
public void testDoesNotReturnAdditionalAuthoritiesIfCalledWithoutARunAsSetting()
    throws Exception {
  UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken(
      "Test", "Password",
      AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
  RunAsManagerImpl runAs = new RunAsManagerImpl();
  runAs.setKey("my_password");
  Authentication resultingToken = runAs.buildRunAs(inputToken, new Object(),
      SecurityConfig.createList("SOMETHING_WE_IGNORE"));
  assertThat(resultingToken).isNull();
}
org.springframework.security.access.interceptRunAsManagerImplsetKey

Popular methods of RunAsManagerImpl

  • supports
  • getRolePrefix
  • <init>
  • afterPropertiesSet
  • buildRunAs
  • getKey
  • setRolePrefix
    Allows the default role prefix of ROLE_ to be overridden. May be set to an empty value, although thi

Popular in Java

  • Making http requests using okhttp
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JOptionPane (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • 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