Remove redundant throws clauses

Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
This commit is contained in:
Lars Grefer 2019-08-23 01:03:54 +02:00
parent f0515a021c
commit 34dd5fea30
418 changed files with 1146 additions and 1273 deletions

View File

@ -74,7 +74,7 @@ class AclClassIdUtils {
return identifier; return identifier;
} }
private boolean hasValidClassIdType(ResultSet resultSet) throws SQLException { private boolean hasValidClassIdType(ResultSet resultSet) {
boolean hasClassIdType = false; boolean hasClassIdType = false;
try { try {
hasClassIdType = classIdTypeFrom(resultSet) != null; hasClassIdType = classIdTypeFrom(resultSet) != null;

View File

@ -32,7 +32,7 @@ public class AclFormattingUtilsTests {
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
@Test @Test
public final void testDemergePatternsParametersConstraints() throws Exception { public final void testDemergePatternsParametersConstraints() {
try { try {
AclFormattingUtils.demergePatterns(null, "SOME STRING"); AclFormattingUtils.demergePatterns(null, "SOME STRING");
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
@ -63,7 +63,7 @@ public class AclFormattingUtilsTests {
} }
@Test @Test
public final void testDemergePatterns() throws Exception { public final void testDemergePatterns() {
String original = "...........................A...R"; String original = "...........................A...R";
String removeBits = "...............................R"; String removeBits = "...............................R";
assertThat(AclFormattingUtils.demergePatterns(original, removeBits)).isEqualTo( assertThat(AclFormattingUtils.demergePatterns(original, removeBits)).isEqualTo(
@ -76,7 +76,7 @@ public class AclFormattingUtilsTests {
} }
@Test @Test
public final void testMergePatternsParametersConstraints() throws Exception { public final void testMergePatternsParametersConstraints() {
try { try {
AclFormattingUtils.mergePatterns(null, "SOME STRING"); AclFormattingUtils.mergePatterns(null, "SOME STRING");
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
@ -106,7 +106,7 @@ public class AclFormattingUtilsTests {
} }
@Test @Test
public final void testMergePatterns() throws Exception { public final void testMergePatterns() {
String original = "...............................R"; String original = "...............................R";
String extraBits = "...........................A...."; String extraBits = "...........................A....";
assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo( assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo(
@ -119,7 +119,7 @@ public class AclFormattingUtilsTests {
} }
@Test @Test
public final void testBinaryPrints() throws Exception { public final void testBinaryPrints() {
assertThat(AclFormattingUtils.printBinary(15)).isEqualTo( assertThat(AclFormattingUtils.printBinary(15)).isEqualTo(
"............................****"); "............................****");

View File

@ -36,7 +36,7 @@ import java.util.List;
public class AclPermissionCacheOptimizerTests { public class AclPermissionCacheOptimizerTests {
@Test @Test
public void eagerlyLoadsRequiredAcls() throws Exception { public void eagerlyLoadsRequiredAcls() {
AclService service = mock(AclService.class); AclService service = mock(AclService.class);
AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service); AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service);
ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class); ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class);

View File

@ -37,7 +37,7 @@ import org.springframework.security.core.Authentication;
public class AclPermissionEvaluatorTests { public class AclPermissionEvaluatorTests {
@Test @Test
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception { public void hasPermissionReturnsTrueIfAclGrantsPermission() {
AclService service = mock(AclService.class); AclService service = mock(AclService.class);
AclPermissionEvaluator pe = new AclPermissionEvaluator(service); AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
ObjectIdentity oid = mock(ObjectIdentity.class); ObjectIdentity oid = mock(ObjectIdentity.class);

View File

@ -37,7 +37,7 @@ import java.util.List;
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public class AclEntryAfterInvocationCollectionFilteringProviderTests { public class AclEntryAfterInvocationCollectionFilteringProviderTests {
@Test @Test
public void objectsAreRemovedIfPermissionDenied() throws Exception { public void objectsAreRemovedIfPermissionDenied() {
AclService service = mock(AclService.class); AclService service = mock(AclService.class);
Acl acl = mock(Acl.class); Acl acl = mock(Acl.class);
when(acl.isGranted(any(), any(), anyBoolean())).thenReturn( when(acl.isGranted(any(), any(), anyBoolean())).thenReturn(
@ -63,7 +63,7 @@ public class AclEntryAfterInvocationCollectionFilteringProviderTests {
} }
@Test @Test
public void accessIsGrantedIfNoAttributesDefined() throws Exception { public void accessIsGrantedIfNoAttributesDefined() {
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider( AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class))); mock(AclService.class), Arrays.asList(mock(Permission.class)));
Object returned = new Object(); Object returned = new Object();
@ -75,7 +75,7 @@ public class AclEntryAfterInvocationCollectionFilteringProviderTests {
} }
@Test @Test
public void nullReturnObjectIsIgnored() throws Exception { public void nullReturnObjectIsIgnored() {
AclService service = mock(AclService.class); AclService service = mock(AclService.class);
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider( AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
service, Arrays.asList(mock(Permission.class))); service, Arrays.asList(mock(Permission.class)));

View File

@ -37,7 +37,7 @@ import java.util.List;
public class AclEntryAfterInvocationProviderTests { public class AclEntryAfterInvocationProviderTests {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void rejectsMissingPermissions() throws Exception { public void rejectsMissingPermissions() {
try { try {
new AclEntryAfterInvocationProvider(mock(AclService.class), null); new AclEntryAfterInvocationProvider(mock(AclService.class), null);
fail("Exception expected"); fail("Exception expected");
@ -72,7 +72,7 @@ public class AclEntryAfterInvocationProviderTests {
} }
@Test @Test
public void accessIsGrantedIfNoAttributesDefined() throws Exception { public void accessIsGrantedIfNoAttributesDefined() {
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class))); mock(AclService.class), Arrays.asList(mock(Permission.class)));
Object returned = new Object(); Object returned = new Object();
@ -85,7 +85,7 @@ public class AclEntryAfterInvocationProviderTests {
} }
@Test @Test
public void accessIsGrantedIfObjectTypeNotSupported() throws Exception { public void accessIsGrantedIfObjectTypeNotSupported() {
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
mock(AclService.class), Arrays.asList(mock(Permission.class))); mock(AclService.class), Arrays.asList(mock(Permission.class)));
provider.setProcessDomainObjectClass(String.class); provider.setProcessDomainObjectClass(String.class);
@ -131,7 +131,7 @@ public class AclEntryAfterInvocationProviderTests {
} }
@Test @Test
public void nullReturnObjectIsIgnored() throws Exception { public void nullReturnObjectIsIgnored() {
AclService service = mock(AclService.class); AclService service = mock(AclService.class);
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider( AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
service, Arrays.asList(mock(Permission.class))); service, Arrays.asList(mock(Permission.class)));

View File

@ -54,7 +54,7 @@ public class AclImplTests {
// ======================================================================================================== // ========================================================================================================
@Before @Before
public void setUp() throws Exception { public void setUp() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
authzStrategy = mock(AclAuthorizationStrategy.class); authzStrategy = mock(AclAuthorizationStrategy.class);
mockAuditLogger = mock(AuditLogger.class); mockAuditLogger = mock(AuditLogger.class);
@ -63,12 +63,12 @@ public class AclImplTests {
} }
@After @After
public void tearDown() throws Exception { public void tearDown() {
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullObjectIdentity() throws Exception { public void constructorsRejectNullObjectIdentity() {
try { try {
new AclImpl(null, 1, authzStrategy, pgs, null, null, true, new PrincipalSid( new AclImpl(null, 1, authzStrategy, pgs, null, null, true, new PrincipalSid(
"joe")); "joe"));
@ -80,7 +80,7 @@ public class AclImplTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullId() throws Exception { public void constructorsRejectNullId() {
try { try {
new AclImpl(objectIdentity, null, authzStrategy, pgs, null, null, true, new AclImpl(objectIdentity, null, authzStrategy, pgs, null, null, true,
new PrincipalSid("joe")); new PrincipalSid("joe"));
@ -93,7 +93,7 @@ public class AclImplTests {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorsRejectNullAclAuthzStrategy() throws Exception { public void constructorsRejectNullAclAuthzStrategy() {
try { try {
new AclImpl(objectIdentity, 1, null, new DefaultPermissionGrantingStrategy( new AclImpl(objectIdentity, 1, null, new DefaultPermissionGrantingStrategy(
mockAuditLogger), null, null, true, new PrincipalSid("joe")); mockAuditLogger), null, null, true, new PrincipalSid("joe"));
@ -105,7 +105,7 @@ public class AclImplTests {
} }
@Test @Test
public void insertAceRejectsNullParameters() throws Exception { public void insertAceRejectsNullParameters() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
try { try {
@ -123,7 +123,7 @@ public class AclImplTests {
} }
@Test @Test
public void insertAceAddsElementAtCorrectIndex() throws Exception { public void insertAceAddsElementAtCorrectIndex() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
MockAclService service = new MockAclService(); MockAclService service = new MockAclService();
@ -166,7 +166,7 @@ public class AclImplTests {
} }
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void insertAceFailsForNonExistentElement() throws Exception { public void insertAceFailsForNonExistentElement() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
MockAclService service = new MockAclService(); MockAclService service = new MockAclService();
@ -180,7 +180,7 @@ public class AclImplTests {
} }
@Test @Test
public void deleteAceKeepsInitialOrdering() throws Exception { public void deleteAceKeepsInitialOrdering() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
MockAclService service = new MockAclService(); MockAclService service = new MockAclService();
@ -217,7 +217,7 @@ public class AclImplTests {
} }
@Test @Test
public void deleteAceFailsForNonExistentElement() throws Exception { public void deleteAceFailsForNonExistentElement() {
AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl( AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(
new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority( new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority(
"ROLE_AUDITING"), new SimpleGrantedAuthority("ROLE_GENERAL")); "ROLE_AUDITING"), new SimpleGrantedAuthority("ROLE_GENERAL"));
@ -232,7 +232,7 @@ public class AclImplTests {
} }
@Test @Test
public void isGrantingRejectsEmptyParameters() throws Exception { public void isGrantingRejectsEmptyParameters() {
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
Sid ben = new PrincipalSid("ben"); Sid ben = new PrincipalSid("ben");
@ -251,7 +251,7 @@ public class AclImplTests {
} }
@Test @Test
public void isGrantingGrantsAccessForAclWithNoParent() throws Exception { public void isGrantingGrantsAccessForAclWithNoParent() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL", "ROLE_GUEST"); "ROLE_GENERAL", "ROLE_GUEST");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -297,7 +297,7 @@ public class AclImplTests {
} }
@Test @Test
public void isGrantingGrantsAccessForInheritableAcls() throws Exception { public void isGrantingGrantsAccessForInheritableAcls() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL"); "ROLE_GENERAL");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -379,7 +379,7 @@ public class AclImplTests {
} }
@Test @Test
public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception { public void updatedAceValuesAreCorrectlyReflectedInAcl() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL"); "ROLE_GENERAL");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -411,7 +411,7 @@ public class AclImplTests {
} }
@Test @Test
public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception { public void auditableEntryFlagsAreUpdatedCorrectly() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_AUDITING", "ROLE_GENERAL"); "ROLE_AUDITING", "ROLE_GENERAL");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -449,7 +449,7 @@ public class AclImplTests {
} }
@Test @Test
public void gettersAndSettersAreConsistent() throws Exception { public void gettersAndSettersAreConsistent() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_GENERAL"); "ROLE_GENERAL");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -485,7 +485,7 @@ public class AclImplTests {
} }
@Test @Test
public void isSidLoadedBehavesAsExpected() throws Exception { public void isSidLoadedBehavesAsExpected() {
List<Sid> loadedSids = Arrays.asList(new PrincipalSid("ben"), List<Sid> loadedSids = Arrays.asList(new PrincipalSid("ben"),
new GrantedAuthoritySid("ROLE_IGNORED")); new GrantedAuthoritySid("ROLE_IGNORED"));
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null,
@ -513,22 +513,21 @@ public class AclImplTests {
} }
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true); acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true);
} }
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception { public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
acl.deleteAce(-1); acl.deleteAce(-1);
} }
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() {
throws Exception {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
// Insert at zero, OK. // Insert at zero, OK.
@ -539,7 +538,7 @@ public class AclImplTests {
// SEC-1151 // SEC-1151
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception { public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() {
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
acl.insertAce(0, mock(Permission.class), mock(Sid.class), true); acl.insertAce(0, mock(Permission.class), mock(Sid.class), true);
@ -549,7 +548,7 @@ public class AclImplTests {
// SEC-1795 // SEC-1795
@Test @Test
public void changingParentIsSuccessful() throws Exception { public void changingParentIsSuccessful() {
AclImpl parentAcl = new AclImpl(objectIdentity, 1L, authzStrategy, AclImpl parentAcl = new AclImpl(objectIdentity, 1L, authzStrategy,
mockAuditLogger); mockAuditLogger);
AclImpl childAcl = new AclImpl(objectIdentity, 2L, authzStrategy, mockAuditLogger); AclImpl childAcl = new AclImpl(objectIdentity, 2L, authzStrategy, mockAuditLogger);

View File

@ -41,17 +41,17 @@ public class AclImplementationSecurityCheckTests {
// ======================================================================================================== // ========================================================================================================
@Before @Before
public void setUp() throws Exception { public void setUp() {
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
@After @After
public void tearDown() throws Exception { public void tearDown() {
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
@Test @Test
public void testSecurityCheckNoACEs() throws Exception { public void testSecurityCheckNoACEs() {
Authentication auth = new TestingAuthenticationToken("user", "password", Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL", "ROLE_AUDITING", "ROLE_OWNERSHIP"); "ROLE_GENERAL", "ROLE_AUDITING", "ROLE_OWNERSHIP");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -103,7 +103,7 @@ public class AclImplementationSecurityCheckTests {
} }
@Test @Test
public void testSecurityCheckWithMultipleACEs() throws Exception { public void testSecurityCheckWithMultipleACEs() {
// Create a simple authentication with ROLE_GENERAL // Create a simple authentication with ROLE_GENERAL
Authentication auth = new TestingAuthenticationToken("user", "password", Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL"); "ROLE_GENERAL");
@ -206,7 +206,7 @@ public class AclImplementationSecurityCheckTests {
} }
@Test @Test
public void testSecurityCheckWithInheritableACEs() throws Exception { public void testSecurityCheckWithInheritableACEs() {
// Create a simple authentication with ROLE_GENERAL // Create a simple authentication with ROLE_GENERAL
Authentication auth = new TestingAuthenticationToken("user", "password", Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL"); "ROLE_GENERAL");
@ -273,7 +273,7 @@ public class AclImplementationSecurityCheckTests {
} }
@Test @Test
public void testSecurityCheckPrincipalOwner() throws Exception { public void testSecurityCheckPrincipalOwner() {
Authentication auth = new TestingAuthenticationToken("user", "password", Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_ONE"); "ROLE_ONE");
auth.setAuthenticated(true); auth.setAuthenticated(true);

View File

@ -44,7 +44,7 @@ public class AuditLoggerTests {
// ======================================================================================================== // ========================================================================================================
@Before @Before
public void setUp() throws Exception { public void setUp() {
logger = new ConsoleAuditLogger(); logger = new ConsoleAuditLogger();
ace = mock(AuditableAccessControlEntry.class); ace = mock(AuditableAccessControlEntry.class);
console = System.out; console = System.out;
@ -52,7 +52,7 @@ public class AuditLoggerTests {
} }
@After @After
public void tearDown() throws Exception { public void tearDown() {
System.setOut(console); System.setOut(console);
bytes.reset(); bytes.reset();
} }
@ -65,14 +65,14 @@ public class AuditLoggerTests {
} }
@Test @Test
public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception { public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() {
when(ace.isAuditSuccess()).thenReturn(false); when(ace.isAuditSuccess()).thenReturn(false);
logger.logIfNeeded(true, ace); logger.logIfNeeded(true, ace);
assertThat(bytes.size()).isZero(); assertThat(bytes.size()).isZero();
} }
@Test @Test
public void successIsLoggedIfAceRequiresSuccessAudit() throws Exception { public void successIsLoggedIfAceRequiresSuccessAudit() {
when(ace.isAuditSuccess()).thenReturn(true); when(ace.isAuditSuccess()).thenReturn(true);
logger.logIfNeeded(true, ace); logger.logIfNeeded(true, ace);
@ -80,14 +80,14 @@ public class AuditLoggerTests {
} }
@Test @Test
public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception { public void failureIsntLoggedIfAceDoesntRequireFailureAudit() {
when(ace.isAuditFailure()).thenReturn(false); when(ace.isAuditFailure()).thenReturn(false);
logger.logIfNeeded(false, ace); logger.logIfNeeded(false, ace);
assertThat(bytes.size()).isZero(); assertThat(bytes.size()).isZero();
} }
@Test @Test
public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception { public void failureIsLoggedIfAceRequiresFailureAudit() {
when(ace.isAuditFailure()).thenReturn(true); when(ace.isAuditFailure()).thenReturn(true);
logger.logIfNeeded(false, ace); logger.logIfNeeded(false, ace);
assertThat(bytes.toString()).startsWith("DENIED due to ACE"); assertThat(bytes.toString()).startsWith("DENIED due to ACE");

View File

@ -36,7 +36,7 @@ public class ObjectIdentityImplTests {
// ======================================================================================================== // ========================================================================================================
@Test @Test
public void constructorsRespectRequiredFields() throws Exception { public void constructorsRespectRequiredFields() {
// Check one-argument constructor required field // Check one-argument constructor required field
try { try {
new ObjectIdentityImpl(null); new ObjectIdentityImpl(null);
@ -79,14 +79,14 @@ public class ObjectIdentityImplTests {
} }
@Test @Test
public void gettersReturnExpectedValues() throws Exception { public void gettersReturnExpectedValues() {
ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L); ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L);
assertThat(obj.getIdentifier()).isEqualTo(1L); assertThat(obj.getIdentifier()).isEqualTo(1L);
assertThat(obj.getType()).isEqualTo(MockIdDomainObject.class.getName()); assertThat(obj.getType()).isEqualTo(MockIdDomainObject.class.getName());
} }
@Test @Test
public void testGetIdMethodConstraints() throws Exception { public void testGetIdMethodConstraints() {
// Check the getId() method is present // Check the getId() method is present
try { try {
new ObjectIdentityImpl("A_STRING_OBJECT"); new ObjectIdentityImpl("A_STRING_OBJECT");
@ -125,12 +125,12 @@ public class ObjectIdentityImplTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorRejectsInvalidTypeParameter() throws Exception { public void constructorRejectsInvalidTypeParameter() {
new ObjectIdentityImpl("", 1L); new ObjectIdentityImpl("", 1L);
} }
@Test @Test
public void testEquals() throws Exception { public void testEquals() {
ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L); ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, 1L);
MockIdDomainObject mockObj = new MockIdDomainObject(); MockIdDomainObject mockObj = new MockIdDomainObject();
mockObj.setId(1L); mockObj.setId(1L);
@ -148,7 +148,7 @@ public class ObjectIdentityImplTests {
} }
@Test @Test
public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception { public void hashcodeIsDifferentForDifferentJavaTypes() {
ObjectIdentity obj = new ObjectIdentityImpl(Object.class, 1L); ObjectIdentity obj = new ObjectIdentityImpl(Object.class, 1L);
ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, 1L); ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, 1L);
assertThat(obj.hashCode()).isNotEqualTo(obj2.hashCode()); assertThat(obj.hashCode()).isNotEqualTo(obj2.hashCode());
@ -164,7 +164,7 @@ public class ObjectIdentityImplTests {
} }
@Test @Test
public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception { public void equalStringIdsAreEqualAndHaveSameHashcode() {
ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000");
ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000");
assertThat(obj2).isEqualTo(obj); assertThat(obj2).isEqualTo(obj);
@ -172,7 +172,7 @@ public class ObjectIdentityImplTests {
} }
@Test @Test
public void stringAndNumericIdsAreNotEqual() throws Exception { public void stringAndNumericIdsAreNotEqual() {
ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000");
ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, 1000L); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, 1000L);
assertThat(obj).isNotEqualTo(obj2); assertThat(obj).isNotEqualTo(obj2);

View File

@ -31,7 +31,7 @@ public class ObjectIdentityRetrievalStrategyImplTests {
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
@Test @Test
public void testObjectIdentityCreation() throws Exception { public void testObjectIdentityCreation() {
MockIdDomainObject domain = new MockIdDomainObject(); MockIdDomainObject domain = new MockIdDomainObject();
domain.setId(1); domain.setId(1);

View File

@ -171,7 +171,7 @@ public abstract class AbstractBasicLookupStrategyTests {
} }
private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid, private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid,
Map<ObjectIdentity, Acl> map) throws Exception { Map<ObjectIdentity, Acl> map) {
assertThat(map).hasSize(3); assertThat(map).hasSize(3);
MutableAcl topParent = (MutableAcl) map.get(topParentOid); MutableAcl topParent = (MutableAcl) map.get(topParentOid);
@ -238,7 +238,7 @@ public abstract class AbstractBasicLookupStrategyTests {
} }
@Test @Test
public void testAllParentsAreRetrievedWhenChildIsLoaded() throws Exception { public void testAllParentsAreRetrievedWhenChildIsLoaded() {
String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,103,1,1,1);"; String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,103,1,1,1);";
getJdbcTemplate().execute(query); getJdbcTemplate().execute(query);
@ -266,7 +266,7 @@ public abstract class AbstractBasicLookupStrategyTests {
* Test created from SEC-590. * Test created from SEC-590.
*/ */
@Test @Test
public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() throws Exception { public void testReadAllObjectIdentitiesWhenLastElementIsAlreadyCached() {
String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,105,null,1,1);" String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,105,null,1,1);"
+ "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,106,6,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (7,2,106,6,1,1);"
+ "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (8,2,107,6,1,1);" + "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (8,2,107,6,1,1);"

View File

@ -151,13 +151,13 @@ public class AclClassIdUtilsTest {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void shouldNotAcceptNullConversionServiceInConstruction() throws SQLException { public void shouldNotAcceptNullConversionServiceInConstruction() {
// when // when
new AclClassIdUtils(null); new AclClassIdUtils(null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void shouldNotAcceptNullConversionServiceInSetter() throws SQLException { public void shouldNotAcceptNullConversionServiceInSetter() {
// when // when
aclClassIdUtils.setConversionService(null); aclClassIdUtils.setConversionService(null);
} }

View File

@ -37,7 +37,7 @@ public class BasicLookupStrategyTests extends AbstractBasicLookupStrategyTests {
} }
@AfterClass @AfterClass
public static void dropDatabase() throws Exception { public static void dropDatabase() {
DATABASE_HELPER.getDataSource().destroy(); DATABASE_HELPER.getDataSource().destroy();
} }

View File

@ -63,7 +63,7 @@ public class BasicLookupStrategyWithAclClassTypeTests extends AbstractBasicLooku
} }
@AfterClass @AfterClass
public static void dropDatabase() throws Exception { public static void dropDatabase() {
DATABASE_HELPER.getDataSource().destroy(); DATABASE_HELPER.getDataSource().destroy();
} }

View File

@ -86,14 +86,14 @@ public class EhCacheBasedAclCacheTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorRejectsNullParameters() throws Exception { public void constructorRejectsNullParameters() {
new EhCacheBasedAclCache(null, new DefaultPermissionGrantingStrategy( new EhCacheBasedAclCache(null, new DefaultPermissionGrantingStrategy(
new ConsoleAuditLogger()), new AclAuthorizationStrategyImpl( new ConsoleAuditLogger()), new AclAuthorizationStrategyImpl(
new SimpleGrantedAuthority("ROLE_USER"))); new SimpleGrantedAuthority("ROLE_USER")));
} }
@Test @Test
public void methodsRejectNullParameters() throws Exception { public void methodsRejectNullParameters() {
try { try {
Serializable id = null; Serializable id = null;
myCache.evictFromCache(id); myCache.evictFromCache(id);
@ -162,14 +162,14 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void clearCache() throws Exception { public void clearCache() {
myCache.clearCache(); myCache.clearCache();
verify(cache).removeAll(); verify(cache).removeAll();
} }
@Test @Test
public void putInCache() throws Exception { public void putInCache() {
myCache.putInCache(acl); myCache.putInCache(acl);
verify(cache, times(2)).put(element.capture()); verify(cache, times(2)).put(element.capture());
@ -181,7 +181,7 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void putInCacheAclWithParent() throws Exception { public void putInCacheAclWithParent() {
Authentication auth = new TestingAuthenticationToken("user", "password", Authentication auth = new TestingAuthenticationToken("user", "password",
"ROLE_GENERAL"); "ROLE_GENERAL");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -216,14 +216,14 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void getFromCacheSerializable() throws Exception { public void getFromCacheSerializable() {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl);
} }
@Test @Test
public void getFromCacheSerializablePopulatesTransient() throws Exception { public void getFromCacheSerializablePopulatesTransient() {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
myCache.putInCache(acl); myCache.putInCache(acl);
@ -240,14 +240,14 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void getFromCacheObjectIdentity() throws Exception { public void getFromCacheObjectIdentity() {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl);
} }
@Test @Test
public void getFromCacheObjectIdentityPopulatesTransient() throws Exception { public void getFromCacheObjectIdentityPopulatesTransient() {
when(cache.get(acl.getObjectIdentity())) when(cache.get(acl.getObjectIdentity()))
.thenReturn(new Element(acl.getId(), acl)); .thenReturn(new Element(acl.getId(), acl));
@ -265,7 +265,7 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void evictCacheSerializable() throws Exception { public void evictCacheSerializable() {
when(cache.get(acl.getObjectIdentity())) when(cache.get(acl.getObjectIdentity()))
.thenReturn(new Element(acl.getId(), acl)); .thenReturn(new Element(acl.getId(), acl));
@ -276,7 +276,7 @@ public class EhCacheBasedAclCacheTests {
} }
@Test @Test
public void evictCacheObjectIdentity() throws Exception { public void evictCacheObjectIdentity() {
when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl));
myCache.evictFromCache(acl.getId()); myCache.evictFromCache(acl.getId());

View File

@ -132,7 +132,7 @@ public class JdbcMutableAclServiceTests extends
} }
@AfterTransaction @AfterTransaction
public void clearContextAndData() throws Exception { public void clearContextAndData() {
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
jdbcTemplate.execute("drop table acl_entry"); jdbcTemplate.execute("drop table acl_entry");
jdbcTemplate.execute("drop table acl_object_identity"); jdbcTemplate.execute("drop table acl_object_identity");
@ -285,7 +285,7 @@ public class JdbcMutableAclServiceTests extends
*/ */
@Test @Test
@Transactional @Transactional
public void deleteAclAlsoDeletesChildren() throws Exception { public void deleteAclAlsoDeletesChildren() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
jdbcMutableAclService.createAcl(getTopParentOid()); jdbcMutableAclService.createAcl(getTopParentOid());
@ -323,7 +323,7 @@ public class JdbcMutableAclServiceTests extends
} }
@Test @Test
public void constructorRejectsNullParameters() throws Exception { public void constructorRejectsNullParameters() {
try { try {
new JdbcMutableAclService(null, lookupStrategy, aclCache); new JdbcMutableAclService(null, lookupStrategy, aclCache);
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
@ -347,7 +347,7 @@ public class JdbcMutableAclServiceTests extends
} }
@Test @Test
public void createAclRejectsNullParameter() throws Exception { public void createAclRejectsNullParameter() {
try { try {
jdbcMutableAclService.createAcl(null); jdbcMutableAclService.createAcl(null);
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
@ -358,7 +358,7 @@ public class JdbcMutableAclServiceTests extends
@Test @Test
@Transactional @Transactional
public void createAclForADuplicateDomainObject() throws Exception { public void createAclForADuplicateDomainObject() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
ObjectIdentity duplicateOid = new ObjectIdentityImpl(TARGET_CLASS, ObjectIdentity duplicateOid = new ObjectIdentityImpl(TARGET_CLASS,
100L); 100L);
@ -374,7 +374,7 @@ public class JdbcMutableAclServiceTests extends
@Test @Test
@Transactional @Transactional
public void deleteAclRejectsNullParameters() throws Exception { public void deleteAclRejectsNullParameters() {
try { try {
jdbcMutableAclService.deleteAcl(null, true); jdbcMutableAclService.deleteAcl(null, true);
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
@ -385,7 +385,7 @@ public class JdbcMutableAclServiceTests extends
@Test @Test
@Transactional @Transactional
public void deleteAclWithChildrenThrowsException() throws Exception { public void deleteAclWithChildrenThrowsException() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
MutableAcl parent = jdbcMutableAclService.createAcl(getTopParentOid()); MutableAcl parent = jdbcMutableAclService.createAcl(getTopParentOid());
MutableAcl child = jdbcMutableAclService.createAcl(getMiddleParentOid()); MutableAcl child = jdbcMutableAclService.createAcl(getMiddleParentOid());
@ -411,7 +411,7 @@ public class JdbcMutableAclServiceTests extends
@Test @Test
@Transactional @Transactional
public void deleteAclRemovesRowsFromDatabase() throws Exception { public void deleteAclRemovesRowsFromDatabase() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
MutableAcl child = jdbcMutableAclService.createAcl(getChildOid()); MutableAcl child = jdbcMutableAclService.createAcl(getChildOid());
child.insertAce(0, BasePermission.DELETE, new PrincipalSid(auth), false); child.insertAce(0, BasePermission.DELETE, new PrincipalSid(auth), false);
@ -434,7 +434,7 @@ public class JdbcMutableAclServiceTests extends
/** SEC-1107 */ /** SEC-1107 */
@Test @Test
@Transactional @Transactional
public void identityWithIntegerIdIsSupportedByCreateAcl() throws Exception { public void identityWithIntegerIdIsSupportedByCreateAcl() {
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);
ObjectIdentity oid = new ObjectIdentityImpl(TARGET_CLASS, 101); ObjectIdentity oid = new ObjectIdentityImpl(TARGET_CLASS, 101);
jdbcMutableAclService.createAcl(oid); jdbcMutableAclService.createAcl(oid);
@ -448,7 +448,7 @@ public class JdbcMutableAclServiceTests extends
*/ */
@Test @Test
@Transactional @Transactional
public void childrenAreClearedFromCacheWhenParentIsUpdated() throws Exception { public void childrenAreClearedFromCacheWhenParentIsUpdated() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", Authentication auth = new TestingAuthenticationToken("ben", "ignored",
"ROLE_ADMINISTRATOR"); "ROLE_ADMINISTRATOR");
auth.setAuthenticated(true); auth.setAuthenticated(true);
@ -486,7 +486,7 @@ public class JdbcMutableAclServiceTests extends
*/ */
@Test @Test
@Transactional @Transactional
public void childrenAreClearedFromCacheWhenParentisUpdated2() throws Exception { public void childrenAreClearedFromCacheWhenParentisUpdated2() {
Authentication auth = new TestingAuthenticationToken("system", "secret", Authentication auth = new TestingAuthenticationToken("system", "secret",
"ROLE_IGNORED"); "ROLE_IGNORED");
SecurityContextHolder.getContext().setAuthentication(auth); SecurityContextHolder.getContext().setAuthentication(auth);

View File

@ -70,7 +70,7 @@ public class JdbcMutableAclServiceTestsWithAclClassId extends JdbcMutableAclServ
@Test @Test
@Transactional @Transactional
public void identityWithUuidIdIsSupportedByCreateAcl() throws Exception { public void identityWithUuidIdIsSupportedByCreateAcl() {
SecurityContextHolder.getContext().setAuthentication(getAuth()); SecurityContextHolder.getContext().setAuthentication(getAuth());
UUID id = UUID.randomUUID(); UUID id = UUID.randomUUID();

View File

@ -65,13 +65,13 @@ public class SpringCacheBasedAclCacheTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorRejectsNullParameters() throws Exception { public void constructorRejectsNullParameters() {
new SpringCacheBasedAclCache(null, null, null); new SpringCacheBasedAclCache(null, null, null);
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Test @Test
public void cacheOperationsAclWithoutParent() throws Exception { public void cacheOperationsAclWithoutParent() {
Cache cache = getCache(); Cache cache = getCache();
Map realCache = (Map) cache.getNativeCache(); Map realCache = (Map) cache.getNativeCache();
ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100L); ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100L);

View File

@ -46,7 +46,7 @@ public class SidRetrievalStrategyTests {
// ======================================================================================================== // ========================================================================================================
@Test @Test
public void correctSidsAreRetrieved() throws Exception { public void correctSidsAreRetrieved() {
SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl(); SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl();
List<Sid> sids = retrStrategy.getSids(authentication); List<Sid> sids = retrStrategy.getSids(authentication);
@ -66,7 +66,7 @@ public class SidRetrievalStrategyTests {
} }
@Test @Test
public void roleHierarchyIsUsedWhenSet() throws Exception { public void roleHierarchyIsUsedWhenSet() {
RoleHierarchy rh = mock(RoleHierarchy.class); RoleHierarchy rh = mock(RoleHierarchy.class);
List rhAuthorities = AuthorityUtils.createAuthorityList("D"); List rhAuthorities = AuthorityUtils.createAuthorityList("D");
when(rh.getReachableGrantedAuthorities(anyCollection())) when(rh.getReachableGrantedAuthorities(anyCollection()))

View File

@ -32,7 +32,7 @@ public class SidTests {
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
@Test @Test
public void testPrincipalSidConstructorsRequiredFields() throws Exception { public void testPrincipalSidConstructorsRequiredFields() {
// Check one String-argument constructor // Check one String-argument constructor
try { try {
String string = null; String string = null;
@ -77,7 +77,7 @@ public class SidTests {
} }
@Test @Test
public void testGrantedAuthoritySidConstructorsRequiredFields() throws Exception { public void testGrantedAuthoritySidConstructorsRequiredFields() {
// Check one String-argument constructor // Check one String-argument constructor
try { try {
String string = null; String string = null;
@ -134,7 +134,7 @@ public class SidTests {
} }
@Test @Test
public void testPrincipalSidEquals() throws Exception { public void testPrincipalSidEquals() {
Authentication authentication = new TestingAuthenticationToken("johndoe", Authentication authentication = new TestingAuthenticationToken("johndoe",
"password"); "password");
Sid principalSid = new PrincipalSid(authentication); Sid principalSid = new PrincipalSid(authentication);
@ -152,7 +152,7 @@ public class SidTests {
} }
@Test @Test
public void testGrantedAuthoritySidEquals() throws Exception { public void testGrantedAuthoritySidEquals() {
GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST");
Sid gaSid = new GrantedAuthoritySid(ga); Sid gaSid = new GrantedAuthoritySid(ga);
@ -169,7 +169,7 @@ public class SidTests {
} }
@Test @Test
public void testPrincipalSidHashCode() throws Exception { public void testPrincipalSidHashCode() {
Authentication authentication = new TestingAuthenticationToken("johndoe", Authentication authentication = new TestingAuthenticationToken("johndoe",
"password"); "password");
Sid principalSid = new PrincipalSid(authentication); Sid principalSid = new PrincipalSid(authentication);
@ -184,7 +184,7 @@ public class SidTests {
} }
@Test @Test
public void testGrantedAuthoritySidHashCode() throws Exception { public void testGrantedAuthoritySidHashCode() {
GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST"); GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_TEST");
Sid gaSid = new GrantedAuthoritySid(ga); Sid gaSid = new GrantedAuthoritySid(ga);
@ -198,7 +198,7 @@ public class SidTests {
} }
@Test @Test
public void testGetters() throws Exception { public void testGetters() {
Authentication authentication = new TestingAuthenticationToken("johndoe", Authentication authentication = new TestingAuthenticationToken("johndoe",
"password"); "password");
PrincipalSid principalSid = new PrincipalSid(authentication); PrincipalSid principalSid = new PrincipalSid(authentication);

View File

@ -81,7 +81,7 @@ public aspect AnnotationSecurityAspect implements InitializingBean {
this.securityInterceptor = securityInterceptor; this.securityInterceptor = securityInterceptor;
} }
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
if (this.securityInterceptor == null) { if (this.securityInterceptor == null) {
throw new IllegalArgumentException("securityInterceptor required"); throw new IllegalArgumentException("securityInterceptor required");
} }

View File

@ -67,7 +67,7 @@ public class AnnotationSecurityAspectTests {
private PrePostSecured prePostSecured = new PrePostSecured(); private PrePostSecured prePostSecured = new PrePostSecured();
@Before @Before
public final void setUp() throws Exception { public final void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
interceptor = new AspectJMethodSecurityInterceptor(); interceptor = new AspectJMethodSecurityInterceptor();
AccessDecisionVoter[] voters = new AccessDecisionVoter[] { AccessDecisionVoter[] voters = new AccessDecisionVoter[] {
@ -90,17 +90,17 @@ public class AnnotationSecurityAspectTests {
} }
@Test @Test
public void securedInterfaceMethodAllowsAllAccess() throws Exception { public void securedInterfaceMethodAllowsAllAccess() {
secured.securedMethod(); secured.securedMethod();
} }
@Test(expected = AuthenticationCredentialsNotFoundException.class) @Test(expected = AuthenticationCredentialsNotFoundException.class)
public void securedClassMethodDeniesUnauthenticatedAccess() throws Exception { public void securedClassMethodDeniesUnauthenticatedAccess() {
secured.securedClassMethod(); secured.securedClassMethod();
} }
@Test @Test
public void securedClassMethodAllowsAccessToRoleA() throws Exception { public void securedClassMethodAllowsAccessToRoleA() {
SecurityContextHolder.getContext().setAuthentication(anne); SecurityContextHolder.getContext().setAuthentication(anne);
secured.securedClassMethod(); secured.securedClassMethod();
} }
@ -119,28 +119,28 @@ public class AnnotationSecurityAspectTests {
} }
@Test(expected = AccessDeniedException.class) @Test(expected = AccessDeniedException.class)
public void protectedMethodIsIntercepted() throws Exception { public void protectedMethodIsIntercepted() {
SecurityContextHolder.getContext().setAuthentication(anne); SecurityContextHolder.getContext().setAuthentication(anne);
secured.protectedMethod(); secured.protectedMethod();
} }
@Test @Test
public void overriddenProtectedMethodIsNotIntercepted() throws Exception { public void overriddenProtectedMethodIsNotIntercepted() {
// AspectJ doesn't inherit annotations // AspectJ doesn't inherit annotations
securedSub.protectedMethod(); securedSub.protectedMethod();
} }
// SEC-1262 // SEC-1262
@Test(expected = AccessDeniedException.class) @Test(expected = AccessDeniedException.class)
public void denyAllPreAuthorizeDeniesAccess() throws Exception { public void denyAllPreAuthorizeDeniesAccess() {
configureForElAnnotations(); configureForElAnnotations();
SecurityContextHolder.getContext().setAuthentication(anne); SecurityContextHolder.getContext().setAuthentication(anne);
prePostSecured.denyAllMethod(); prePostSecured.denyAllMethod();
} }
@Test @Test
public void postFilterIsApplied() throws Exception { public void postFilterIsApplied() {
configureForElAnnotations(); configureForElAnnotations();
SecurityContextHolder.getContext().setAuthentication(anne); SecurityContextHolder.getContext().setAuthentication(anne);
List<String> objects = prePostSecured.postFilterMethod(); List<String> objects = prePostSecured.postFilterMethod();

View File

@ -50,7 +50,7 @@ public class ServiceProperties implements InitializingBean {
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
Assert.hasLength(this.service, "service cannot be empty."); Assert.hasLength(this.service, "service cannot be empty.");
Assert.hasLength(this.artifactParameter, "artifactParameter cannot be empty."); Assert.hasLength(this.artifactParameter, "artifactParameter cannot be empty.");
Assert.hasLength(this.serviceParameter, "serviceParameter cannot be empty."); Assert.hasLength(this.serviceParameter, "serviceParameter cannot be empty.");

View File

@ -77,7 +77,7 @@ public class CasAuthenticationProvider implements AuthenticationProvider,
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
Assert.notNull(this.authenticationUserDetailsService, Assert.notNull(this.authenticationUserDetailsService,
"An authenticationUserDetailsService must be set"); "An authenticationUserDetailsService must be set");
Assert.notNull(this.ticketValidator, "A ticketValidator must be set"); Assert.notNull(this.ticketValidator, "A ticketValidator must be set");

View File

@ -44,7 +44,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
Assert.notNull(cache, "cache mandatory"); Assert.notNull(cache, "cache mandatory");
} }

View File

@ -42,7 +42,7 @@ public class SpringCacheBasedTicketCache implements StatelessTicketCache {
// ~ Constructors // ~ Constructors
// =================================================================================================== // ===================================================================================================
public SpringCacheBasedTicketCache(Cache cache) throws Exception { public SpringCacheBasedTicketCache(Cache cache) {
Assert.notNull(cache, "cache mandatory"); Assert.notNull(cache, "cache mandatory");
this.cache = cache; this.cache = cache;
} }

View File

@ -65,7 +65,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint,
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
Assert.hasLength(this.loginUrl, "loginUrl must be specified"); Assert.hasLength(this.loginUrl, "loginUrl must be specified");
Assert.notNull(this.serviceProperties, "serviceProperties must be specified"); Assert.notNull(this.serviceProperties, "serviceProperties must be specified");
Assert.notNull(this.serviceProperties.getService(), Assert.notNull(this.serviceProperties.getService(),
@ -74,8 +74,7 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint,
public final void commence(final HttpServletRequest servletRequest, public final void commence(final HttpServletRequest servletRequest,
final HttpServletResponse response, final HttpServletResponse response,
final AuthenticationException authenticationException) throws IOException, final AuthenticationException authenticationException) throws IOException {
ServletException {
final String urlEncodedService = createServiceUrl(servletRequest, response); final String urlEncodedService = createServiceUrl(servletRequest, response);
final String redirectUrl = createRedirectUrl(urlEncodedService); final String redirectUrl = createRedirectUrl(urlEncodedService);

View File

@ -418,8 +418,7 @@ public class CasAuthenticationProviderTests {
this.returnTicket = returnTicket; this.returnTicket = returnTicket;
} }
public Assertion validate(final String ticket, final String service) public Assertion validate(final String ticket, final String service) {
throws TicketValidationException {
if (returnTicket) { if (returnTicket) {
return new AssertionImpl("rod"); return new AssertionImpl("rod");
} }

View File

@ -128,7 +128,7 @@ public class CasAuthenticationTokenMixinTests {
} }
@Test @Test
public void deserializeCasAuthenticationTest() throws IOException, JSONException { public void deserializeCasAuthenticationTest() throws IOException {
CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_JSON, CasAuthenticationToken.class); CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_JSON, CasAuthenticationToken.class);
assertThat(token).isNotNull(); assertThat(token).isNotNull();
assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class); assertThat(token.getPrincipal()).isNotNull().isInstanceOf(User.class);

View File

@ -59,7 +59,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void beanClassNamesAreCorrect() throws Exception { public void beanClassNamesAreCorrect() {
assertThat(FilterBasedLdapUserSearch.class.getName()).isEqualTo(LDAP_SEARCH_CLASS); assertThat(FilterBasedLdapUserSearch.class.getName()).isEqualTo(LDAP_SEARCH_CLASS);
assertThat(PersonContextMapper.class.getName()).isEqualTo(PERSON_MAPPER_CLASS); assertThat(PersonContextMapper.class.getName()).isEqualTo(PERSON_MAPPER_CLASS);
assertThat(InetOrgPersonContextMapper.class.getName()).isEqualTo(INET_ORG_PERSON_MAPPER_CLASS); assertThat(InetOrgPersonContextMapper.class.getName()).isEqualTo(INET_ORG_PERSON_MAPPER_CLASS);
@ -69,12 +69,12 @@ public class LdapUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void minimalConfigurationIsParsedOk() throws Exception { public void minimalConfigurationIsParsedOk() {
setContext("<ldap-user-service user-search-filter='(uid={0})' /><ldap-server ldif='classpath:test-server.ldif' url='ldap://127.0.0.1:343/dc=springframework,dc=org' />"); setContext("<ldap-user-service user-search-filter='(uid={0})' /><ldap-server ldif='classpath:test-server.ldif' url='ldap://127.0.0.1:343/dc=springframework,dc=org' />");
} }
@Test @Test
public void userServiceReturnsExpectedData() throws Exception { public void userServiceReturnsExpectedData() {
setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>"); setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
@ -86,7 +86,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void differentUserSearchBaseWorksAsExpected() throws Exception { public void differentUserSearchBaseWorksAsExpected() {
setContext("<ldap-user-service id='ldapUDS' " setContext("<ldap-user-service id='ldapUDS' "
+ " user-search-base='ou=otherpeople' " + " user-search-base='ou=otherpeople' "
+ " user-search-filter='(cn={0})' " + " user-search-filter='(cn={0})' "
@ -99,7 +99,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void rolePrefixIsSupported() throws Exception { public void rolePrefixIsSupported() {
setContext("<ldap-user-service id='ldapUDS' " setContext("<ldap-user-service id='ldapUDS' "
+ " user-search-filter='(uid={0})' " + " user-search-filter='(uid={0})' "
+ " group-search-filter='member={0}' role-prefix='PREFIX_'/>" + " group-search-filter='member={0}' role-prefix='PREFIX_'/>"
@ -117,7 +117,7 @@ public class LdapUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void differentGroupRoleAttributeWorksAsExpected() throws Exception { public void differentGroupRoleAttributeWorksAsExpected() {
setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-role-attribute='ou' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>"); setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-role-attribute='ou' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");

View File

@ -183,10 +183,9 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* {@link SecurityConfigurer#init(SecurityBuilder)} immediately if necessary. * {@link SecurityConfigurer#init(SecurityBuilder)} immediately if necessary.
* *
* @param configurer the {@link SecurityConfigurer} to add * @param configurer the {@link SecurityConfigurer} to add
* @throws Exception if an error occurs
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <C extends SecurityConfigurer<O, B>> void add(C configurer) throws Exception { private <C extends SecurityConfigurer<O, B>> void add(C configurer) {
Assert.notNull(configurer, "configurer cannot be null"); Assert.notNull(configurer, "configurer cannot be null");
Class<? extends SecurityConfigurer<O, B>> clazz = (Class<? extends SecurityConfigurer<O, B>>) configurer Class<? extends SecurityConfigurer<O, B>> clazz = (Class<? extends SecurityConfigurer<O, B>>) configurer
@ -344,7 +343,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
* method. Subclasses may override this method to hook into the lifecycle without * method. Subclasses may override this method to hook into the lifecycle without
* using a {@link SecurityConfigurer}. * using a {@link SecurityConfigurer}.
*/ */
protected void beforeInit() throws Exception { protected void beforeInit() {
} }
/** /**

View File

@ -228,7 +228,7 @@ public class AuthenticationManagerBuilder
} }
@Override @Override
protected ProviderManager performBuild() throws Exception { protected ProviderManager performBuild() {
if (!isConfigured()) { if (!isConfigured()) {
logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null."); logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
return null; return null;

View File

@ -128,7 +128,7 @@ public class AuthenticationConfiguration {
@Autowired(required = false) @Autowired(required = false)
public void setGlobalAuthenticationConfigurers( public void setGlobalAuthenticationConfigurers(
List<GlobalAuthenticationConfigurerAdapter> configurers) throws Exception { List<GlobalAuthenticationConfigurerAdapter> configurers) {
configurers.sort(AnnotationAwareOrderComparator.INSTANCE); configurers.sort(AnnotationAwareOrderComparator.INSTANCE);
this.globalAuthConfigurers = configurers; this.globalAuthConfigurers = configurers;
} }

View File

@ -55,7 +55,7 @@ class InitializeAuthenticationProviderBeanManagerConfigurer
class InitializeUserDetailsManagerConfigurer class InitializeUserDetailsManagerConfigurer
extends GlobalAuthenticationConfigurerAdapter { extends GlobalAuthenticationConfigurerAdapter {
@Override @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(AuthenticationManagerBuilder auth) {
if (auth.isConfigured()) { if (auth.isConfigured()) {
return; return;
} }

View File

@ -64,10 +64,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* *
* @param dataSource the {@link DataSource} to be used. Cannot be null. * @param dataSource the {@link DataSource} to be used. Cannot be null.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations * @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> dataSource(DataSource dataSource) public JdbcUserDetailsManagerConfigurer<B> dataSource(DataSource dataSource) {
throws Exception {
this.dataSource = dataSource; this.dataSource = dataSource;
getUserDetailsService().setDataSource(dataSource); getUserDetailsService().setDataSource(dataSource);
return this; return this;
@ -83,10 +81,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* is enabled by username. Must contain a single parameter for the username. * is enabled by username. Must contain a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional * @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations * customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(String query) public JdbcUserDetailsManagerConfigurer<B> usersByUsernameQuery(String query) {
throws Exception {
getUserDetailsService().setUsersByUsernameQuery(query); getUserDetailsService().setUsersByUsernameQuery(query);
return this; return this;
} }
@ -103,10 +99,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* Must contain a single parameter for the username. * Must contain a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional * @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations * customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(String query) public JdbcUserDetailsManagerConfigurer<B> authoritiesByUsernameQuery(String query) {
throws Exception {
getUserDetailsService().setAuthoritiesByUsernameQuery(query); getUserDetailsService().setAuthoritiesByUsernameQuery(query);
return this; return this;
} }
@ -127,10 +121,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* a single parameter for the username. * a single parameter for the username.
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional * @return The {@link JdbcUserDetailsManagerConfigurer} used for additional
* customizations * customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(String query) public JdbcUserDetailsManagerConfigurer<B> groupAuthoritiesByUsername(String query) {
throws Exception {
JdbcUserDetailsManager userDetailsService = getUserDetailsService(); JdbcUserDetailsManager userDetailsService = getUserDetailsService();
userDetailsService.setEnableGroups(true); userDetailsService.setEnableGroups(true);
userDetailsService.setGroupAuthoritiesByUsernameQuery(query); userDetailsService.setGroupAuthoritiesByUsernameQuery(query);
@ -143,10 +135,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* *
* @param rolePrefix * @param rolePrefix
* @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations * @return The {@link JdbcUserDetailsManagerConfigurer} used for additional customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> rolePrefix(String rolePrefix) public JdbcUserDetailsManagerConfigurer<B> rolePrefix(String rolePrefix) {
throws Exception {
getUserDetailsService().setRolePrefix(rolePrefix); getUserDetailsService().setRolePrefix(rolePrefix);
return this; return this;
} }
@ -156,10 +146,8 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
* *
* @param userCache the {@link UserCache} to use * @param userCache the {@link UserCache} to use
* @return the {@link JdbcUserDetailsManagerConfigurer} for further customizations * @return the {@link JdbcUserDetailsManagerConfigurer} for further customizations
* @throws Exception
*/ */
public JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache) public JdbcUserDetailsManagerConfigurer<B> userCache(UserCache userCache) {
throws Exception {
getUserDetailsService().setUserCache(userCache); getUserDetailsService().setUserCache(userCache);
return this; return this;
} }

View File

@ -97,7 +97,7 @@ final class AutowireBeanFactoryObjectPostProcessor
* *
* @see org.springframework.beans.factory.DisposableBean#destroy() * @see org.springframework.beans.factory.DisposableBean#destroy()
*/ */
public void destroy() throws Exception { public void destroy() {
for (DisposableBean disposable : this.disposableBeans) { for (DisposableBean disposable : this.disposableBeans) {
try { try {
disposable.destroy(); disposable.destroy();

View File

@ -46,7 +46,7 @@ class ReactiveMethodSecurityConfiguration implements ImportAware {
@Bean @Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) throws Exception { public MethodSecurityMetadataSourceAdvisor methodSecurityInterceptor(AbstractMethodSecurityMetadataSource source) {
MethodSecurityMetadataSourceAdvisor advisor = new MethodSecurityMetadataSourceAdvisor( MethodSecurityMetadataSourceAdvisor advisor = new MethodSecurityMetadataSourceAdvisor(
"securityMethodInterceptor", source, "methodMetadataSource"); "securityMethodInterceptor", source, "methodMetadataSource");
advisor.setOrder(advisorOrder); advisor.setOrder(advisorOrder);

View File

@ -2325,7 +2325,7 @@ public final class HttpSecurity extends
} }
@Override @Override
protected DefaultSecurityFilterChain performBuild() throws Exception { protected DefaultSecurityFilterChain performBuild() {
filters.sort(comparator); filters.sort(comparator);
return new DefaultSecurityFilterChain(requestMatcher, filters); return new DefaultSecurityFilterChain(requestMatcher, filters);
} }
@ -2633,9 +2633,8 @@ public final class HttpSecurity extends
* @param requestMatcherCustomizer the {@link Customizer} to provide more options for * @param requestMatcherCustomizer the {@link Customizer} to provide more options for
* the {@link RequestMatcherConfigurer} * the {@link RequestMatcherConfigurer}
* @return the {@link HttpSecurity} for further customizations * @return the {@link HttpSecurity} for further customizations
* @throws Exception
*/ */
public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) throws Exception { public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) {
requestMatcherCustomizer.customize(requestMatcherConfigurer); requestMatcherCustomizer.customize(requestMatcherConfigurer);
return HttpSecurity.this; return HttpSecurity.this;
} }

View File

@ -108,11 +108,10 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
* Creates the {@link WebInvocationPrivilegeEvaluator} that is necessary for the JSP * Creates the {@link WebInvocationPrivilegeEvaluator} that is necessary for the JSP
* tag support. * tag support.
* @return the {@link WebInvocationPrivilegeEvaluator} * @return the {@link WebInvocationPrivilegeEvaluator}
* @throws Exception
*/ */
@Bean @Bean
@DependsOn(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) @DependsOn(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
public WebInvocationPrivilegeEvaluator privilegeEvaluator() throws Exception { public WebInvocationPrivilegeEvaluator privilegeEvaluator() {
return webSecurity.getPrivilegeEvaluator(); return webSecurity.getPrivilegeEvaluator();
} }

View File

@ -331,7 +331,7 @@ public abstract class WebSecurityConfigurerAdapter implements
* Override this method to configure {@link WebSecurity}. For example, if you wish to * Override this method to configure {@link WebSecurity}. For example, if you wish to
* ignore certain requests. * ignore certain requests.
*/ */
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
} }
/** /**

View File

@ -145,7 +145,7 @@ public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>> extends
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
if (authenticationProvider == null) { if (authenticationProvider == null) {
authenticationProvider = new AnonymousAuthenticationProvider(getKey()); authenticationProvider = new AnonymousAuthenticationProvider(getKey());
} }
@ -158,7 +158,7 @@ public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>> extends
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
authenticationFilter.afterPropertiesSet(); authenticationFilter.afterPropertiesSet();
http.addFilter(authenticationFilter); http.addFilter(authenticationFilter);
} }

View File

@ -98,7 +98,7 @@ public final class ChannelSecurityConfigurer<H extends HttpSecurityBuilder<H>> e
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
ChannelDecisionManagerImpl channelDecisionManager = new ChannelDecisionManagerImpl(); ChannelDecisionManagerImpl channelDecisionManager = new ChannelDecisionManagerImpl();
channelDecisionManager.setChannelProcessors(getChannelProcessors(http)); channelDecisionManager.setChannelProcessors(getChannelProcessors(http));
channelDecisionManager = postProcess(channelDecisionManager); channelDecisionManager = postProcess(channelDecisionManager);

View File

@ -60,7 +60,7 @@ public class CorsConfigurer<H extends HttpSecurityBuilder<H>>
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
ApplicationContext context = http.getSharedObject(ApplicationContext.class); ApplicationContext context = http.getSharedObject(ApplicationContext.class);
CorsFilter corsFilter = getCorsFilter(context); CorsFilter corsFilter = getCorsFilter(context);

View File

@ -203,7 +203,7 @@ public final class CsrfConfigurer<H extends HttpSecurityBuilder<H>>
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
CsrfFilter filter = new CsrfFilter(this.csrfTokenRepository); CsrfFilter filter = new CsrfFilter(this.csrfTokenRepository);
RequestMatcher requireCsrfProtectionMatcher = getRequireCsrfProtectionMatcher(); RequestMatcher requireCsrfProtectionMatcher = getRequireCsrfProtectionMatcher();
if (requireCsrfProtectionMatcher != null) { if (requireCsrfProtectionMatcher != null) {

View File

@ -73,7 +73,7 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
private DefaultLogoutPageGeneratingFilter logoutPageGeneratingFilter = new DefaultLogoutPageGeneratingFilter(); private DefaultLogoutPageGeneratingFilter logoutPageGeneratingFilter = new DefaultLogoutPageGeneratingFilter();
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
Function<HttpServletRequest, Map<String, String>> hiddenInputs = request -> { Function<HttpServletRequest, Map<String, String>> hiddenInputs = request -> {
CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
if (token == null) { if (token == null) {
@ -89,7 +89,7 @@ public final class DefaultLoginPageConfigurer<H extends HttpSecurityBuilder<H>>
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void configure(H http) throws Exception { public void configure(H http) {
AuthenticationEntryPoint authenticationEntryPoint = null; AuthenticationEntryPoint authenticationEntryPoint = null;
ExceptionHandlingConfigurer<?> exceptionConf = http ExceptionHandlingConfigurer<?> exceptionConf = http
.getConfigurer(ExceptionHandlingConfigurer.class); .getConfigurer(ExceptionHandlingConfigurer.class);

View File

@ -188,7 +188,7 @@ public final class ExceptionHandlingConfigurer<H extends HttpSecurityBuilder<H>>
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http); AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http);
ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter( ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(
entryPoint, getRequestCache(http)); entryPoint, getRequestCache(http));

View File

@ -899,7 +899,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>> extends
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
HeaderWriterFilter headersFilter = createHeaderWriterFilter(); HeaderWriterFilter headersFilter = createHeaderWriterFilter();
http.addFilter(headersFilter); http.addFilter(headersFilter);
} }

View File

@ -91,10 +91,9 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
/** /**
* Creates a new instance * Creates a new instance
* @throws Exception
* @see HttpSecurity#httpBasic() * @see HttpSecurity#httpBasic()
*/ */
public HttpBasicConfigurer() throws Exception { public HttpBasicConfigurer() {
realmName(DEFAULT_REALM); realmName(DEFAULT_REALM);
LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>(); LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
@ -150,7 +149,7 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
} }
@Override @Override
public void init(B http) throws Exception { public void init(B http) {
registerDefaults(http); registerDefaults(http);
} }
@ -204,7 +203,7 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
} }
@Override @Override
public void configure(B http) throws Exception { public void configure(B http) {
AuthenticationManager authenticationManager = http AuthenticationManager authenticationManager = http
.getSharedObject(AuthenticationManager.class); .getSharedObject(AuthenticationManager.class);
BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter( BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter(

View File

@ -192,7 +192,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
* @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder) * @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder)
*/ */
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider(); PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider authenticationProvider
.setPreAuthenticatedUserDetailsService(getUserDetailsService()); .setPreAuthenticatedUserDetailsService(getUserDetailsService());
@ -206,7 +206,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
J2eePreAuthenticatedProcessingFilter filter = getFilter(http J2eePreAuthenticatedProcessingFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class)); .getSharedObject(AuthenticationManager.class));
http.addFilter(filter); http.addFilter(filter);

View File

@ -270,7 +270,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
if (permitAll) { if (permitAll) {
PermitAllSupport.permitAll(http, this.logoutSuccessUrl); PermitAllSupport.permitAll(http, this.logoutSuccessUrl);
PermitAllSupport.permitAll(http, this.getLogoutRequestMatcher(http)); PermitAllSupport.permitAll(http, this.getLogoutRequestMatcher(http));
@ -325,9 +325,8 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
* *
* @param http the builder to use * @param http the builder to use
* @return the {@link LogoutFilter} to use. * @return the {@link LogoutFilter} to use.
* @throws Exception
*/ */
private LogoutFilter createLogoutFilter(H http) throws Exception { private LogoutFilter createLogoutFilter(H http) {
logoutHandlers.add(contextLogoutHandler); logoutHandlers.add(contextLogoutHandler);
LogoutHandler[] handlers = logoutHandlers LogoutHandler[] handlers = logoutHandlers
.toArray(new LogoutHandler[0]); .toArray(new LogoutHandler[0]);

View File

@ -62,7 +62,7 @@ public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>> extend
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
http.setSharedObject(PortMapper.class, getPortMapper()); http.setSharedObject(PortMapper.class, getPortMapper());
} }

View File

@ -282,7 +282,7 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
RememberMeAuthenticationFilter rememberMeFilter = new RememberMeAuthenticationFilter( RememberMeAuthenticationFilter rememberMeFilter = new RememberMeAuthenticationFilter(
http.getSharedObject(AuthenticationManager.class), http.getSharedObject(AuthenticationManager.class),
this.rememberMeServices); this.rememberMeServices);
@ -373,10 +373,8 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
* @param http the {@link HttpSecurity} to lookup shared objects * @param http the {@link HttpSecurity} to lookup shared objects
* @param key the {@link #key(String)} * @param key the {@link #key(String)}
* @return the {@link RememberMeServices} to use * @return the {@link RememberMeServices} to use
* @throws Exception
*/ */
private AbstractRememberMeServices createRememberMeServices(H http, String key) private AbstractRememberMeServices createRememberMeServices(H http, String key) {
throws Exception {
return this.tokenRepository == null return this.tokenRepository == null
? createTokenBasedRememberMeServices(http, key) ? createTokenBasedRememberMeServices(http, key)
: createPersistentRememberMeServices(http, key); : createPersistentRememberMeServices(http, key);
@ -441,4 +439,4 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
} }
return this.key; return this.key;
} }
} }

View File

@ -95,12 +95,12 @@ public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>> exte
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
http.setSharedObject(RequestCache.class, getRequestCache(http)); http.setSharedObject(RequestCache.class, getRequestCache(http));
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
RequestCache requestCache = getRequestCache(http); RequestCache requestCache = getRequestCache(http);
RequestCacheAwareFilter requestCacheFilter = new RequestCacheAwareFilter( RequestCacheAwareFilter requestCacheFilter = new RequestCacheAwareFilter(
requestCache); requestCache);

View File

@ -82,7 +82,7 @@ public final class SecurityContextConfigurer<H extends HttpSecurityBuilder<H>> e
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void configure(H http) throws Exception { public void configure(H http) {
SecurityContextRepository securityContextRepository = http SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class); .getSharedObject(SecurityContextRepository.class);

View File

@ -75,7 +75,7 @@ public final class ServletApiConfigurer<H extends HttpSecurityBuilder<H>> extend
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void configure(H http) throws Exception { public void configure(H http) {
securityContextRequestFilter.setAuthenticationManager(http securityContextRequestFilter.setAuthenticationManager(http
.getSharedObject(AuthenticationManager.class)); .getSharedObject(AuthenticationManager.class));
ExceptionHandlingConfigurer<H> exceptionConf = http ExceptionHandlingConfigurer<H> exceptionConf = http

View File

@ -441,7 +441,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
SecurityContextRepository securityContextRepository = http SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class); .getSharedObject(SecurityContextRepository.class);
boolean stateless = isStateless(); boolean stateless = isStateless();
@ -478,7 +478,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
SecurityContextRepository securityContextRepository = http SecurityContextRepository securityContextRepository = http
.getSharedObject(SecurityContextRepository.class); .getSharedObject(SecurityContextRepository.class);
SessionManagementFilter sessionManagementFilter = new SessionManagementFilter( SessionManagementFilter sessionManagementFilter = new SessionManagementFilter(

View File

@ -171,7 +171,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
// @formatter:off // @formatter:off
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider(); PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http)); authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
@ -182,7 +182,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
// @formatter:on // @formatter:on
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
X509AuthenticationFilter filter = getFilter(http X509AuthenticationFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class)); .getSharedObject(AuthenticationManager.class));
http.addFilter(filter); http.addFilter(filter);

View File

@ -83,7 +83,7 @@ public final class ImplicitGrantConfigurer<B extends HttpSecurityBuilder<B>> ext
} }
@Override @Override
public void configure(B http) throws Exception { public void configure(B http) {
OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter( OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter(
OAuth2ClientConfigurerUtils.getClientRegistrationRepository(this.getBuilder()), this.getAuthorizationRequestBaseUri()); OAuth2ClientConfigurerUtils.getClientRegistrationRepository(this.getBuilder()), this.getAuthorizationRequestBaseUri());
http.addFilter(this.postProcess(authorizationRequestFilter)); http.addFilter(this.postProcess(authorizationRequestFilter));

View File

@ -142,10 +142,8 @@ public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>> exte
* @param authorizationCodeGrantCustomizer the {@link Customizer} to provide more options for * @param authorizationCodeGrantCustomizer the {@link Customizer} to provide more options for
* the {@link AuthorizationCodeGrantConfigurer} * the {@link AuthorizationCodeGrantConfigurer}
* @return the {@link OAuth2ClientConfigurer} for further customizations * @return the {@link OAuth2ClientConfigurer} for further customizations
* @throws Exception
*/ */
public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer) public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer) {
throws Exception {
authorizationCodeGrantCustomizer.customize(this.authorizationCodeGrantConfigurer); authorizationCodeGrantCustomizer.customize(this.authorizationCodeGrantConfigurer);
return this; return this;
} }
@ -270,12 +268,12 @@ public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>> exte
} }
@Override @Override
public void init(B builder) throws Exception { public void init(B builder) {
this.authorizationCodeGrantConfigurer.init(builder); this.authorizationCodeGrantConfigurer.init(builder);
} }
@Override @Override
public void configure(B builder) throws Exception { public void configure(B builder) {
this.authorizationCodeGrantConfigurer.configure(builder); this.authorizationCodeGrantConfigurer.configure(builder);
} }
} }

View File

@ -221,14 +221,14 @@ public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<
} }
@Override @Override
public void init(H http) throws Exception { public void init(H http) {
registerDefaultAccessDeniedHandler(http); registerDefaultAccessDeniedHandler(http);
registerDefaultEntryPoint(http); registerDefaultEntryPoint(http);
registerDefaultCsrfOverride(http); registerDefaultCsrfOverride(http);
} }
@Override @Override
public void configure(H http) throws Exception { public void configure(H http) {
BearerTokenResolver bearerTokenResolver = getBearerTokenResolver(); BearerTokenResolver bearerTokenResolver = getBearerTokenResolver();
this.requestMatcher.setBearerTokenResolver(bearerTokenResolver); this.requestMatcher.setBearerTokenResolver(bearerTokenResolver);

View File

@ -54,7 +54,7 @@ public class UserDetailsMapFactoryBean implements FactoryBean<Collection<UserDet
} }
@Override @Override
public Collection<UserDetails> getObject() throws Exception { public Collection<UserDetails> getObject() {
Collection<UserDetails> users = new ArrayList<>(this.userProperties.size()); Collection<UserDetails> users = new ArrayList<>(this.userProperties.size());
UserAttributeEditor editor = new UserAttributeEditor(); UserAttributeEditor editor = new UserAttributeEditor();

View File

@ -32,7 +32,7 @@ public class DataSourcePopulator implements InitializingBean {
JdbcTemplate template; JdbcTemplate template;
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() {
Assert.notNull(template, "dataSource required"); Assert.notNull(template, "dataSource required");
template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(500) NOT NULL,ENABLED BOOLEAN NOT NULL);"); template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(500) NOT NULL,ENABLED BOOLEAN NOT NULL);");

View File

@ -105,7 +105,7 @@ public class FilterChainProxyConfigTests {
} }
@Test @Test
public void pathWithNoMatchHasNoFilters() throws Exception { public void pathWithNoMatchHasNoFilters() {
FilterChainProxy filterChainProxy = appCtx.getBean( FilterChainProxy filterChainProxy = appCtx.getBean(
"newFilterChainProxyNoDefaultPath", FilterChainProxy.class); "newFilterChainProxyNoDefaultPath", FilterChainProxy.class);
assertThat(filterChainProxy.getFilters("/nomatch")).isNull(); assertThat(filterChainProxy.getFilters("/nomatch")).isNull();
@ -113,7 +113,7 @@ public class FilterChainProxyConfigTests {
// SEC-1235 // SEC-1235
@Test @Test
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() throws Exception { public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() {
FilterChainProxy fcp = appCtx.getBean("sec1235FilterChainProxy", FilterChainProxy fcp = appCtx.getBean("sec1235FilterChainProxy",
FilterChainProxy.class); FilterChainProxy.class);
@ -128,8 +128,7 @@ public class FilterChainProxyConfigTests {
.getRequestMatcher()).getPattern(); .getRequestMatcher()).getPattern();
} }
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy) private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy) {
throws Exception {
List<Filter> filters = filterChainProxy.getFilters("/foo/blah;x=1"); List<Filter> filters = filterChainProxy.getFilters("/foo/blah;x=1");
assertThat(filters).hasSize(1); assertThat(filters).hasSize(1);
assertThat(filters.get(0) instanceof SecurityContextHolderAwareRequestFilter).isTrue(); assertThat(filters.get(0) instanceof SecurityContextHolderAwareRequestFilter).isTrue();

View File

@ -72,7 +72,7 @@ public class SecurityNamespaceHandlerTests {
} }
@Test @Test
public void pre32SchemaAreNotSupported() throws Exception { public void pre32SchemaAreNotSupported() {
try { try {
new InMemoryXmlApplicationContext( new InMemoryXmlApplicationContext(
"<user-service id='us'>" "<user-service id='us'>"

View File

@ -27,7 +27,7 @@ class ConcereteSecurityConfigurerAdapter extends
private List<Object> list = new ArrayList<>(); private List<Object> list = new ArrayList<>();
@Override @Override
public void configure(SecurityBuilder<Object> builder) throws Exception { public void configure(SecurityBuilder<Object> builder) {
list = postProcess(list); list = postProcess(list);
} }

View File

@ -55,7 +55,7 @@ public class NamespaceAuthenticationProviderTests {
@EnableWebSecurity @EnableWebSecurity
static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter { static class AuthenticationProviderRefConfig extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) {
auth auth
.authenticationProvider(authenticationProvider()); .authenticationProvider(authenticationProvider());
} }

View File

@ -60,7 +60,7 @@ public class PasswordEncoderConfigurerTests {
// @formatter:on // @formatter:on
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
@Bean @Bean

View File

@ -203,7 +203,7 @@ public class AuthenticationConfigurationTests {
inits.add(getClass()); inits.add(getClass());
} }
public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(AuthenticationManagerBuilder auth) {
configs.add(getClass()); configs.add(getClass());
} }
} }
@ -256,7 +256,7 @@ public class AuthenticationConfigurationTests {
static class DefaultBootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter { static class DefaultBootGlobalAuthenticationConfigurerAdapter extends DefaultOrderGlobalAuthenticationConfigurerAdapter {
@Override @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception { public void configure(AuthenticationManagerBuilder auth) {
if (auth.isConfigured()) { if (auth.isConfigured()) {
return; return;
} }
@ -477,7 +477,7 @@ public class AuthenticationConfigurationTests {
} }
@Test @Test
public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() throws Exception { public void enableGlobalMethodSecurityWhenPreAuthorizeThenNoException() {
this.spring.register(UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire(); this.spring.register(UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
// no exception // no exception
@ -491,7 +491,7 @@ public class AuthenticationConfigurationTests {
} }
@Test @Test
public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() throws Exception { public void enableGlobalMethodSecurityWhenPreAuthorizeThenUsesMethodSecurityService() {
this.spring.register(ServicesConfig.class, UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire(); this.spring.register(ServicesConfig.class, UsesPreAuthorizeMethodSecurityConfig.class, AuthenticationManagerBeanConfig.class).autowire();
// no exception // no exception

View File

@ -154,7 +154,7 @@ public class AutowireBeanFactoryObjectPostProcessorTests {
@Test @Test
// SEC-2382 // SEC-2382
public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() throws Exception { public void autowireBeanFactoryWhenBeanNameAutoProxyCreatorThenWorks() {
this.spring.testConfigLocations("AutowireBeanFactoryObjectPostProcessorTests-aopconfig.xml").autowire(); this.spring.testConfigLocations("AutowireBeanFactoryObjectPostProcessorTests-aopconfig.xml").autowire();
MyAdvisedBean bean = this.spring.getContext().getBean(MyAdvisedBean.class); MyAdvisedBean bean = this.spring.getContext().getBean(MyAdvisedBean.class);

View File

@ -47,7 +47,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// @formatter:off // @formatter:off
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) {
auth auth
.authenticationProvider(authenticationProvider()); .authenticationProvider(authenticationProvider());
} }

View File

@ -251,7 +251,7 @@ public class GlobalMethodSecurityConfigurationTests {
} }
@Test @Test
public void multiPermissionEvaluatorConfig() throws Exception { public void multiPermissionEvaluatorConfig() {
this.spring.register(MultiPermissionEvaluatorConfig.class).autowire(); this.spring.register(MultiPermissionEvaluatorConfig.class).autowire();
// no exception // no exception

View File

@ -65,7 +65,7 @@ public class AbstractConfiguredSecurityBuilderTests {
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void getObjectWhenNotBuiltThenThrowIllegalStateException() throws Exception { public void getObjectWhenNotBuiltThenThrowIllegalStateException() {
this.builder.getObject(); this.builder.getObject();
} }
@ -141,7 +141,7 @@ public class AbstractConfiguredSecurityBuilderTests {
super(objectPostProcessor, allowConfigurersOfSameType); super(objectPostProcessor, allowConfigurersOfSameType);
} }
public Object performBuild() throws Exception { public Object performBuild() {
return "success"; return "success";
} }
} }

View File

@ -57,7 +57,7 @@ public class HttpSecurityHeadersTests {
MockMvc mockMvc; MockMvc mockMvc;
@Before @Before
public void setup() throws Exception { public void setup() {
mockMvc = MockMvcBuilders mockMvc = MockMvcBuilders
.webAppContextSetup(wac) .webAppContextSetup(wac)
.addFilters(springSecurityFilterChain) .addFilters(springSecurityFilterChain)
@ -86,7 +86,7 @@ public class HttpSecurityHeadersTests {
@EnableWebSecurity @EnableWebSecurity
static class WebSecurityConfig extends WebSecurityConfigurerAdapter { static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }

View File

@ -210,7 +210,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
public static class SampleWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { public static class SampleWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/resources/**"); .antMatchers("/resources/**");
@ -367,7 +367,7 @@ public class SampleWebSecurityConfigurerAdapterTests {
@Configuration @Configuration
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/resources/**"); .antMatchers("/resources/**");

View File

@ -79,7 +79,7 @@ public class WebSecurityConfigurerAdapterPowermockTests {
@EnableWebSecurity @EnableWebSecurity
static class Config extends WebSecurityConfigurerAdapter { static class Config extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }
@ -88,12 +88,12 @@ public class WebSecurityConfigurerAdapterPowermockTests {
boolean configure; boolean configure;
@Override @Override
public void init(HttpSecurity builder) throws Exception { public void init(HttpSecurity builder) {
this.init = true; this.init = true;
} }
@Override @Override
public void configure(HttpSecurity builder) throws Exception { public void configure(HttpSecurity builder) {
this.configure = true; this.configure = true;
} }
} }

View File

@ -110,7 +110,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }
@ -146,7 +146,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }
@ -237,7 +237,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Test @Test
public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() throws Exception { public void loadConfigWhenCustomContentNegotiationStrategyBeanThenOverridesDefault() {
OverrideContentNegotiationStrategySharedObjectConfig.CONTENT_NEGOTIATION_STRATEGY_BEAN = mock(ContentNegotiationStrategy.class); OverrideContentNegotiationStrategySharedObjectConfig.CONTENT_NEGOTIATION_STRATEGY_BEAN = mock(ContentNegotiationStrategy.class);
this.spring.register(OverrideContentNegotiationStrategySharedObjectConfig.class).autowire(); this.spring.register(OverrideContentNegotiationStrategySharedObjectConfig.class).autowire();
@ -267,7 +267,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Test @Test
public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() throws Exception { public void loadConfigWhenDefaultContentNegotiationStrategyThenHeaderContentNegotiationStrategy() {
this.spring.register(ContentNegotiationStrategyDefaultSharedObjectConfig.class).autowire(); this.spring.register(ContentNegotiationStrategyDefaultSharedObjectConfig.class).autowire();
ContentNegotiationStrategyDefaultSharedObjectConfig securityConfig = ContentNegotiationStrategyDefaultSharedObjectConfig securityConfig =
@ -289,7 +289,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Test @Test
public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() throws Exception { public void loadConfigWhenUserDetailsServiceHasCircularReferenceThenStillLoads() {
this.spring.register(RequiresUserDetailsServiceConfig.class, UserDetailsServiceConfig.class).autowire(); this.spring.register(RequiresUserDetailsServiceConfig.class, UserDetailsServiceConfig.class).autowire();
MyFilter myFilter = this.spring.getContext().getBean(MyFilter.class); MyFilter myFilter = this.spring.getContext().getBean(MyFilter.class);
@ -350,7 +350,7 @@ public class WebSecurityConfigurerAdapterTests {
// SEC-2274: WebSecurityConfigurer adds ApplicationContext as a shared object // SEC-2274: WebSecurityConfigurer adds ApplicationContext as a shared object
@Test @Test
public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() throws Exception { public void loadConfigWhenSharedObjectsCreatedThenApplicationContextAdded() {
this.spring.register(ApplicationContextSharedObjectConfig.class).autowire(); this.spring.register(ApplicationContextSharedObjectConfig.class).autowire();
ApplicationContextSharedObjectConfig securityConfig = ApplicationContextSharedObjectConfig securityConfig =
@ -372,7 +372,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Test @Test
public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() throws Exception { public void loadConfigWhenCustomAuthenticationTrustResolverBeanThenOverridesDefault() {
CustomTrustResolverConfig.AUTHENTICATION_TRUST_RESOLVER_BEAN = mock(AuthenticationTrustResolver.class); CustomTrustResolverConfig.AUTHENTICATION_TRUST_RESOLVER_BEAN = mock(AuthenticationTrustResolver.class);
this.spring.register(CustomTrustResolverConfig.class).autowire(); this.spring.register(CustomTrustResolverConfig.class).autowire();
@ -402,7 +402,7 @@ public class WebSecurityConfigurerAdapterTests {
} }
@Test @Test
public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() throws Exception { public void compareOrderWebSecurityConfigurerAdapterWhenLowestOrderToDefaultOrderThenGreaterThanZero() {
AnnotationAwareOrderComparator comparator = new AnnotationAwareOrderComparator(); AnnotationAwareOrderComparator comparator = new AnnotationAwareOrderComparator();
assertThat(comparator.compare( assertThat(comparator.compare(
new LowestPriorityWebSecurityConfig(), new LowestPriorityWebSecurityConfig(),

View File

@ -56,7 +56,7 @@ public class HttpConfigurationTests {
private MockMvc mockMvc; private MockMvc mockMvc;
@Test @Test
public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() throws Exception { public void configureWhenAddFilterUnregisteredThenThrowsBeanCreationException() {
Throwable thrown = catchThrowable(() -> this.spring.register(UnregisteredFilterConfig.class).autowire() ); Throwable thrown = catchThrowable(() -> this.spring.register(UnregisteredFilterConfig.class).autowire() );
assertThat(thrown).isInstanceOf(BeanCreationException.class); assertThat(thrown).isInstanceOf(BeanCreationException.class);
assertThat(thrown.getMessage()).contains("The Filter class " + UnregisteredFilter.class.getName() + assertThat(thrown.getMessage()).contains("The Filter class " + UnregisteredFilter.class.getName() +
@ -67,7 +67,7 @@ public class HttpConfigurationTests {
@EnableWebSecurity @EnableWebSecurity
static class UnregisteredFilterConfig extends WebSecurityConfigurerAdapter { static class UnregisteredFilterConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.addFilter(new UnregisteredFilter()); .addFilter(new UnregisteredFilter());
} }
@ -104,7 +104,7 @@ public class HttpConfigurationTests {
static class CasAuthenticationFilterConfig extends WebSecurityConfigurerAdapter { static class CasAuthenticationFilterConfig extends WebSecurityConfigurerAdapter {
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER; static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER;
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.addFilter(CAS_AUTHENTICATION_FILTER); .addFilter(CAS_AUTHENTICATION_FILTER);
} }

View File

@ -139,7 +139,7 @@ public class NamespaceHttpTests {
static AuthenticationManager AUTHENTICATION_MANAGER; static AuthenticationManager AUTHENTICATION_MANAGER;
@Override @Override
protected AuthenticationManager authenticationManager() throws Exception { protected AuthenticationManager authenticationManager() {
return AUTHENTICATION_MANAGER; return AUTHENTICATION_MANAGER;
} }
@ -298,7 +298,7 @@ public class NamespaceHttpTests {
@EnableWebSecurity @EnableWebSecurity
static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter { static class JaasApiProvisionConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.addFilter(new JaasApiIntegrationFilter()); .addFilter(new JaasApiIntegrationFilter());
} }
@ -327,7 +327,7 @@ public class NamespaceHttpTests {
} }
@Test // http@request-matcher-ref ant @Test // http@request-matcher-ref ant
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() throws Exception { public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() {
this.spring.register(RequestMatcherAntConfig.class).autowire(); this.spring.register(RequestMatcherAntConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@ -340,14 +340,14 @@ public class NamespaceHttpTests {
@EnableWebSecurity @EnableWebSecurity
static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter { static class RequestMatcherAntConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.antMatcher("/api/**"); .antMatcher("/api/**");
} }
} }
@Test // http@request-matcher-ref regex @Test // http@request-matcher-ref regex
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() throws Exception { public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() {
this.spring.register(RequestMatcherRegexConfig.class).autowire(); this.spring.register(RequestMatcherRegexConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@ -360,14 +360,14 @@ public class NamespaceHttpTests {
@EnableWebSecurity @EnableWebSecurity
static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter { static class RequestMatcherRegexConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.regexMatcher("/regex/.*"); .regexMatcher("/regex/.*");
} }
} }
@Test // http@request-matcher-ref @Test // http@request-matcher-ref
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() throws Exception { public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() {
this.spring.register(RequestMatcherRefConfig.class).autowire(); this.spring.register(RequestMatcherRefConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@ -380,7 +380,7 @@ public class NamespaceHttpTests {
@EnableWebSecurity @EnableWebSecurity
static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter { static class RequestMatcherRefConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.requestMatcher(new MyRequestMatcher()); .requestMatcher(new MyRequestMatcher());
} }
@ -393,7 +393,7 @@ public class NamespaceHttpTests {
} }
@Test // http@security=none @Test // http@security=none
public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() throws Exception { public void configureWhenIgnoredAntPatternsThenAntPathRequestMatcherUsedWithNoFilters() {
this.spring.register(SecurityNoneConfig.class).autowire(); this.spring.register(SecurityNoneConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@ -415,14 +415,14 @@ public class NamespaceHttpTests {
static class SecurityNoneConfig extends WebSecurityConfigurerAdapter { static class SecurityNoneConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/resources/**", "/public/**"); .antMatchers("/resources/**", "/public/**");
} }
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }
@ -510,7 +510,7 @@ public class NamespaceHttpTests {
} }
@Test // http@use-expressions=true @Test // http@use-expressions=true
public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() throws Exception { public void configureWhenUseExpressionsEnabledThenExpressionBasedSecurityMetadataSource() {
this.spring.register(UseExpressionsConfig.class).autowire(); this.spring.register(UseExpressionsConfig.class).autowire();
UseExpressionsConfig config = this.spring.getContext().getBean(UseExpressionsConfig.class); UseExpressionsConfig config = this.spring.getContext().getBean(UseExpressionsConfig.class);
@ -545,7 +545,7 @@ public class NamespaceHttpTests {
} }
@Test // http@use-expressions=false @Test // http@use-expressions=false
public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() throws Exception { public void configureWhenUseExpressionsDisabledThenDefaultSecurityMetadataSource() {
this.spring.register(DisableUseExpressionsConfig.class).autowire(); this.spring.register(DisableUseExpressionsConfig.class).autowire();
DisableUseExpressionsConfig config = this.spring.getContext().getBean(DisableUseExpressionsConfig.class); DisableUseExpressionsConfig config = this.spring.getContext().getBean(DisableUseExpressionsConfig.class);

View File

@ -104,7 +104,7 @@ public class WebSecurityTests {
@EnableWebMvc @EnableWebMvc
static class MvcMatcherConfig extends WebSecurityConfigurerAdapter { static class MvcMatcherConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
// @formatter:off // @formatter:off
web web
.ignoring() .ignoring()
@ -180,7 +180,7 @@ public class WebSecurityTests {
@EnableWebMvc @EnableWebMvc
static class MvcMatcherServletPathConfig extends WebSecurityConfigurerAdapter { static class MvcMatcherServletPathConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
// @formatter:off // @formatter:off
web web
.ignoring() .ignoring()

View File

@ -51,7 +51,7 @@ public class EnableWebSecurityTests {
private MockMvc mockMvc; private MockMvc mockMvc;
@Test @Test
public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() throws Exception { public void configureWhenOverrideAuthenticationManagerBeanThenAuthenticationManagerBeanRegistered() {
this.spring.register(SecurityConfig.class).autowire(); this.spring.register(SecurityConfig.class).autowire();
AuthenticationManager authenticationManager = this.spring.getContext().getBean(AuthenticationManager.class); AuthenticationManager authenticationManager = this.spring.getContext().getBean(AuthenticationManager.class);
@ -85,7 +85,7 @@ public class EnableWebSecurityTests {
} }
@Test @Test
public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() throws Exception { public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInherited() {
this.spring.register(ChildSecurityConfig.class).autowire(); this.spring.register(ChildSecurityConfig.class).autowire();
this.spring.getContext().getBean("springSecurityFilterChain", DebugFilter.class); this.spring.getContext().getBean("springSecurityFilterChain", DebugFilter.class);
} }
@ -110,7 +110,7 @@ public class EnableWebSecurityTests {
@EnableWebMvc @EnableWebMvc
static class AuthenticationPrincipalConfig extends WebSecurityConfigurerAdapter { static class AuthenticationPrincipalConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
@RestController @RestController

View File

@ -133,7 +133,7 @@ public class OAuth2ClientConfigurationTests {
static OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> ACCESS_TOKEN_RESPONSE_CLIENT; static OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> ACCESS_TOKEN_RESPONSE_CLIENT;
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
@RestController @RestController

View File

@ -39,7 +39,7 @@ public class Sec2515Tests {
// SEC-2515 // SEC-2515
@Test(expected = FatalBeanException.class) @Test(expected = FatalBeanException.class)
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() throws Exception { public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanThenThrowFatalBeanException() {
this.spring.register(StackOverflowSecurityConfig.class).autowire(); this.spring.register(StackOverflowSecurityConfig.class).autowire();
} }
@ -54,7 +54,7 @@ public class Sec2515Tests {
} }
@Test(expected = FatalBeanException.class) @Test(expected = FatalBeanException.class)
public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() throws Exception { public void loadConfigWhenAuthenticationManagerNotConfiguredAndRegisterBeanCustomNameThenThrowFatalBeanException() {
this.spring.register(CustomBeanNameStackOverflowSecurityConfig.class).autowire(); this.spring.register(CustomBeanNameStackOverflowSecurityConfig.class).autowire();
} }
@ -70,7 +70,7 @@ public class Sec2515Tests {
// SEC-2549 // SEC-2549
@Test @Test
public void loadConfigWhenChildClassLoaderSetThenContextLoads() throws Exception { public void loadConfigWhenChildClassLoaderSetThenContextLoads() {
CanLoadWithChildConfig.AUTHENTICATION_MANAGER = mock(AuthenticationManager.class); CanLoadWithChildConfig.AUTHENTICATION_MANAGER = mock(AuthenticationManager.class);
this.spring.register(CanLoadWithChildConfig.class); this.spring.register(CanLoadWithChildConfig.class);
AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) this.spring.getContext(); AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) this.spring.getContext();
@ -92,7 +92,7 @@ public class Sec2515Tests {
// SEC-2515 // SEC-2515
@Test @Test
public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() throws Exception { public void loadConfigWhenAuthenticationManagerConfiguredAndRegisterBeanThenContextLoads() {
this.spring.register(SecurityConfig.class).autowire(); this.spring.register(SecurityConfig.class).autowire();
} }

View File

@ -78,7 +78,7 @@ public class WebSecurityConfigurationTests {
private MockMvc mockMvc; private MockMvc mockMvc;
@Test @Test
public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() throws Exception { public void loadConfigWhenWebSecurityConfigurersHaveOrderThenFilterChainsOrdered() {
this.spring.register(SortedWebSecurityConfigurerAdaptersConfig.class).autowire(); this.spring.register(SortedWebSecurityConfigurerAdaptersConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
@ -116,7 +116,7 @@ public class WebSecurityConfigurationTests {
@Order(1) @Order(1)
static class WebConfigurer1 extends WebSecurityConfigurerAdapter { static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/ignore1", "/ignore2"); .antMatchers("/ignore1", "/ignore2");
@ -168,7 +168,7 @@ public class WebSecurityConfigurationTests {
} }
@Test @Test
public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() throws Exception { public void loadConfigWhenWebSecurityConfigurersHaveSameOrderThenThrowBeanCreationException() {
Throwable thrown = catchThrowable(() -> this.spring.register(DuplicateOrderConfig.class).autowire()); Throwable thrown = catchThrowable(() -> this.spring.register(DuplicateOrderConfig.class).autowire());
assertThat(thrown).isInstanceOf(BeanCreationException.class) assertThat(thrown).isInstanceOf(BeanCreationException.class)
@ -205,7 +205,7 @@ public class WebSecurityConfigurationTests {
} }
@Test @Test
public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() throws Exception { public void loadConfigWhenWebInvocationPrivilegeEvaluatorSetThenIsRegistered() {
PrivilegeEvaluatorConfigurerAdapterConfig.PRIVILEGE_EVALUATOR = mock(WebInvocationPrivilegeEvaluator.class); PrivilegeEvaluatorConfigurerAdapterConfig.PRIVILEGE_EVALUATOR = mock(WebInvocationPrivilegeEvaluator.class);
this.spring.register(PrivilegeEvaluatorConfigurerAdapterConfig.class).autowire(); this.spring.register(PrivilegeEvaluatorConfigurerAdapterConfig.class).autowire();
@ -219,13 +219,13 @@ public class WebSecurityConfigurationTests {
static WebInvocationPrivilegeEvaluator PRIVILEGE_EVALUATOR; static WebInvocationPrivilegeEvaluator PRIVILEGE_EVALUATOR;
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web.privilegeEvaluator(PRIVILEGE_EVALUATOR); web.privilegeEvaluator(PRIVILEGE_EVALUATOR);
} }
} }
@Test @Test
public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() throws Exception { public void loadConfigWhenSecurityExpressionHandlerSetThenIsRegistered() {
WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER = mock(SecurityExpressionHandler.class); WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER = mock(SecurityExpressionHandler.class);
when(WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER.getExpressionParser()).thenReturn(mock(ExpressionParser.class)); when(WebSecurityExpressionHandlerConfig.EXPRESSION_HANDLER.getExpressionParser()).thenReturn(mock(ExpressionParser.class));
@ -240,7 +240,7 @@ public class WebSecurityConfigurationTests {
static SecurityExpressionHandler EXPRESSION_HANDLER; static SecurityExpressionHandler EXPRESSION_HANDLER;
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web.expressionHandler(EXPRESSION_HANDLER); web.expressionHandler(EXPRESSION_HANDLER);
} }
@ -254,7 +254,7 @@ public class WebSecurityConfigurationTests {
} }
@Test @Test
public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() throws Exception { public void loadConfigWhenDefaultSecurityExpressionHandlerThenDefaultIsRegistered() {
this.spring.register(WebSecurityExpressionHandlerDefaultsConfig.class).autowire(); this.spring.register(WebSecurityExpressionHandlerDefaultsConfig.class).autowire();
assertThat(this.spring.getContext().getBean(SecurityExpressionHandler.class)) assertThat(this.spring.getContext().getBean(SecurityExpressionHandler.class))
@ -272,7 +272,7 @@ public class WebSecurityConfigurationTests {
} }
@Test @Test
public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() throws Exception { public void securityExpressionHandlerWhenPermissionEvaluatorBeanThenPermissionEvaluatorUsed() {
this.spring.register(WebSecurityExpressionHandlerPermissionEvaluatorBeanConfig.class).autowire(); this.spring.register(WebSecurityExpressionHandlerPermissionEvaluatorBeanConfig.class).autowire();
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "notused"); TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "notused");
FilterInvocation invocation = new FilterInvocation(new MockHttpServletRequest("GET", ""), new MockHttpServletResponse(), new MockFilterChain()); FilterInvocation invocation = new FilterInvocation(new MockHttpServletRequest("GET", ""), new MockHttpServletResponse(), new MockFilterChain());
@ -308,7 +308,7 @@ public class WebSecurityConfigurationTests {
} }
@Test @Test
public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() throws Exception { public void loadConfigWhenDefaultWebInvocationPrivilegeEvaluatorThenDefaultIsRegistered() {
this.spring.register(WebInvocationPrivilegeEvaluatorDefaultsConfig.class).autowire(); this.spring.register(WebInvocationPrivilegeEvaluatorDefaultsConfig.class).autowire();
assertThat(this.spring.getContext().getBean(WebInvocationPrivilegeEvaluator.class)) assertThat(this.spring.getContext().getBean(WebInvocationPrivilegeEvaluator.class))
@ -372,7 +372,7 @@ public class WebSecurityConfigurationTests {
// SEC-2461 // SEC-2461
@Test @Test
public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() throws Exception { public void loadConfigWhenMultipleWebSecurityConfigurationThenContextLoads() {
this.spring.register(ParentConfig.class).autowire(); this.spring.register(ParentConfig.class).autowire();
this.child.register(ChildConfig.class); this.child.register(ChildConfig.class);
@ -400,7 +400,7 @@ public class WebSecurityConfigurationTests {
// SEC-2773 // SEC-2773
@Test @Test
public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() throws Exception { public void getMethodDelegatingApplicationListenerWhenWebSecurityConfigurationThenIsStatic() {
Method method = ClassUtils.getMethod(WebSecurityConfiguration.class, "delegatingApplicationListener", null); Method method = ClassUtils.getMethod(WebSecurityConfiguration.class, "delegatingApplicationListener", null);
assertThat(Modifier.isStatic(method.getModifiers())).isTrue(); assertThat(Modifier.isStatic(method.getModifiers())).isTrue();
} }
@ -426,7 +426,7 @@ public class WebSecurityConfigurationTests {
@Order(1) @Order(1)
static class WebConfigurer1 extends WebSecurityConfigurerAdapter { static class WebConfigurer1 extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/ignore1", "/ignore2"); .antMatchers("/ignore1", "/ignore2");

View File

@ -71,7 +71,7 @@ public class CsrfConfigurerNoWebMvcTests {
static class EnableWebConfig extends WebSecurityConfigurerAdapter { static class EnableWebConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }
@ -88,7 +88,7 @@ public class CsrfConfigurerNoWebMvcTests {
static class EnableWebMvcConfig extends WebSecurityConfigurerAdapter { static class EnableWebMvcConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }

View File

@ -183,7 +183,7 @@ public class CsrfConfigurerTests {
static class CsrfAppliedDefaultConfig extends WebSecurityConfigurerAdapter { static class CsrfAppliedDefaultConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }

View File

@ -166,7 +166,7 @@ public class FormLoginConfigurerTests {
@EnableWebSecurity @EnableWebSecurity
static class FormLoginConfig extends WebSecurityConfigurerAdapter { static class FormLoginConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
// @formatter:off // @formatter:off
web web
.ignoring() .ignoring()

View File

@ -101,7 +101,7 @@ public class NamespaceHttpCustomFilterTests {
super(true); super(true);
} }
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
// this works so long as the CustomFilter extends one of the standard filters // this works so long as the CustomFilter extends one of the standard filters
// if not, use addFilterBefore or addFilterAfter // if not, use addFilterBefore or addFilterAfter
@ -123,7 +123,7 @@ public class NamespaceHttpCustomFilterTests {
super(true); super(true);
} }
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
http http
.addFilterAt(new OtherCustomFilter(), UsernamePasswordAuthenticationFilter.class); .addFilterAt(new OtherCustomFilter(), UsernamePasswordAuthenticationFilter.class);
} }
@ -141,8 +141,7 @@ public class NamespaceHttpCustomFilterTests {
super(true); super(true);
} }
protected AuthenticationManager authenticationManager() protected AuthenticationManager authenticationManager() {
throws Exception {
return new CustomAuthenticationManager(); return new CustomAuthenticationManager();
} }

View File

@ -50,7 +50,7 @@ public class NamespaceHttpFirewallTests {
MockMvc mvc; MockMvc mvc;
@Test @Test
public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() throws Exception { public void requestWhenPathContainsDoubleDotsThenBehaviorMatchesNamespace() {
this.rule.register(HttpFirewallConfig.class).autowire(); this.rule.register(HttpFirewallConfig.class).autowire();
assertThatCode(() -> this.mvc.perform(get("/public/../private/"))) assertThatCode(() -> this.mvc.perform(get("/public/../private/")))
.isInstanceOf(RequestRejectedException.class); .isInstanceOf(RequestRejectedException.class);
@ -69,7 +69,7 @@ public class NamespaceHttpFirewallTests {
@EnableWebSecurity @EnableWebSecurity
static class CustomHttpFirewallConfig extends WebSecurityConfigurerAdapter { static class CustomHttpFirewallConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.httpFirewall(new CustomHttpFirewall()); .httpFirewall(new CustomHttpFirewall());
} }

View File

@ -82,7 +82,7 @@ public class NamespaceHttpFormLoginTests {
static class FormLoginConfig extends WebSecurityConfigurerAdapter { static class FormLoginConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) {
web web
.ignoring() .ignoring()
.antMatchers("/resources/**"); .antMatchers("/resources/**");

View File

@ -81,7 +81,7 @@ public class NamespaceHttpLogoutTests {
@EnableWebSecurity @EnableWebSecurity
static class HttpLogoutConfig extends WebSecurityConfigurerAdapter { static class HttpLogoutConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
} }
} }

View File

@ -76,7 +76,7 @@ public class RememberMeConfigurerTests {
MockMvc mvc; MockMvc mvc;
@Test @Test
public void postWhenNoUserDetailsServiceThenException() throws Exception { public void postWhenNoUserDetailsServiceThenException() {
this.spring.register(NullUserDetailsConfig.class).autowire(); this.spring.register(NullUserDetailsConfig.class).autowire();
assertThatThrownBy(() -> assertThatThrownBy(() ->
@ -103,7 +103,7 @@ public class RememberMeConfigurerTests {
} }
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) {
User user = (User) PasswordEncodedUser.user(); User user = (User) PasswordEncodedUser.user();
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(user))); provider.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(user)));

View File

@ -223,7 +223,7 @@ public class ServletApiConfigurerTests {
static AuthenticationTrustResolver TR = spy(AuthenticationTrustResolver.class); static AuthenticationTrustResolver TR = spy(AuthenticationTrustResolver.class);
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
// @formatter:off // @formatter:off
http http
.setSharedObject(AuthenticationTrustResolver.class, TR); .setSharedObject(AuthenticationTrustResolver.class, TR);

View File

@ -476,7 +476,7 @@ public class SessionManagementConfigurerTests {
static AuthenticationTrustResolver TR; static AuthenticationTrustResolver TR;
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) {
// @formatter:off // @formatter:off
http http
.setSharedObject(AuthenticationTrustResolver.class, TR); .setSharedObject(AuthenticationTrustResolver.class, TR);

View File

@ -76,7 +76,7 @@ public class SessionManagementConfigurerTransientAuthenticationTests {
} }
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) {
auth auth
.authenticationProvider(new TransientAuthenticationProvider()); .authenticationProvider(new TransientAuthenticationProvider());
} }

View File

@ -1170,7 +1170,7 @@ public class OAuth2ResourceServerConfigurerTests {
} }
@Test @Test
public void configureWhenOnlyIntrospectionUrlThenException() throws Exception { public void configureWhenOnlyIntrospectionUrlThenException() {
assertThatCode(() -> this.spring.register(OpaqueTokenHalfConfiguredConfig.class).autowire()) assertThatCode(() -> this.spring.register(OpaqueTokenHalfConfiguredConfig.class).autowire())
.isInstanceOf(BeanCreationException.class); .isInstanceOf(BeanCreationException.class);
} }

View File

@ -134,7 +134,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void addsAuthenticationPrincipalResolver() throws InterruptedException { public void addsAuthenticationPrincipalResolver() {
loadConfig(SockJsSecurityConfig.class); loadConfig(SockJsSecurityConfig.class);
MessageChannel messageChannel = clientInboundChannel(); MessageChannel messageChannel = clientInboundChannel();
@ -146,8 +146,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void addsAuthenticationPrincipalResolverWhenNoAuthorization() public void addsAuthenticationPrincipalResolverWhenNoAuthorization() {
throws InterruptedException {
loadConfig(NoInboundSecurityConfig.class); loadConfig(NoInboundSecurityConfig.class);
MessageChannel messageChannel = clientInboundChannel(); MessageChannel messageChannel = clientInboundChannel();
@ -159,7 +158,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void addsCsrfProtectionWhenNoAuthorization() throws InterruptedException { public void addsCsrfProtectionWhenNoAuthorization() {
loadConfig(NoInboundSecurityConfig.class); loadConfig(NoInboundSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@ -177,7 +176,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void csrfProtectionForConnect() throws InterruptedException { public void csrfProtectionForConnect() {
loadConfig(SockJsSecurityConfig.class); loadConfig(SockJsSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@ -195,7 +194,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void csrfProtectionDisabledForConnect() throws InterruptedException { public void csrfProtectionDisabledForConnect() {
loadConfig(CsrfDisabledSockJsSecurityConfig.class); loadConfig(CsrfDisabledSockJsSecurityConfig.class);
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor
@ -265,8 +264,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void msmsRegistryCustomPatternMatcher() public void msmsRegistryCustomPatternMatcher() {
throws Exception {
loadConfig(MsmsRegistryCustomPatternMatcherConfig.class); loadConfig(MsmsRegistryCustomPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a.b")); clientInboundChannel().send(message("/app/a.b"));
@ -317,8 +315,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void overrideMsmsRegistryCustomPatternMatcher() public void overrideMsmsRegistryCustomPatternMatcher() {
throws Exception {
loadConfig(OverrideMsmsRegistryCustomPatternMatcherConfig.class); loadConfig(OverrideMsmsRegistryCustomPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a/b")); clientInboundChannel().send(message("/app/a/b"));
@ -371,8 +368,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void defaultPatternMatcher() public void defaultPatternMatcher() {
throws Exception {
loadConfig(DefaultPatternMatcherConfig.class); loadConfig(DefaultPatternMatcherConfig.class);
clientInboundChannel().send(message("/app/a/b")); clientInboundChannel().send(message("/app/a/b"));
@ -422,8 +418,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
} }
@Test @Test
public void customExpression() public void customExpression() {
throws Exception {
loadConfig(CustomExpressionConfig.class); loadConfig(CustomExpressionConfig.class);
clientInboundChannel().send(message("/denyRob")); clientInboundChannel().send(message("/denyRob"));
@ -612,8 +607,7 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
return parameter.getParameterType().isAssignableFrom(MyCustomArgument.class); return parameter.getParameterType().isAssignableFrom(MyCustomArgument.class);
} }
public Object resolveArgument(MethodParameter parameter, Message<?> message) public Object resolveArgument(MethodParameter parameter, Message<?> message) {
throws Exception {
return new MyCustomArgument(""); return new MyCustomArgument("");
} }
} }

View File

@ -54,7 +54,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
@Test @Test
// SEC-1225 // SEC-1225
public void providersAreRegisteredAsTopLevelBeans() throws Exception { public void providersAreRegisteredAsTopLevelBeans() {
ConfigurableApplicationContext context = this.spring.context(CONTEXT) ConfigurableApplicationContext context = this.spring.context(CONTEXT)
.getContext(); .getContext();
assertThat(context.getBeansOfType(AuthenticationProvider.class)).hasSize(1); assertThat(context.getBeansOfType(AuthenticationProvider.class)).hasSize(1);
@ -78,7 +78,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
} }
@Test @Test
public void credentialsAreClearedByDefault() throws Exception { public void credentialsAreClearedByDefault() {
ConfigurableApplicationContext appContext = this.spring.context(CONTEXT) ConfigurableApplicationContext appContext = this.spring.context(CONTEXT)
.getContext(); .getContext();
ProviderManager pm = (ProviderManager) appContext ProviderManager pm = (ProviderManager) appContext
@ -87,7 +87,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
} }
@Test @Test
public void clearCredentialsPropertyIsRespected() throws Exception { public void clearCredentialsPropertyIsRespected() {
ConfigurableApplicationContext appContext = this.spring.context("<authentication-manager erase-credentials='false'/>") ConfigurableApplicationContext appContext = this.spring.context("<authentication-manager erase-credentials='false'/>")
.getContext(); .getContext();
ProviderManager pm = (ProviderManager) appContext ProviderManager pm = (ProviderManager) appContext

View File

@ -57,7 +57,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
} }
@Test @Test
public void externalUserServiceRefWorks() throws Exception { public void externalUserServiceRefWorks() {
appContext = new InMemoryXmlApplicationContext( appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>" " <authentication-manager>"
+ " <authentication-provider user-service-ref='myUserService' />" + " <authentication-provider user-service-ref='myUserService' />"
@ -69,7 +69,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
} }
@Test @Test
public void providerWithBCryptPasswordEncoderWorks() throws Exception { public void providerWithBCryptPasswordEncoderWorks() {
setContext(" <authentication-provider>" setContext(" <authentication-provider>"
+ " <password-encoder hash='bcrypt'/>" + " <password-encoder hash='bcrypt'/>"
+ " <user-service>" + " <user-service>"
@ -80,7 +80,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
} }
@Test @Test
public void providerWithMd5PasswordEncoderWorks() throws Exception { public void providerWithMd5PasswordEncoderWorks() {
appContext = new InMemoryXmlApplicationContext( appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>" " <authentication-manager>"
+ " <authentication-provider>" + " <authentication-provider>"
@ -99,7 +99,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
} }
@Test @Test
public void providerWithShaPasswordEncoderWorks() throws Exception { public void providerWithShaPasswordEncoderWorks() {
appContext = new InMemoryXmlApplicationContext( appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>" " <authentication-manager>"
+ " <authentication-provider>" + " <authentication-provider>"
@ -116,7 +116,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
} }
@Test @Test
public void passwordIsBase64EncodedWhenBase64IsEnabled() throws Exception { public void passwordIsBase64EncodedWhenBase64IsEnabled() {
appContext = new InMemoryXmlApplicationContext( appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>" " <authentication-manager>"
+ " <authentication-provider>" + " <authentication-provider>"
@ -137,7 +137,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
// SEC-1466 // SEC-1466
@Test(expected = BeanDefinitionParsingException.class) @Test(expected = BeanDefinitionParsingException.class)
public void exernalProviderDoesNotSupportChildElements() throws Exception { public void exernalProviderDoesNotSupportChildElements() {
appContext = new InMemoryXmlApplicationContext( appContext = new InMemoryXmlApplicationContext(
" <authentication-manager>" " <authentication-manager>"
+ " <authentication-provider ref='aProvider'> " + " <authentication-provider ref='aProvider'> "

View File

@ -61,7 +61,7 @@ public class JdbcUserServiceBeanDefinitionParserTests {
} }
@Test @Test
public void beanNameIsCorrect() throws Exception { public void beanNameIsCorrect() {
assertThat(JdbcUserDetailsManager.class.getName()).isEqualTo( assertThat(JdbcUserDetailsManager.class.getName()).isEqualTo(
new JdbcUserServiceBeanDefinitionParser() new JdbcUserServiceBeanDefinitionParser()
.getBeanClassName(mock(Element.class))); .getBeanClassName(mock(Element.class)));

Some files were not shown because too many files have changed in this diff Show More