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

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-security

authorities.add(new JaasGrantedAuthority(role, principal));
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: org.springframework.security/spring-security-core

authorities.add(new JaasGrantedAuthority(role, principal));
origin: Teradata/kylo

public static Set<Principal> getCurrentPrincipals() {
  Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  Set<Principal> principals = new HashSet<>();
  
  if (auth != null) {
    for (GrantedAuthority grant : auth.getAuthorities()) {
      if (grant instanceof JaasGrantedAuthority) {
        JaasGrantedAuthority jaasGrant = (JaasGrantedAuthority) grant;
        principals.add(jaasGrant.getPrincipal());
      } else {
        String authority = grant.getAuthority();
        
        if (authority != null) {
          principals.add(new SimplePrincipal(authority));
        }
      }
    }
    
    principals.add(new UsernamePrincipal(auth.getName()));
  } else {
    principals.add(new AnonymousPrincipal());
  }
  
  return principals;
}

origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape

public OverrideCredentials(Principal userPrincipal, Set<Principal> rolePrincipals) {
  super();
  this.userPrincipal = userPrincipal;
  this.rolePrincipals = Collections.unmodifiableSet(new HashSet<>(rolePrincipals));
  
  Collection<? extends GrantedAuthority> authorities = Stream.concat(Stream.of(this.userPrincipal), this.rolePrincipals.stream())
          .map(p -> new JaasGrantedAuthority(p.getName(), p))
          .collect(Collectors.toSet());
  this.authentication = new UsernameAuthenticationToken(userPrincipal, authorities);
}
origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape

@Override
public boolean hasRole(String roleName) {
  boolean matched = this.authentication.getAuthorities().stream().anyMatch(grant -> {
    if (grant instanceof JaasGrantedAuthority) {
      JaasGrantedAuthority jaasGrant = (JaasGrantedAuthority) grant;
      return JcrAccessControlUtil.matchesRole(jaasGrant.getPrincipal(), roleName);
    } else {
      if (roleName.equals(grant.getAuthority())) {
        return true;
      } else {
        return false;
      }
    }
  });
  if (matched) {
    return true;
  } else {
    return this.principals.stream().anyMatch(principal -> JcrAccessControlUtil.matchesRole(principal, roleName));
  }
}
origin: com.thinkbiganalytics.kylo/kylo-commons-test

@Override
public SecurityContext createSecurityContext(WithMockJaasUser withUser) {
  String username = StringUtils.hasLength(withUser.username()) ? withUser.username() : withUser.value();
  List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
  
  for (String authority : withUser.authorities()) {
    grantedAuthorities.add(new JaasGrantedAuthority(authority, new GroupPrincipal(authority)));
  }
  User principal = new User(username, withUser.password(), true, true, true, true, grantedAuthorities);
  Authentication authentication = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), principal.getAuthorities());
  SecurityContext context = SecurityContextHolder.createEmptyContext();
  context.setAuthentication(authentication);
  return context;
}

origin: com.thinkbiganalytics.kylo/kylo-commons-security

public static Set<Principal> getCurrentPrincipals() {
  Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  Set<Principal> principals = new HashSet<>();
  
  if (auth != null) {
    for (GrantedAuthority grant : auth.getAuthorities()) {
      if (grant instanceof JaasGrantedAuthority) {
        JaasGrantedAuthority jaasGrant = (JaasGrantedAuthority) grant;
        principals.add(jaasGrant.getPrincipal());
      } else {
        String authority = grant.getAuthority();
        
        if (authority != null) {
          principals.add(new SimplePrincipal(authority));
        }
      }
    }
    
    principals.add(new UsernamePrincipal(auth.getName()));
  } else {
    principals.add(new AnonymousPrincipal());
  }
  
  return principals;
}

origin: org.springframework.security/org.springframework.security.core

authorities.add(new JaasGrantedAuthority(role, principal));
origin: apache/servicemix-bundles

authorities.add(new JaasGrantedAuthority(role, principal));
org.springframework.security.authentication.jaasJaasGrantedAuthority

Javadoc

GrantedAuthority which, in addition to the assigned role, holds the principal that an AuthorityGranter used as a reason to grant this authority.

Most used methods

  • <init>
  • getPrincipal

Popular in Java

  • Reactive rest calls using spring rest template
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • onCreateOptionsMenu (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • ImageIO (javax.imageio)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
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