Package org.springframework.security

Examples of org.springframework.security.Authentication


  public String generateRowLevelSecurityConstraint( LogicalModel model ) {
    RowLevelSecurity rls = model.getRowLevelSecurity();
    if ( rls == null || rls.getType() == RowLevelSecurity.Type.NONE ) {
      return null;
    }
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if ( auth == null ) {
      logger.info( Messages.getInstance().getString( "SecurityAwareCwmSchemaFactory.INFO_AUTH_NULL_CONTINUE" ) ); //$NON-NLS-1$
      return "FALSE()"; //$NON-NLS-1$
    }
    String username = auth.getName();
    HashSet<String> roles = null;
    roles = new HashSet<String>();
    for ( GrantedAuthority role : auth.getAuthorities() ) {
      roles.add( role.getAuthority() );
    }

    RowLevelSecurityHelper helper = new SessionAwareRowLevelSecurityHelper();
    return helper.getOpenFormulaSecurityConstraint( rls, username, new ArrayList<String>( roles ) );
View Full Code Here


@SuppressWarnings( "deprecation" )
public class PentahoUserOverridesVoter extends PentahoBasicAclVoter {

  @Override
  public AclEntry[] getEffectiveAcls( final IPentahoSession session, final IAclHolder holder ) {
    Authentication auth = getAuthentication( session );
    // User is un-authenticated. Return no access controls.
    if ( auth == null ) {
      return null;
    }
    AclEntry[] objectAcls = super.getEffectiveAcls( session, holder );
    if ( objectAcls == null ) {
      return null;
    }
    Object principal = auth.getPrincipal();
    String userName = null;
    if ( principal instanceof UserDetails ) {
      userName = ( (UserDetails) principal ).getUsername();
    } else {
      userName = principal.toString();
View Full Code Here

    // and a member of the adminRole specified.
    return isGranted( session, adminRole );
  }

  public boolean isGranted( final IPentahoSession session, GrantedAuthority role ) {
    Authentication auth = getAuthentication( session );
    if ( ( auth != null ) && auth.isAuthenticated() ) {
      GrantedAuthority[] userAuths = auth.getAuthorities();
      if ( userAuths == null ) {
        return false;
      }
      for ( GrantedAuthority element : userAuths ) {
        if ( element.equals( role ) ) {
View Full Code Here

  public Authentication getAuthentication( final IPentahoSession session ) {
    return SecurityHelper.getInstance().getAuthentication();
  }

  public boolean hasAccess( final IPentahoSession session, final IAclHolder holder, final int mask ) {
    Authentication auth = getAuthentication( session );
    // If we're not authenticated, default to no access and return.
    if ( auth == null ) {
      return false;
    }
    // admins can do anything they want!
View Full Code Here

    }
    return false;
  }

  public AclEntry[] getEffectiveAcls( final IPentahoSession session, final IAclHolder holder ) {
    Authentication auth = getAuthentication( session );
    if ( auth == null ) {
      return null; // No user, so no ACLs.
    }
    List allAcls = holder.getEffectiveAccessControls();
    AclEntry[] acls = new AclEntry[allAcls.size()];
View Full Code Here

  protected List<String> getRuntimeRoleNames() {
    IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
    List<String> runtimeRoles = new ArrayList<String>();
    Assert.state( pentahoSession != null );
    Authentication authentication = SecurityHelper.getInstance().getAuthentication();
    if ( authentication != null ) {
      GrantedAuthority[] authorities = authentication.getAuthorities();
      for ( int i = 0; i < authorities.length; i++ ) {
        runtimeRoles.add( authorities[ i ].getAuthority() );
      }
    }
    return runtimeRoles;
View Full Code Here

    pentahoSession.setAuthenticated( repositoryAdminUsername );
    final GrantedAuthority[] repositoryAdminAuthorities = new GrantedAuthority[] {};
    final String password = "ignored";
    UserDetails repositoryAdminUserDetails =
        new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
    Authentication repositoryAdminAuthentication =
        new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
    PentahoSessionHolder.setSession( pentahoSession );
    // this line necessary for Spring Security's MethodSecurityInterceptor
    SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );
  }
View Full Code Here

    for ( String roleName : roles ) {
      authList.add( new GrantedAuthorityImpl( roleName ) );
    }
    GrantedAuthority[] authorities = authList.toArray( new GrantedAuthority[0] );
    UserDetails userDetails = new User( username, PASSWORD, true, true, true, true, authorities );
    Authentication auth = new UsernamePasswordAuthenticationToken( userDetails, PASSWORD, authorities );
    PentahoSessionHolder.setSession( pentahoSession );
    // this line necessary for Spring Security's MethodSecurityInterceptor
    SecurityContextHolder.getContext().setAuthentication( auth );

    createUserHomeFolder( tenant, username );
View Full Code Here

    final GrantedAuthority[] repositoryAdminAuthorities =
      new GrantedAuthority[] { new GrantedAuthorityImpl( superAdminRoleName ) };
    final String password = "ignored";
    UserDetails repositoryAdminUserDetails =
      new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
    Authentication repositoryAdminAuthentication =
      new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
    PentahoSessionHolder.setSession( pentahoSession );
    // this line necessary for Spring Security's MethodSecurityInterceptor
    SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );
  }
View Full Code Here

    SecurityContextHolder.getContext().setAuthentication( null );
  }

  protected void createUserHomeFolder( final ITenant theTenant, final String theUsername ) {
    IPentahoSession origPentahoSession = PentahoSessionHolder.getSession();
    Authentication origAuthentication = SecurityContextHolder.getContext().getAuthentication();
    StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
    pentahoSession.setAuthenticated( null, repositoryAdminUsername );
    PentahoSessionHolder.setSession( pentahoSession );
    try {
      txnTemplate.execute( new TransactionCallbackWithoutResult() {
View Full Code Here

TOP

Related Classes of org.springframework.security.Authentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.