package org.zalando.nakadi.plugin.auth;

import org.springframework.security.core.context.SecurityContextHolder;
import org.zalando.nakadi.plugin.api.PluginException;
import org.zalando.nakadi.plugin.api.authz.AuthorizationAttribute;
import org.zalando.nakadi.plugin.api.authz.AuthorizationService;
import org.zalando.nakadi.plugin.api.authz.Resource;
import org.zalando.nakadi.plugin.api.authz.Subject;

import java.util.List;

public class DefaultAuthorizationService implements AuthorizationService {

    @Override
    public boolean isAuthorized(final Operation operation, final Resource resource) {
        return true;
    }

    @Override
    public boolean isAuthorizationAttributeValid(final AuthorizationAttribute authorizationAttribute) {
        return true;
    }

    @Override
    public Subject getSubject() {
        return () -> SecurityContextHolder.getContext().getAuthentication().getName();
    }

    @Override
    public List<Resource> filter(final List<Resource> input) throws PluginException {
        return input;
    }
}

@@ -414,17 +414,76 @@
 ava.
-util.List
+security.Principal;%0Aimport java.util.List;%0Aimport java.util.Optional
 ;%0A%0Ap
@@ -899,16 +899,53 @@
 rn () -%3E
+ Optional.ofNullable(%0A               
  Securit
@@ -995,17 +995,45 @@
 on()
-.getName(
+).map(Principal::getName).orElse(null
 );%0A 

Fix NullPointerException resulting in MalformedChunk in AcceptanceTests