@@ -0,0 +1,2278 @@
+/*%0A * Copyright 2002-2016 the original author or authors.%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 org.springframework.security.acls.domain;%0A%0A%0Aimport java.util.Arrays;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0Aimport org.springframework.security.acls.model.Acl;%0Aimport org.springframework.security.authentication.TestingAuthenticationToken;%0Aimport org.springframework.security.core.GrantedAuthority;%0Aimport org.springframework.security.core.authority.SimpleGrantedAuthority;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0A%0A/**%0A *%0A * @author Rob Winch%0A *%0A */%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class AclAuthorizationStrategyImplTests %7B%0A%09@Mock%0A%09Acl acl;%0A%09GrantedAuthority authority;%0A%09AclAuthorizationStrategyImpl strategy;%0A%0A%09@Before%0A%09public void setup() %7B%0A%09%09authority = new SimpleGrantedAuthority(%22ROLE_AUTH%22);%0A%09%09strategy = new AclAuthorizationStrategyImpl(authority);%0A%09%09TestingAuthenticationToken authentication = new TestingAuthenticationToken(%22foo%22, %22bar%22, Arrays.asList(authority));%0A%09%09authentication.setAuthenticated(true);%0A%09%09SecurityContextHolder.getContext().setAuthentication(authentication);%0A%09%7D%0A%0A%09@After%0A%09public void cleanup() %7B%0A%09%09SecurityContextHolder.clearContext();%0A%09%7D%0A%0A%09// gh-4085%0A%09@Test%0A%09public void securityCheckWhenCustomAuthorityThenNameIsUsed() %7B%0A%09%09strategy = new AclAuthorizationStrategyImpl(new CustomAuthority());%0A%09%09strategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL);%0A%09%7D%0A%0A%09@SuppressWarnings(%22serial%22)%0A%09class CustomAuthority implements GrantedAuthority %7B%0A%09%09@Override%0A%09%09public String getAuthority() %7B%0A%09%09%09return authority.getAuthority();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add securityCheckWhenCustomAuthorityThenNameIsUsed