import org.springframework.security.core.context.SecurityContext;
public class UsernameLeakyBucketKeyFactory implements LeakyBucketKeyFactory<UsernameLeakyBucketKey> {
@Override
public UsernameLeakyBucketKey create(SecurityContext context) {
return new UsernameLeakyBucketKey(context.getAuthentication().getName());
}