Custom security service using annotation Spring Boot

Custom security service using annotation Spring Boot:

Create our security service

package com.yamicode.utils;

//service that you should replace with your implementation
import com.yamicode.domain.User;
import com.yamicode.service.UserService;

//java imports
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

public class YamiSecurityService {

    UserService userService;

    public boolean isNotForbidden(){
    	//replace this by your security implementation of user
        User user = userService.getAuthenticatedUser();

        //test: you can do whatever you want to do
        return !user.isForbidden();


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping(value = "/api/yamicode")
public class YamiCodeRest{

    void getResource() {
        //wathever you planning to do