Package com.swinarta.sunflower.server.auth

Source Code of com.swinarta.sunflower.server.auth.SpringSecurityVerifier

package com.swinarta.sunflower.server.auth;

import org.restlet.security.LocalVerifier;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import com.swinarta.sunflower.core.model.User;

public class SpringSecurityVerifier extends LocalVerifier{

  @Override
  public char[] getLocalSecret(String username) {   
    return "password".toCharArray();
  }
 
   public boolean verify(String identifier, char[] secret){
     boolean value =  super.verify(identifier, secret);
     if(value){
          User user = new User();
          user.setId(9);
          user.setUsername(identifier);

          Authentication auth = new UsernamePasswordAuthenticationToken(user,secret);
          SecurityContextHolder.getContext().setAuthentication(auth);
     }
     return value;
   }
 
}
TOP

Related Classes of com.swinarta.sunflower.server.auth.SpringSecurityVerifier

TOP
Copyright © 2018 www.massapi.com. 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.