@@ -0,0 +1,2536 @@
+/**%0A * Copyright (C) 2015 Agro-Know, Deutsches Forschungszentrum f%C3%BCr K%C3%BCnstliche Intelligenz, iMinds,%0A * Institut f%C3%BCr Angewandte Informatik e. V. an der Universit%C3%A4t Leipzig,%0A * Istituto Superiore Mario Boella, Tilde, Vistatec, WRIPL (http://freme-project.eu)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *         http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage eu.freme.bservices.usercontroller;%0A%0Aimport eu.freme.common.persistence.model.User;%0A%0Aimport org.springframework.security.access.AccessDecisionVoter;%0Aimport org.springframework.security.access.ConfigAttribute;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport java.util.Collection;%0A%0A/**%0A * @author Jonathan Sauder jsauder@campus.tu-berlin.de%0A */%0A@Component%0Apublic class UserAccessDecisionVoter implements AccessDecisionVoter%3CObject%3E %7B%0A%0A    @Override%0A    public boolean supports(ConfigAttribute attribute) %7B%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean supports(Class%3C?%3E clazz) %7B%0A        return clazz == User.class;%0A    %7D%0A%0A    @Override%0A    public int vote(Authentication authentication, Object object,%0A                    Collection%3CConfigAttribute%3E attributes) %7B%0A        try %7B%0A            User user = (User) object;%0A%0A            //temporary%0A            //System.out.println(%22Successfully casted from Object to User%22);%0A%0A            if (authentication.getPrincipal().equals(%22anonymousUser%22)) %7B%0A                return ACCESS_DENIED;%0A            %7D%0A%0A            User authenticatedUser = (User) authentication.getPrincipal();%0A%0A            if (authenticatedUser.getRole().equals(User.roleAdmin)) %7B%0A                return ACCESS_GRANTED;%0A            %7D else if (authenticatedUser.getName().equals(user.getName())) %7B%0A                return ACCESS_GRANTED;%0A            %7D else %7B%0A                return ACCESS_DENIED;%0A            %7D%0A        %7D catch (ClassCastException e) %7B%0A            //temporary%0A            //System.out.println(%22Handled ClassCastException from some Object to User%22);%0A            return ACCESS_ABSTAIN;%0A        %7D%0A    %7D%0A%7D

move UserAccessDecisionVoter to user-controller