Hello!

Please refer to SecurityContextHolder - get(), push(), pop().

When getting null you can just do SecurityContextHolder.get().

Regards,
-- 
Ilya Kasnacheev


пт, 8 февр. 2019 г. в 22:45, Sergio Hernández Martínez <
[email protected]>:

> hi everyone,
>
> I'm developing my own authorization plugin. I've arrived to a point that
> i'm blocked.
>
> My code is:
>
> public void authorize(String s, SecurityPermission securityPermission,
> @Nullable SecurityContext securityContext) throws SecurityException {
>         if (securityContext.subject().login().equals("test-user")) {
>             System.out.println("You can entry");
>         } else {
>             System.out.println("You cannot entry");
>         }
>     }
>
> I have a problem, always securityContext is null. But in my code i have:
>
> public SecurityContext authenticate(AuthenticationContext
> authenticationContext) throws IgniteCheckedException {
>         SecurityPluginSecuritySubject securityPluginSecuritySubject = new
> SecurityPluginSecuritySubject(
>                 authenticationContext.subjectId(),
>                 authenticationContext.subjectType(),
>                 authenticationContext.credentials().getLogin(),
>                 authenticationContext.address()
>         );
>
>         return new
> SecurityPluginSecurityContext(securityPluginSecuritySubject);
> }
>
> In ignite code (
> https://github.com/apache/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java)
> i've saw:
>
>
>  /**
>      * @param op Operation to check.
>      * @throws SecurityException If security check failed.
>      */
>     public void checkSecurity(SecurityPermission op) throws
> SecurityException {
>         if (CU.isSystemCache(name()))
>             return;
>
>         ctx.security().authorize(name(), op, null);
>     }
>
> In security context always is null. Why? Am I missing something in my code?
>
> Thank's for your help.
>

Reply via email to