Package org.springframework.security

Examples of org.springframework.security.Authentication


   * rule.
   * @param rule the rule to base the decision
   * @param object the execution listener phase
   */
  protected void decide(SecurityRule rule, Object object) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    ConfigAttributeDefinition config = new ConfigAttributeDefinition(getConfigAttributes(rule));
    if (accessDecisionManager != null) {
      accessDecisionManager.decide(authentication, object, config);
    } else {
      AbstractAccessDecisionManager abstractAccessDecisionManager;
View Full Code Here


    @Autowired
    LogManagerService logService;

    @After( "UIPointcuts.loginPointcut()" )
    public void logLoginOperation( JoinPoint joinPoint ) {
        Authentication authenticationInfo = SecurityContextHolder.getContext().getAuthentication();
        if ( authenticationInfo != null && !ROLE_ANONYMOUS.equals( authenticationInfo.getPrincipal() ) ) {
            final String userName = ( ( User ) authenticationInfo.getPrincipal() ).getUsername();
            final SimpleAction action = new SimpleAction( PosibleOperations.getMethod( joinPoint.getSignature().getName() ), userName );
            logService.addLog( action );
        }
    }
View Full Code Here

        authToken, request, SecurityRequestHolder.getResponse(),
        _apiKey, _secretKey);

    token.setDetails(authenticationDetailsSource.buildDetails(request));

    Authentication authentication = getAuthenticationManager().authenticate(token);
    if (authentication.isAuthenticated()) {
      setLastUsername(token.getUserId(), request);
    }

    return authentication;
  }
View Full Code Here

                authToken, request, SecurityRequestHolder.getResponse(),
                _apiKey, _secretKey);

        token.setDetails(authenticationDetailsSource.buildDetails(request));

        Authentication authentication = getAuthenticationManager().authenticate(token);
        if (authentication.isAuthenticated()) {
            setLastUsername(token.getUserId(), request);
        }

        return authentication;
    }
View Full Code Here

                return true;
            }

            user = userService.createUser(fullName, email, username, password1);

            Authentication token = new UsernamePasswordAuthenticationToken(username, password1);
            Authentication result = authenticationManager.authenticate(token);
            SecurityContext securityContext = new SecurityContextImpl();
            securityContext.setAuthentication(result);
            SecurityContextHolder.setContext(securityContext);

            String path = redirectField.getValue();
View Full Code Here

      session.setAuthenticated( principalName );
    }

    PentahoSessionHolder.setSession( session );

    Authentication auth = createAuthentication( principalName );
    // TODO We need to figure out how to inject this
    // Get the tenant id from the principle name and set it as an attribute of the pentaho session

    SecurityContextHolder.getContext().setAuthentication( auth );
    PentahoSystem.sessionStartup( PentahoSessionHolder.getSession(), paramProvider );
View Full Code Here

  @Override
  public <T> T
  runAsUser( final String principalName, final IParameterProvider paramProvider, final Callable<T> callable )
    throws Exception {
    IPentahoSession origSession = PentahoSessionHolder.getSession();
    Authentication origAuth = SecurityContextHolder.getContext().getAuthentication();
    try {
      becomeUser( principalName );
      return callable.call();
    } finally {
      IPentahoSession sessionToDestroy = PentahoSessionHolder.getSession();
View Full Code Here

   * @see {@link Callable}
   */
  @Override
  public <T> T runAsAnonymous( final Callable<T> callable ) throws Exception {
    IPentahoSession origSession = PentahoSessionHolder.getSession();
    Authentication origAuth = SecurityContextHolder.getContext().getAuthentication();
    try {
      PentahoSessionHolder.setSession( new StandaloneSession() );

      // get anonymous username/role defined in pentaho.xml
      String user = PentahoSystem
        .getSystemSetting( "anonymous-authentication/anonymous-user", "anonymousUser" ); //$NON-NLS-1$//$NON-NLS-2$
      String role = PentahoSystem
        .getSystemSetting( "anonymous-authentication/anonymous-role", "Anonymous" ); //$NON-NLS-1$//$NON-NLS-2$
      GrantedAuthority[] authorities = new GrantedAuthority[] { new GrantedAuthorityImpl( role ) };

      Authentication auth =
        new AnonymousAuthenticationToken( "anonymousUser", new User( user, "ignored", true, true, true, true,
          authorities ), authorities );

      SecurityContextHolder.getContext().setAuthentication( auth );
      return callable.call();
View Full Code Here

    for ( int i = 0; i < roles.size(); i++ ) {
      grantedAuthorities[ i ] = new GrantedAuthorityImpl( roles.get( i ) );
    }

    User user = new User( principalName, "", true, true, true, true, grantedAuthorities );
    Authentication auth = new UsernamePasswordAuthenticationToken( user, null, grantedAuthorities );
    return auth;

  }
View Full Code Here

   */
  public <T> T runAsSystem( final Callable<T> callable ) throws Exception {
    String singleTenantAdmin = PentahoSystem.get( String.class, "singleTenantAdminUserName", null );
    IPentahoSession origSession = PentahoSessionHolder.getSession();

    Authentication origAuth = SecurityContextHolder.getContext().getAuthentication();

    StandaloneSession session = null;
    try {
      session = new StandaloneSession( singleTenantAdmin );
      session.setAuthenticated( singleTenantAdmin );

      // Set the session first or else the call to
      // createAuthentication will fail
      PentahoSessionHolder.setSession( session );

      // Now create the authentication
      Authentication auth = createAuthentication( singleTenantAdmin ); //$NON-NLS-1$
      SecurityContextHolder.getContext().setAuthentication( auth );

      // Invoke the delta.
      return callable.call();
    } finally {
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.