Package org.springframework.security

Examples of org.springframework.security.Authentication


        this.displaySuccess = displaySuccess;
    }

    protected void doExecuteCommand() {
        ApplicationSecurityManager sm = (ApplicationSecurityManager)ApplicationServicesLocator.services().getService(ApplicationSecurityManager.class);
        Authentication loggedOutAuth = sm.doLogout();
        onLogout(loggedOutAuth);

        if (displaySuccess) {
            JOptionPane.showMessageDialog(getParentWindowControl(), "You have been logged out.", "Logout Successful",
                    JOptionPane.INFORMATION_MESSAGE);
View Full Code Here


        if (logger.isDebugEnabled() && event instanceof ClientSecurityEvent) {
            logger.debug("Processing event: " + event.toString());
        }

        if (event instanceof LoginEvent) {
            Authentication authentication = (Authentication)event.getSource();
            updateExporters(authentication.getPrincipal().toString(), authentication.getCredentials().toString());
        }
        else if (event instanceof LogoutEvent) {
            updateExporters(null, null);
        }
    }
View Full Code Here

     */
    protected void prepareConnection(HttpURLConnection con, int contentLength) throws IOException {

        super.prepareConnection( con, contentLength );

        Authentication auth = getAuthenticationToken();

        if( (auth != null) && (auth.getName() != null) && (auth.getCredentials() != null) ) {
            String base64 = auth.getName() + ":" + auth.getCredentials().toString();
            con.setRequestProperty( "Authorization", "Basic " + new String( Base64.encodeBase64( base64.getBytes() ) ) );

            if( logger.isDebugEnabled() ) {
                logger.debug( "HttpInvocation now presenting via BASIC authentication with token:: " + auth );
            }
View Full Code Here

* Date: Nov 9, 2008
* Time: 8:04:02 PM
*/
public class SpringSecurityUtils {
    public static Collection getPrincipalAuthorities() {
        Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();

        if (null == currentUser) {
            return Collections.EMPTY_LIST;
        }

        if ((null == currentUser.getAuthorities()) || (currentUser.getAuthorities().length < 1)) {
            return Collections.EMPTY_LIST;
        }

        Collection granted = Arrays.asList(currentUser.getAuthorities());

        return granted;
    }
View Full Code Here

   
    protected void beforeProcess(Exchange exchange) throws Exception {
        ConfigAttributeDefinition attributes = accessPolicy.getConfigAttributeDefinition();
       
        try {
            Authentication authToken = getAuthentication(exchange.getIn());
            if (authToken == null) {
                CamelAuthorizationException authorizationException =
                    new CamelAuthorizationException("Cannot find the Authentication instance.", exchange);
                throw authorizationException;
            }
           
            Authentication authenticated = authenticateIfRequired(authToken);
           
            // Attempt authorization with exchange
            try {
                this.accessDecisionManager.decide(authenticated, exchange, attributes);
            } catch (AccessDeniedException accessDeniedException) {
View Full Code Here

            throw authorizationException;
        }
    }
   
    protected Authentication getAuthentication(Message message) {
        Authentication answer = message.getHeader(Exchange.AUTHENTICATION, Authentication.class);
        // try to get it from thread context as a fallback
        if (answer == null && useThreadSecurityContext) {
            answer = SecurityContextHolder.getContext().getAuthentication();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Get the authentication from SecurityContextHolder");
View Full Code Here

   
    @Test
    public void testGetAuthorizationTokenFromSecurityContextHolder() throws Exception {
        MockEndpoint end = getMockEndpoint("mock:end");
        end.expectedBodiesReceived("hello world");
        Authentication authToken = createAuthenticationToken("jim", "jimspassword", "ROLE_USER", "ROLE_ADMIN");
        SecurityContextHolder.getContext().setAuthentication(authToken);
        template.sendBody("direct:start", "hello world");
        end.assertIsSatisfied();
        SecurityContextHolder.getContext().setAuthentication(null);
       
View Full Code Here

        SecurityContextHolder.getContext().setAuthentication(null);
       
    }
   
    private Authentication createAuthenticationToken(String username, String password, String... roles) {
        Authentication authToken;
        if (roles != null && roles.length > 0) {
            GrantedAuthority[] authorities = new GrantedAuthority[roles.length];
            for (int i = 0; i < roles.length; i++) {
                authorities[i] = new GrantedAuthorityImpl(roles[i]);
            }
View Full Code Here

        return authToken;
    }

    private void sendMessageWithAuthentication(String username, String password, String... roles) {

        Authentication authToken = createAuthenticationToken(username, password, roles);
       
        Subject subject = new Subject();
        subject.getPrincipals().add(authToken);

        template.sendBodyAndHeader("direct:start", "hello world", Exchange.AUTHENTICATION, subject);
View Full Code Here

  @SuppressWarnings("deprecation")
  private void authenticate(WSPasswordCallback passwordCallback){
    String userName = passwordCallback.getIdentifer();
    String password = passwordCallback.getPassword();
   
    Authentication authentication = new UsernamePasswordAuthenticationToken(userName, password);
    try {
      authentication = authenticationManager.authenticate(authentication);
      if (authentication.isAuthenticated()) {
        // Set the security context
        SecurityContext securityContext = new SecurityContextImpl();
        securityContext.setAuthentication(authentication);
        SecurityContextHolder.setContext(securityContext);
      } else {
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.