@Test public void shouldBeAuthorizedWhenTheCurrentAuthorizationContextHasTheSpecifiedAnnoationScope() throws Throwable { provider.withScopes("accounts:read"); advisor.handle(authorize().withScopes("accounts:read").build()); }
@Before("execution(* *(..)) && @annotation(authorize)") public void handle(Authorize authorize) throws Throwable { if (!provider.isAuthenticated()) { throw new AuthenticationException(new Reportable("auth.not.authenticated")); } if (isNotBlank(authorize.scopes())) { checkScopes(authorize.scopes()); } if (isNotBlank(authorize.roles())) { checkRoles(authorize.roles()); } if (isNotBlank(authorize.authorities())) { checkAuthorities(authorize.authorities()); } }
AuthorizationAdvisor { @Before("execution(* *(..)) && @annotation(authorize)") public void handle(Authorize authorize) throws Throwable { if (!provider.isAuthenticated()) { throw new AuthenticationException(new Reportable("auth.not.authenticated")); } if (isNotBlank(authorize.scopes())) { checkScopes(authorize.scopes()); } if (isNotBlank(authorize.roles())) { checkRoles(authorize.roles()); } if (isNotBlank(authorize.authorities())) { checkAuthorities(authorize.authorities()); } } }
AuthorizationAdvisor { @Before("execution(* *(..)) && @annotation(authorize)") public void handle(Authorize authorize) throws Throwable { if (!provider.isAuthenticated()) { throw new AuthenticationException(new Reportable("auth.not.authenticated")); } if (isNotBlank(authorize.scopes())) { checkScopes(authorize.scopes()); } if (isNotBlank(authorize.roles())) { checkRoles(authorize.roles()); } if (isNotBlank(authorize.authorities())) { checkAuthorities(authorize.authorities()); } } @Autowired  AuthorizationAdvisor(AuthorizationContextProvider provider); }
AuthorizationAdvisor { @Before("execution(* *(..)) && @annotation(authorize)") public void handle(Authorize authorize) throws Throwable { if (!provider.isAuthenticated()) { throw new AuthenticationException(new Reportable("auth.not.authenticated")); } if (isNotBlank(authorize.scopes())) { checkScopes(authorize.scopes()); } if (isNotBlank(authorize.roles())) { checkRoles(authorize.roles()); } if (isNotBlank(authorize.authorities())) { checkAuthorities(authorize.authorities()); } } @Autowired  AuthorizationAdvisor(AuthorizationContextProvider provider); @Before("execution(* *(..)) && @annotation(authorize)") void handle(Authorize authorize); }
AuthorizationAdvisor { @Before("execution(* *(..)) && @annotation(authorize)") public void handle(Authorize authorize) throws Throwable { if (!provider.isAuthenticated()) { throw new AuthenticationException(new Reportable("auth.not.authenticated")); } if (isNotBlank(authorize.scopes())) { checkScopes(authorize.scopes()); } if (isNotBlank(authorize.roles())) { checkRoles(authorize.roles()); } if (isNotBlank(authorize.authorities())) { checkAuthorities(authorize.authorities()); } } @Autowired  AuthorizationAdvisor(AuthorizationContextProvider provider); @Before("execution(* *(..)) && @annotation(authorize)") void handle(Authorize authorize);  }